use of org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer 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.context.PackageableElementPointer in project legend-engine by finos.
the class GenerationSpecificationParseTreeWalker method visitFileGeneration.
private PackageableElementPointer visitFileGeneration(GenerationSpecificationParserGrammar.QualifiedNameContext ctx) {
PackageableElementPointer packageableElementPointer = new PackageableElementPointer();
packageableElementPointer.type = PackageableElementType.FILE_GENERATION;
packageableElementPointer.path = PureGrammarParserUtility.fromQualifiedName(ctx.packagePath() == null ? Collections.emptyList() : ctx.packagePath().identifier(), ctx.identifier());
packageableElementPointer.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx);
return packageableElementPointer;
}
use of org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer in project legend-engine by finos.
the class DataSpaceParseTreeWalker method visitDataSpaceExecutionContext.
private DataSpaceExecutionContext visitDataSpaceExecutionContext(DataSpaceParserGrammar.ExecutionContextContext ctx, SourceInformation dataSpaceSourceInformation) {
DataSpaceExecutionContext executionContext = new DataSpaceExecutionContext();
// Name
DataSpaceParserGrammar.ExecutionContextNameContext executionContextNameContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.executionContextName(), "name", dataSpaceSourceInformation);
executionContext.name = PureGrammarParserUtility.fromGrammarString(executionContextNameContext.STRING().getText(), true);
// Description (optional)
DataSpaceParserGrammar.DescriptionContext descriptionContext = PureGrammarParserUtility.validateAndExtractOptionalField(ctx.description(), "description", dataSpaceSourceInformation);
executionContext.description = descriptionContext != null ? PureGrammarParserUtility.fromGrammarString(descriptionContext.STRING().getText(), true) : null;
// Mapping
DataSpaceParserGrammar.MappingContext mappingContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.mapping(), "mapping", dataSpaceSourceInformation);
executionContext.mapping = new PackageableElementPointer(PackageableElementType.MAPPING, PureGrammarParserUtility.fromQualifiedName(mappingContext.qualifiedName().packagePath() == null ? Collections.emptyList() : mappingContext.qualifiedName().packagePath().identifier(), mappingContext.qualifiedName().identifier()));
executionContext.mapping.sourceInformation = walkerSourceInformation.getSourceInformation(mappingContext);
// Runtime
DataSpaceParserGrammar.DefaultRuntimeContext defaultRuntimeContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.defaultRuntime(), "defaultRuntime", dataSpaceSourceInformation);
executionContext.defaultRuntime = new PackageableElementPointer(PackageableElementType.RUNTIME, PureGrammarParserUtility.fromQualifiedName(defaultRuntimeContext.qualifiedName().packagePath() == null ? Collections.emptyList() : defaultRuntimeContext.qualifiedName().packagePath().identifier(), defaultRuntimeContext.qualifiedName().identifier()));
executionContext.defaultRuntime.sourceInformation = walkerSourceInformation.getSourceInformation(defaultRuntimeContext);
return executionContext;
}
use of org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer in project legend-engine by finos.
the class DataSpaceParseTreeWalker method visitDataSpace.
private DataSpace visitDataSpace(DataSpaceParserGrammar.DataSpaceElementContext ctx) {
DataSpace dataSpace = new DataSpace();
dataSpace.name = PureGrammarParserUtility.fromIdentifier(ctx.qualifiedName().identifier());
dataSpace._package = ctx.qualifiedName().packagePath() == null ? "" : PureGrammarParserUtility.fromPath(ctx.qualifiedName().packagePath().identifier());
dataSpace.sourceInformation = walkerSourceInformation.getSourceInformation(ctx);
dataSpace.stereotypes = ctx.stereotypes() == null ? Lists.mutable.empty() : this.visitStereotypes(ctx.stereotypes());
dataSpace.taggedValues = ctx.taggedValues() == null ? Lists.mutable.empty() : this.visitTaggedValues(ctx.taggedValues());
// Group ID
DataSpaceParserGrammar.GroupIdContext groupIdContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.groupId(), "groupId", dataSpace.sourceInformation);
dataSpace.groupId = PureGrammarParserUtility.fromGrammarString(groupIdContext.STRING().getText(), true);
// Artifact ID
DataSpaceParserGrammar.ArtifactIdContext artifactIdContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.artifactId(), "artifactId", dataSpace.sourceInformation);
dataSpace.artifactId = PureGrammarParserUtility.fromGrammarString(artifactIdContext.STRING().getText(), true);
// Version ID
DataSpaceParserGrammar.VersionIdContext versionIdContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.versionId(), "versionId", dataSpace.sourceInformation);
dataSpace.versionId = PureGrammarParserUtility.fromGrammarString(versionIdContext.STRING().getText(), true);
// Execution contexts
DataSpaceParserGrammar.ExecutionContextsContext executionContextsContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.executionContexts(), "executionContexts", dataSpace.sourceInformation);
dataSpace.executionContexts = ListIterate.collect(executionContextsContext.executionContext(), executionContext -> this.visitDataSpaceExecutionContext(executionContext, dataSpace.sourceInformation));
// Default execution context
DataSpaceParserGrammar.DefaultExecutionContextContext defaultExecutionContextContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.defaultExecutionContext(), "defaultExecutionContext", dataSpace.sourceInformation);
dataSpace.defaultExecutionContext = PureGrammarParserUtility.fromGrammarString(defaultExecutionContextContext.STRING().getText(), true);
// Description (optional)
DataSpaceParserGrammar.DescriptionContext descriptionContext = PureGrammarParserUtility.validateAndExtractOptionalField(ctx.description(), "description", dataSpace.sourceInformation);
dataSpace.description = descriptionContext != null ? PureGrammarParserUtility.fromGrammarString(descriptionContext.STRING().getText(), true) : null;
// Featured diagrams (optional)
DataSpaceParserGrammar.FeaturedDiagramsContext featuredDiagramsContext = PureGrammarParserUtility.validateAndExtractOptionalField(ctx.featuredDiagrams(), "featuredDiagrams", dataSpace.sourceInformation);
dataSpace.featuredDiagrams = featuredDiagramsContext != null ? ListIterate.collect(featuredDiagramsContext.qualifiedName(), diagramPathContext -> {
PackageableElementPointer pointer = new PackageableElementPointer(PackageableElementType.DIAGRAM, PureGrammarParserUtility.fromQualifiedName(diagramPathContext.packagePath() == null ? Collections.emptyList() : diagramPathContext.packagePath().identifier(), diagramPathContext.identifier()));
pointer.sourceInformation = walkerSourceInformation.getSourceInformation(diagramPathContext);
return pointer;
}) : null;
// Support info (optional)
DataSpaceParserGrammar.SupportInfoContext supportInfoContext = PureGrammarParserUtility.validateAndExtractOptionalField(ctx.supportInfo(), "supportInfo", dataSpace.sourceInformation);
dataSpace.supportInfo = supportInfoContext != null ? this.visitDataSpaceSupportInfo(supportInfoContext, dataSpace.sourceInformation) : null;
return dataSpace;
}
use of org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer in project legend-engine by finos.
the class LegacyRuntime method toEngineRuntime.
@JsonIgnore
public EngineRuntime toEngineRuntime() {
EngineRuntime engineRuntime = new EngineRuntime();
AtomicInteger counter = new AtomicInteger(1);
engineRuntime.mappings = this.mappings;
ListIterate.forEach(this.connections, connection -> {
IdentifiedConnection identifiedConnection = new IdentifiedConnection();
// adhoc connection id creation
identifiedConnection.id = "connection_" + counter;
identifiedConnection.connection = connection;
counter.getAndIncrement();
// find the current connections by store and update
if (engineRuntime.getStoreConnections(connection.element) != null) {
engineRuntime.getStoreConnections(connection.element).storeConnections.add(identifiedConnection);
} else {
StoreConnections storeConnections = new StoreConnections();
storeConnections.storeConnections.add(identifiedConnection);
PackageableElementPointer storePointer = new PackageableElementPointer();
storePointer.type = PackageableElementType.STORE;
storePointer.path = connection.element;
storeConnections.store = storePointer;
engineRuntime.connections.add(storeConnections);
}
});
return engineRuntime;
}
Aggregations