use of org.finos.legend.pure.generated.Root_meta_pure_runtime_Runtime_Impl in project legend-sdlc by finos.
the class LegendPureV1TestCase method doSetUp.
@Override
protected void doSetUp() throws Exception {
// Initialize runtime
Runtime newRuntime = new Root_meta_pure_runtime_Runtime_Impl("");
ConnectionVisitor<org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.Connection> connectionVisitor1 = new ConnectionFirstPassBuilder(this.pureModel.getContext());
setUpTestData(conn -> newRuntime._connectionsAdd(conn.accept(connectionVisitor1)));
this.runtime = newRuntime;
}
use of org.finos.legend.pure.generated.Root_meta_pure_runtime_Runtime_Impl in project legend-engine by finos.
the class HelperRuntimeBuilder method buildEngineRuntime.
public static org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.Runtime buildEngineRuntime(EngineRuntime engineRuntime, CompileContext context) {
if (engineRuntime.mappings.isEmpty()) {
throw new EngineException("Runtime must cover at least one mapping", engineRuntime.sourceInformation, EngineErrorType.COMPILATION);
}
// verify if each mapping associated with the PackageableRuntime exists
List<Mapping> mappings = engineRuntime.mappings.stream().map(mappingPointer -> context.resolveMapping(mappingPointer.path, mappingPointer.sourceInformation)).collect(Collectors.toList());
// build connections
List<Connection> connections = new ArrayList<>();
Set<String> ids = new HashSet<>();
ListIterate.forEach(engineRuntime.connections, storeConnections -> {
if (!storeConnections.store.path.equals("ModelStore")) {
// verify stores used for indexing exist
context.resolveStore(storeConnections.store.path, storeConnections.store.sourceInformation);
}
ListIterate.forEach(storeConnections.storeConnections, identifiedConnection -> {
// ID must be unique across all connections of the runtime
if (ids.contains(identifiedConnection.id)) {
throw new EngineException("Runtime connection with ID '" + identifiedConnection.id + "' has already been specified", identifiedConnection.sourceInformation, EngineErrorType.COMPILATION);
} else {
ids.add(identifiedConnection.id);
}
if (identifiedConnection.connection instanceof ConnectionPointer) {
ConnectionPointer pointer = (ConnectionPointer) identifiedConnection.connection;
Store connectionStore = HelperRuntimeBuilder.getConnectionStore(context.resolveConnection(pointer.connection, pointer.sourceInformation));
String connectionStorePath = HelperModelBuilder.getElementFullPath(connectionStore, context.pureModel.getExecutionSupport());
if (!storeConnections.store.path.equals(connectionStorePath)) {
throw new EngineException("Connection pointer for store '" + connectionStorePath + "' should not be indexed to store '" + storeConnections.store.path + "'", pointer.sourceInformation, EngineErrorType.COMPILATION);
}
connections.add(identifiedConnection.connection);
} else if (storeConnections.store.path.equals(identifiedConnection.connection.element)) {
connections.add(identifiedConnection.connection);
} else if (identifiedConnection.connection.element == null) {
identifiedConnection.connection.element = storeConnections.store.path;
identifiedConnection.connection.elementSourceInformation = identifiedConnection.connection.sourceInformation;
connections.add(identifiedConnection.connection);
} else {
throw new EngineException("Connection for store '" + identifiedConnection.connection.element + "' should not be indexed to store '" + storeConnections.store.path + "'", identifiedConnection.connection.sourceInformation, EngineErrorType.COMPILATION);
}
});
});
// convert EngineRuntime with connection as a map indexes by store to Pure runtime which only contains an array of connections
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(connections, connection -> {
final org.finos.legend.pure.m3.coreinstance.meta.pure.runtime.Connection pureConnection = connection.accept(new ConnectionFirstPassBuilder(context));
connection.accept(new ConnectionSecondPassBuilder(context, pureConnection));
pureRuntime._connectionsAdd(pureConnection);
});
// verify runtime mapping coverage
checkRuntimeMappingCoverage(pureRuntime, mappings, context, engineRuntime.sourceInformation);
return pureRuntime;
}
use of org.finos.legend.pure.generated.Root_meta_pure_runtime_Runtime_Impl 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