use of org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.Runtime in project legend-pure by finos.
the class M3CoreInstanceGenerator method main.
public static void main(String[] args) {
String outputDir = args[0];
String factoryNamePrefix = args[1];
String fileNameStr = args[2];
ListIterable<String> filePaths = StringIterate.tokensToList(fileNameStr, ",");
PureRuntime runtime = new PureRuntimeBuilder(new PureCodeStorage(Paths.get(""), new ClassLoaderCodeStorage(CodeRepository.newPlatformCodeRepository()))).setTransactionalByDefault(false).build();
ModelRepository repository = runtime.getModelRepository();
runtime.loadAndCompileCore();
M3ToJavaGenerator m3ToJavaGenerator = generator(outputDir, factoryNamePrefix, repository);
m3ToJavaGenerator.generate(repository, filePaths);
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.Runtime in project legend-pure by finos.
the class JavaClassLoaderSourceCodeGenerator method gen.
public static void gen(long start, Path filePath, String name, MutableList<CompiledExtension> extensions) {
RichIterable<CodeRepository> repositoriesForCompilation = Lists.fixedSize.of(CodeRepository.newPlatformCodeRepository());
PureCodeStorage codeStorage = new PureCodeStorage(null, new ClassLoaderCodeStorage(repositoriesForCompilation));
ClassLoaderPureGraphCache graphCache = new ClassLoaderPureGraphCache();
PureRuntime runtime = new PureRuntimeBuilder(codeStorage).withCache(graphCache).setTransactionalByDefault(false).buildAndTryToInitializeFromCache();
if (!runtime.isInitialized()) {
CacheState cacheState = graphCache.getCacheState();
if (cacheState != null) {
String lastStackTrace = cacheState.getLastStackTrace();
if (lastStackTrace != null) {
System.out.println("Cache initialization failure: " + lastStackTrace);
}
}
System.out.println("Initialization from caches failed - compiling from scratch");
runtime.reset();
runtime.loadAndCompileCore();
runtime.loadAndCompileSystem();
}
System.out.format("Finished Pure initialization (%.6fs)%n", (System.nanoTime() - start) / 1_000_000_000.0);
JavaSourceCodeGenerator javaSourceCodeGenerator = new JavaSourceCodeGenerator(runtime.getProcessorSupport(), runtime.getCodeStorage(), true, filePath, false, extensions, name, JavaPackageAndImportBuilder.externalizablePackage());
javaSourceCodeGenerator.generateCode();
javaSourceCodeGenerator.generatePureCoreHelperClasses(new ProcessorContext(runtime.getProcessorSupport(), false));
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.Runtime in project legend-pure by finos.
the class TestGraphIsSerialized method testInitializedFromGraphLoaderSerialization.
@Test
public void testInitializedFromGraphLoaderSerialization() {
PureRuntime runtime = new PureRuntimeBuilder(getCodeStorage()).buildAndInitialize();
PureGraphCache cache = new MemoryGraphLoaderPureGraphCache();
cache.setPureRuntime(runtime);
cache.cacheRepoAndSources();
runtime = new PureRuntimeBuilder(getCodeStorage()).withCache(cache).buildAndTryToInitializeFromCache();
new FunctionExecutionCompiledBuilder().build().init(runtime, new Message(""));
Assert.assertTrue(cache.getCacheState().getLastStackTrace(), runtime.isInitialized());
assertAllInstancesMarkedSerialized(runtime);
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.Runtime in project legend-pure by finos.
the class TestGraphIsSerialized method testInitializedFromM4Serialization.
@Test
public void testInitializedFromM4Serialization() {
PureRuntime runtime = new PureRuntimeBuilder(getCodeStorage()).buildAndInitialize();
PureGraphCache cache = new MemoryPureGraphCache();
cache.setPureRuntime(runtime);
cache.cacheRepoAndSources();
runtime = new PureRuntimeBuilder(getCodeStorage()).withCache(cache).buildAndTryToInitializeFromCache();
new FunctionExecutionCompiledBuilder().build().init(runtime, new Message(""));
Assert.assertTrue(cache.getCacheState().getLastStackTrace(), runtime.isInitialized());
assertAllInstancesMarkedSerialized(runtime);
}
use of org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.Runtime in project legend-pure by finos.
the class TestMilestonedPropertyUsageInFunctionExpressions method testAllVersionsInRangePropertyUsageForCrossTemporal.
@ToFix
@Ignore
@Test
public void testAllVersionsInRangePropertyUsageForCrossTemporal() {
runtime.createInMemorySource("test.pure", "import meta::test::milestoning::domain::*;\n" + "Class <<temporal.businesstemporal>> meta::test::milestoning::domain::Product{\n" + " classification : Classification[*];\n" + "}\n" + "Class <<temporal.processingtemporal>> meta::test::milestoning::domain::Classification{\n" + " exchangeName : String[0..1];\n" + "}\n" + "function go():Any[*]\n" + "{\n" + " {|Product.allVersionsInRange(%2018-1-1, %2018-1-9).classificationAllVersionsInRange(%2018-1-1, %2018-1-9)}\n" + "}\n");
runtime.compile();
runtime.modify("test.pure", "import meta::test::milestoning::domain::*;\n" + "Class <<temporal.bitemporal>> meta::test::milestoning::domain::Product{\n" + " classification : Classification[*];\n" + "}\n" + "Class <<temporal.businesstemporal>> meta::test::milestoning::domain::Classification{\n" + " exchangeName : String[0..1];\n" + "}\n" + "function go():Any[*]\n" + "{\n" + " {|Product.all(%2018-1-1, %2018-1-9).classificationAllVersionsInRange(%2018-1-1, %2018-1-9)}\n" + "}\n");
runtime.compile();
runtime.modify("test.pure", "import meta::test::milestoning::domain::*;\n" + "Class <<temporal.bitemporal>> meta::test::milestoning::domain::Product{\n" + " classification : Classification[*];\n" + "}\n" + "Class <<temporal.processingtemporal>> meta::test::milestoning::domain::Classification{\n" + " exchangeName : String[0..1];\n" + "}\n" + "function go():Any[*]\n" + "{\n" + " {|Product.all(%2018-1-1, %2018-1-9).classificationAllVersionsInRange(%2018-1-1, %2018-1-9)}\n" + "}\n");
runtime.compile();
runtime.modify("test.pure", "import meta::test::milestoning::domain::*;\n" + "Class <<temporal.businesstemporal>> meta::test::milestoning::domain::Product{\n" + " classification : Classification[*];\n" + "}\n" + "Class <<temporal.bitemporal>> meta::test::milestoning::domain::Classification{\n" + " exchangeName : String[0..1];\n" + "}\n" + "function go():Any[*]\n" + "{\n" + " {|Product.allVersionsInRange(%2018-1-1, %2018-1-9).classificationAllVersionsInRange(%2018-1-1, %2018-1-9)}\n" + "}\n");
PureCompilationException e1 = Assert.assertThrows(PureCompilationException.class, runtime::compile);
Assert.assertEquals("Compilation error at (resource:test.pure line:10 column:55), \"The system can't find a match for the function: classificationAllVersionsInRange(_:Product[1],_:StrictDate[1],_:StrictDate[1])", e1.getMessage());
runtime.modify("test.pure", "import meta::test::milestoning::domain::*;\n" + "Class <<temporal.processingtemporal>> meta::test::milestoning::domain::Product{\n" + " classification : Classification[*];\n" + "}\n" + "Class <<temporal.bitemporal>> meta::test::milestoning::domain::Classification{\n" + " exchangeName : String[0..1];\n" + "}\n" + "function go():Any[*]\n" + "{\n" + " {|Product.allVersionsInRange(%2018-1-1, %2018-1-9).classificationAllVersionsInRange(%2018-1-1, %2018-1-9)}\n" + "}\n");
PureCompilationException e2 = Assert.assertThrows(PureCompilationException.class, runtime::compile);
Assert.assertEquals("Compilation error at (resource:test.pure line:10 column:55), \"The system can't find a match for the function: classificationAllVersionsInRange(_:Product[1],_:StrictDate[1],_:StrictDate[1])", e2.getMessage());
runtime.modify("test.pure", "import meta::test::milestoning::domain::*;\n" + "Class <<temporal.processingtemporal>> meta::test::milestoning::domain::Product{\n" + " classification : Classification[*];\n" + "}\n" + "Class <<temporal.businesstemporal>> meta::test::milestoning::domain::Classification{\n" + " exchangeName : String[0..1];\n" + "}\n" + "function go():Any[*]\n" + "{\n" + " {|Product.allVersionsInRange(%2018-1-1, %2018-1-9).classificationAllVersionsInRange(%2018-1-1, %2018-1-9)}\n" + "}\n");
runtime.compile();
}
Aggregations