Search in sources :

Example 1 with SourceInformation

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();
}
Also used : PureModel(org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel) PackageableElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement) Logger(org.slf4j.Logger) GenerationCompilerExtension(org.finos.legend.engine.language.pure.dsl.generation.compiler.toPureGraph.GenerationCompilerExtension) EngineErrorType(org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType) GenerationSpecification(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.generationSpecification.GenerationSpecification) Iterate(org.eclipse.collections.impl.utility.Iterate) ListIterate(org.eclipse.collections.impl.utility.ListIterate) SourceInformation(org.finos.legend.engine.protocol.pure.v1.model.SourceInformation) Objects(java.util.Objects) Function3(org.eclipse.collections.api.block.function.Function3) List(java.util.List) MutableMap(org.eclipse.collections.api.map.MutableMap) PureModelContextData(org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData) CompileContext(org.finos.legend.engine.language.pure.compiler.toPureGraph.CompileContext) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) DeploymentMode(org.finos.legend.engine.shared.core.deployment.DeploymentMode) HelperGenerationSpecificationBuilder(org.finos.legend.engine.language.pure.dsl.generation.compiler.toPureGraph.HelperGenerationSpecificationBuilder) GenerationTreeNode(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.generationSpecification.GenerationTreeNode) GenerationCompilerExtension(org.finos.legend.engine.language.pure.dsl.generation.compiler.toPureGraph.GenerationCompilerExtension) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) Function3(org.eclipse.collections.api.block.function.Function3) Objects(java.util.Objects) GenerationTreeNode(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.generationSpecification.GenerationTreeNode)

Example 2 with SourceInformation

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;
}
Also used : DataSpaceParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.DataSpaceParserGrammar) DataSpaceExecutionContext(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.dataSpace.DataSpaceExecutionContext) PackageableElementPointer(org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer)

Example 3 with SourceInformation

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;
}
Also used : DataSpaceParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.DataSpaceParserGrammar) DataSpaceSupportEmail(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.dataSpace.DataSpaceSupportEmail)

Example 4 with SourceInformation

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);
}
Also used : OpaqueTrigger(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.persistence.trigger.OpaqueTrigger) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) ParseTreeWalkerSourceInformation(org.finos.legend.engine.language.pure.grammar.from.ParseTreeWalkerSourceInformation) SourceInformation(org.finos.legend.engine.protocol.pure.v1.model.SourceInformation)

Example 5 with SourceInformation

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;
}
Also used : PersistenceParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.PersistenceParserGrammar) DeleteIndicatorMergeStrategy(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.persistence.batch.mode.delta.merge.DeleteIndicatorMergeStrategy) ParseTreeWalkerSourceInformation(org.finos.legend.engine.language.pure.grammar.from.ParseTreeWalkerSourceInformation) SourceInformation(org.finos.legend.engine.protocol.pure.v1.model.SourceInformation)

Aggregations

EngineException (org.finos.legend.engine.shared.core.operational.errorManagement.EngineException)37 SourceInformation (org.finos.legend.engine.protocol.pure.v1.model.SourceInformation)31 EngineErrorType (org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType)22 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)17 ListIterate (org.eclipse.collections.impl.utility.ListIterate)16 List (java.util.List)13 Type (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type)13 RichIterable (org.eclipse.collections.api.RichIterable)11 Lists (org.eclipse.collections.impl.factory.Lists)11 FastList (org.eclipse.collections.impl.list.mutable.FastList)10 LoggingEventType (org.finos.legend.engine.shared.core.operational.logs.LoggingEventType)8 Objects (java.util.Objects)7 ParseTreeWalkerSourceInformation (org.finos.legend.engine.language.pure.grammar.from.ParseTreeWalkerSourceInformation)7 Class (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class)6 Variable (org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.Variable)6 Root_meta_pure_metamodel_type_generics_GenericType_Impl (org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl)6 PackageableElement (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement)6 MutableList (org.eclipse.collections.api.list.MutableList)5 Mapping (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping)5 PackageableRuntime (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime)5