27 lines
978 B
JavaScript
27 lines
978 B
JavaScript
requireJAR('dataaccess-1.0.jar');
|
|
|
|
var InMemoryCompiler = Packages.me.hatter.tools.commons.classloader.compile.InMemoryCompiler;
|
|
var EntityJavaSourceCodeGenerateTool = Packages.me.hatter.tools.dataaccess.entity.EntityJavaSourceCodeGenerateTool;
|
|
|
|
var systemInMemoryCompiler = InMemoryCompiler.systemInstance().updateClassPath();
|
|
var allCompiledEntityClassMap = {};
|
|
|
|
var generateClass = (json) => {
|
|
var sourceCode = EntityJavaSourceCodeGenerateTool.instance().config(json).generate();
|
|
var clazz = systemInMemoryCompiler.compile(sourceCode);
|
|
return clazz;
|
|
};
|
|
|
|
var getClass = (json) => {
|
|
var jsonSha256Hex = $$.digests().sha256().digest(json.getBytes('UTF-8')).asHex();
|
|
if (allCompiledEntityClassMap[jsonSha256Hex]) {
|
|
return allCompiledEntityClassMap[jsonSha256Hex];
|
|
}
|
|
var clazz = generateClass(json);
|
|
allCompiledEntityClassMap[jsonSha256Hex] = clazz;
|
|
return clazz;
|
|
};
|
|
|
|
exports.getClass = getClass;
|
|
exports.generateClass = generateClass;
|