use of org.finos.legend.engine.protocol.pure.v1.model.SourceInformation in project legend-sdlc by finos.
the class ModelGenerationFactory method generate.
public PureModelContextData generate() throws Exception {
if ((this.generationSpecification._package == null) || this.generationSpecification._package.isEmpty()) {
throw new RuntimeException("Invalid generation specifications, missing path '" + this.generationSpecification.name);
}
LOGGER.info("Generation generation specification '" + generationSpecification.getPath() + "'");
List<GenerationTreeNode> nodes = this.generationSpecification.generationNodes;
for (GenerationTreeNode node : nodes) {
LOGGER.info("Start generating generation model element '" + node.generationElement + "'");
List<Function3<String, SourceInformation, CompileContext, org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement>> extraModelGenerationSpecificationResolvers = ListIterate.flatCollect(HelperGenerationSpecificationBuilder.getGenerationCompilerExtensions(this.pureModel.getContext()), GenerationCompilerExtension::getExtraModelGenerationSpecificationResolvers);
org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement generationElement = extraModelGenerationSpecificationResolvers.stream().map(resolver -> resolver.value(node.generationElement, node.sourceInformation, this.pureModel.getContext())).filter(Objects::nonNull).findFirst().orElseThrow(() -> new EngineException("Can't find generation element '" + node.generationElement + "'", node.sourceInformation, EngineErrorType.COMPILATION));
ModelGenerator modelGenerator = ModelGenerator.newGenerator(generationElement, this.pureModel);
processModelGenerator(modelGenerator);
}
return validateAndBuildGeneratedModel();
}
use of org.finos.legend.engine.protocol.pure.v1.model.SourceInformation 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.SourceInformation in project legend-engine by finos.
the class DataSpaceParseTreeWalker method visitDataSpaceSupportInfo.
// NOTE: for simplicity reason, in the grammar, we only support email address as the only support info type at the moment
// when there are more, we will handle the extension mechanism later
private DataSpaceSupportInfo visitDataSpaceSupportInfo(DataSpaceParserGrammar.SupportInfoContext ctx, SourceInformation dataSpaceSourceInformation) {
DataSpaceSupportEmail supportInfo = new DataSpaceSupportEmail();
// Email
DataSpaceParserGrammar.SupportEmailContext supportEmailContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.supportEmail(), "address", dataSpaceSourceInformation);
supportInfo.address = PureGrammarParserUtility.fromGrammarString(supportEmailContext.STRING().getText(), true);
return supportInfo;
}
use of org.finos.legend.engine.protocol.pure.v1.model.SourceInformation in project legend-engine by finos.
the class PersistenceParseTreeWalker method visitTrigger.
/**
********
* trigger
*********
*/
private Trigger visitTrigger(PersistenceParserGrammar.TriggerContext ctx) {
SourceInformation sourceInformation = walkerSourceInformation.getSourceInformation(ctx);
if (ctx.TRIGGER_OPAQUE() != null) {
OpaqueTrigger opaqueTrigger = new OpaqueTrigger();
opaqueTrigger.sourceInformation = sourceInformation;
return opaqueTrigger;
}
throw new EngineException("Unrecognized trigger", sourceInformation, EngineErrorType.PARSER);
}
use of org.finos.legend.engine.protocol.pure.v1.model.SourceInformation in project legend-engine by finos.
the class PersistenceParseTreeWalker method visitDeleteIndicatorMergeScheme.
private DeleteIndicatorMergeStrategy visitDeleteIndicatorMergeScheme(PersistenceParserGrammar.DeleteIndicatorMergeStrategyContext ctx) {
DeleteIndicatorMergeStrategy mergeStrategy = new DeleteIndicatorMergeStrategy();
SourceInformation sourceInformation = walkerSourceInformation.getSourceInformation(ctx);
// delete property
PersistenceParserGrammar.MergeStrategyDeletePropertyContext deletePropertyContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.mergeStrategyDeleteProperty(), "deleteProperty", sourceInformation);
mergeStrategy.deleteProperty = PureGrammarParserUtility.fromIdentifier(deletePropertyContext.identifier());
// delete values
PersistenceParserGrammar.MergeStrategyDeleteValuesContext deleteValuesContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.mergeStrategyDeleteValues(), "deleteValues", sourceInformation);
mergeStrategy.deleteValues = deleteValuesContext != null && deleteValuesContext.STRING() != null ? ListIterate.collect(deleteValuesContext.STRING(), deleteValueContext -> PureGrammarParserUtility.fromGrammarString(deleteValueContext.getText(), true)) : Collections.emptyList();
return mergeStrategy;
}
Aggregations