use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.LegacyRuntime in project legend-engine by finos.
the class ServiceTestGenerationHelper method buildRelationalTestRuntime.
private static Runtime buildRelationalTestRuntime(Runtime runtime, String mappingPath, String testDataCsv, List<String> sql) {
if (runtime instanceof LegacyRuntime) {
LegacyRuntime newRuntime = new LegacyRuntime();
newRuntime.connections = ListIterate.collect(((LegacyRuntime) runtime).connections, c -> newRelationalConnection(c, testDataCsv, sql));
return newRuntime;
}
if (runtime instanceof EngineRuntime) {
EngineRuntime testRuntime = new EngineRuntime();
PackageableElementPointer mappingPointer = new PackageableElementPointer();
mappingPointer.type = PackageableElementType.MAPPING;
mappingPointer.path = mappingPath;
testRuntime.mappings.add(mappingPointer);
testRuntime.connections = ListIterate.collect(((EngineRuntime) runtime).connections, c -> "ModelStore".equals(c.store.path) ? c : newRelationalStoreConnections(c, testDataCsv, sql));
return testRuntime;
}
if (runtime instanceof RuntimePointer) {
return runtime;
}
throw new UnsupportedOperationException("Unsupported runtime type: " + runtime.getClass().getName());
}
use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.LegacyRuntime in project legend-engine by finos.
the class TestM2MGrammarCompileAndExecute method runtimeValue.
private Runtime runtimeValue(Connection connection) {
LegacyRuntime runtime = new LegacyRuntime();
runtime.connections = Collections.singletonList(connection);
return runtime;
}
use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.LegacyRuntime in project legend-engine by finos.
the class ServiceTestGenerationHelper method resolveRuntime.
private static EngineRuntime resolveRuntime(Runtime runtime, PureModelContextData pureModelContextData) {
if (runtime instanceof EngineRuntime) {
return (EngineRuntime) runtime;
}
if (runtime instanceof LegacyRuntime) {
return ((LegacyRuntime) runtime).toEngineRuntime();
}
if (runtime instanceof RuntimePointer) {
String runtimeFullPath = ((RuntimePointer) runtime).runtime;
PackageableElement found = Iterate.detect(pureModelContextData.getElements(), e -> runtimeFullPath.equals(e.getPath()));
if (!(found instanceof PackageableRuntime)) {
throw new RuntimeException("Can't find runtime '" + runtimeFullPath + "'");
}
return ((PackageableRuntime) found).runtimeValue;
}
throw new UnsupportedOperationException("Unsupported runtime type: " + runtime.getClass().getName());
}
use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.LegacyRuntime in project legend-engine by finos.
the class TestExecutionScope method buildTestRuntime.
public static Runtime buildTestRuntime(Runtime runtime, String testData, List<String> setupSqls) {
if (runtime instanceof LegacyRuntime) {
LegacyRuntime newRuntime = new LegacyRuntime();
newRuntime.connections = ListIterate.collect(((LegacyRuntime) runtime).connections, connection -> {
if (connection instanceof ModelChainConnection) {
return connection;
}
return ConnectionManagerSelector.transformToTestConnectionSpecification(connection, testData, setupSqls);
});
return newRuntime;
} else if (runtime instanceof EngineRuntime) {
EngineRuntime newRuntime = new EngineRuntime();
newRuntime.connections = ListIterate.collect(((EngineRuntime) runtime).connections, storeConnections -> {
StoreConnections newStoreConnections = new StoreConnections();
newStoreConnections.store = storeConnections.store;
newStoreConnections.storeConnections = ListIterate.collect(storeConnections.storeConnections, identifiedConnection -> {
if (identifiedConnection.connection instanceof ModelChainConnection) {
return identifiedConnection;
}
IdentifiedConnection newIdentifiedConnection = new IdentifiedConnection();
newIdentifiedConnection.id = identifiedConnection.id;
newIdentifiedConnection.connection = ConnectionManagerSelector.transformToTestConnectionSpecification(identifiedConnection.connection, testData, setupSqls);
return newIdentifiedConnection;
});
return newStoreConnections;
});
return newRuntime;
} else if (runtime instanceof RuntimePointer) {
return runtime;
}
throw new UnsupportedOperationException();
}
use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.LegacyRuntime in project legend-engine by finos.
the class HelperRuntimeBuilder method buildPureRuntime.
public static org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.Runtime buildPureRuntime(Runtime runtime, CompileContext context) {
if (runtime == null) {
return null;
}
if (runtime instanceof LegacyRuntime) {
LegacyRuntime legacyRuntime = (LegacyRuntime) runtime;
org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.Runtime pureRuntime = new Root_meta_pure_runtime_Runtime_Impl("Root::meta::pure::runtime::Runtime");
ListIterate.forEach(legacyRuntime.connections, connection -> pureRuntime._connectionsAdd(connection.accept(new ConnectionFirstPassBuilder(context))));
return pureRuntime;
}
if (runtime instanceof EngineRuntime) {
return buildEngineRuntime(((EngineRuntime) runtime), context);
} else if (runtime instanceof RuntimePointer) {
return context.resolveRuntime(((RuntimePointer) runtime).runtime, ((RuntimePointer) runtime).sourceInformation);
}
throw new UnsupportedOperationException();
}
Aggregations