Search in sources :

Example 1 with LocalMappingPropertyInfo

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.LocalMappingPropertyInfo in project legend-engine by finos.

the class PureInstanceClassMappingParseTreeWalker method visitPurePropertyMapping.

private PurePropertyMapping visitPurePropertyMapping(PureInstanceClassMappingParserGrammar.PropertyMappingContext ctx, MappingParserGrammar.MappingElementContext classMappingContext, PureInstanceClassMapping pureInstanceClassMapping) {
    PurePropertyMapping purePropertyMapping = new PurePropertyMapping();
    if (ctx.PLUS() != null) {
        // Local property mapping
        purePropertyMapping.localMappingProperty = new LocalMappingPropertyInfo();
        purePropertyMapping.localMappingProperty.type = ctx.type().getText();
        purePropertyMapping.localMappingProperty.multiplicity = buildMultiplicity(ctx.multiplicity().multiplicityArgument());
        purePropertyMapping.localMappingProperty.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx.qualifiedName());
    }
    purePropertyMapping.property = new PropertyPointer();
    purePropertyMapping.property._class = ctx.PLUS() != null ? null : PureGrammarParserUtility.fromQualifiedName(classMappingContext.qualifiedName().packagePath() == null ? Collections.emptyList() : classMappingContext.qualifiedName().packagePath().identifier(), classMappingContext.qualifiedName().identifier());
    purePropertyMapping.property.property = PureGrammarParserUtility.fromQualifiedName(ctx.qualifiedName().packagePath() == null ? Collections.emptyList() : ctx.qualifiedName().packagePath().identifier(), ctx.qualifiedName().identifier());
    purePropertyMapping.source = classMappingContext.mappingElementId() == null ? "" : classMappingContext.mappingElementId().getText();
    // This might looks strange but the parser rule looks like: sourceAndTargetMappingId: BRACKET_OPEN sourceId (COMMA targetId)? BRACKET_CLOSE
    // so in this case the class mapping ID is `sourceId`
    purePropertyMapping.target = ctx.sourceAndTargetMappingId() != null ? PureGrammarParserUtility.fromQualifiedName(ctx.sourceAndTargetMappingId().sourceId().qualifiedName().packagePath() == null ? Collections.emptyList() : ctx.sourceAndTargetMappingId().sourceId().qualifiedName().packagePath().identifier(), ctx.sourceAndTargetMappingId().sourceId().qualifiedName().identifier()) : null;
    if (ctx.ENUMERATION_MAPPING() != null) {
        purePropertyMapping.enumMappingId = PureGrammarParserUtility.fromIdentifier(ctx.identifier());
    }
    purePropertyMapping.transform = visitLambda(ctx.combinedExpression(), pureInstanceClassMapping);
    purePropertyMapping.property.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx.qualifiedName());
    purePropertyMapping.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx);
    purePropertyMapping.explodeProperty = ctx.STAR() != null;
    return purePropertyMapping;
}
Also used : LocalMappingPropertyInfo(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.LocalMappingPropertyInfo) PurePropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.modelToModel.mapping.PurePropertyMapping) PropertyPointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyPointer)

Example 2 with LocalMappingPropertyInfo

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.LocalMappingPropertyInfo in project legend-engine by finos.

the class RelationalParseTreeWalker method visitRelationalPropertyMapping.

private PropertyMapping visitRelationalPropertyMapping(RelationalParserGrammar.RelationalPropertyMappingContext ctx, PropertyPointer propertyPointer, LocalMappingPropertyInfo localMappingPropertyInfo, ScopeInfo scopeInfo, String classMappingId, String targetId) {
    RelationalPropertyMapping relationalPropertyMapping = new RelationalPropertyMapping();
    relationalPropertyMapping.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx);
    relationalPropertyMapping.localMappingProperty = localMappingPropertyInfo;
    relationalPropertyMapping.property = propertyPointer;
    relationalPropertyMapping.source = classMappingId;
    relationalPropertyMapping.target = targetId;
    relationalPropertyMapping.enumMappingId = ctx.transformer() != null && ctx.transformer().enumTransformer() != null ? PureGrammarParserUtility.fromIdentifier(ctx.transformer().enumTransformer().identifier()) : null;
    relationalPropertyMapping.bindingTransformer = ctx.transformer() != null && ctx.transformer().bindingTransformer() != null ? buildBindingTransformer(ctx.transformer().bindingTransformer()) : null;
    relationalPropertyMapping.relationalOperation = this.visitOperation(ctx.operation(), scopeInfo);
    return relationalPropertyMapping;
}
Also used : EmbeddedRelationalPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.EmbeddedRelationalPropertyMapping) OtherwiseEmbeddedRelationalPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.OtherwiseEmbeddedRelationalPropertyMapping) RelationalPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RelationalPropertyMapping)

Example 3 with LocalMappingPropertyInfo

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.LocalMappingPropertyInfo in project legend-engine by finos.

the class RelationalParseTreeWalker method visitPropertyMappingWithLocalMappingProperty.

private PropertyMapping visitPropertyMappingWithLocalMappingProperty(RelationalParserGrammar.SinglePropertyMappingWithPlusContext ctx, ScopeInfo scopeInfo, String classMappingId) {
    RelationalParserGrammar.LocalMappingPropertyContext localMappingPropertyContext = ctx.localMappingProperty();
    LocalMappingPropertyInfo localMappingPropertyInfo = new LocalMappingPropertyInfo();
    localMappingPropertyInfo.sourceInformation = this.walkerSourceInformation.getSourceInformation(localMappingPropertyContext);
    localMappingPropertyInfo.type = PureGrammarParserUtility.fromQualifiedName(localMappingPropertyContext.qualifiedName().packagePath() == null ? Collections.emptyList() : localMappingPropertyContext.qualifiedName().packagePath().identifier(), localMappingPropertyContext.qualifiedName().identifier());
    Multiplicity multiplicity = new Multiplicity();
    localMappingPropertyInfo.multiplicity = multiplicity;
    RelationalParserGrammar.LocalMappingPropertyFromMultiplicityContext fromMultiplicityContext = localMappingPropertyContext.localMappingPropertyFromMultiplicity();
    RelationalParserGrammar.LocalMappingPropertyToMultiplicityContext toMultiplicityContext = localMappingPropertyContext.localMappingPropertyToMultiplicity();
    multiplicity.lowerBound = fromMultiplicityContext == null ? Integer.parseInt("*".equals(toMultiplicityContext.getText()) ? "0" : toMultiplicityContext.getText()) : Integer.parseInt(fromMultiplicityContext.getText());
    multiplicity.setUpperBound("*".equals(toMultiplicityContext.getText()) ? null : Integer.parseInt(toMultiplicityContext.getText()));
    PropertyPointer propertyPointer = new PropertyPointer();
    propertyPointer.property = PureGrammarParserUtility.fromIdentifier(ctx.identifier());
    propertyPointer._class = null;
    propertyPointer.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx.identifier());
    return visitRelationalPropertyMapping(ctx.relationalPropertyMapping(), propertyPointer, localMappingPropertyInfo, scopeInfo, classMappingId, null);
}
Also used : LocalMappingPropertyInfo(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.LocalMappingPropertyInfo) Multiplicity(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Multiplicity) PropertyPointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyPointer) RelationalParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.RelationalParserGrammar)

Example 4 with LocalMappingPropertyInfo

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.LocalMappingPropertyInfo in project legend-engine by finos.

the class HelperMappingBuilder method getMappedProperty.

public static Property getMappedProperty(PropertyMapping propertyMapping, CompileContext context) {
    if (propertyMapping.localMappingProperty != null) {
        // Local property mapping
        LocalMappingPropertyInfo localMappingPropertyInfo = propertyMapping.localMappingProperty;
        // Raw type will be populated when mapping class is built
        GenericType sourceGenericType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("");
        GenericType targetGenericType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.resolveType(localMappingPropertyInfo.type, localMappingPropertyInfo.sourceInformation));
        GenericType propertyClassifierGenericType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::metamodel::function::property::Property"))._typeArguments(Lists.fixedSize.of(sourceGenericType, targetGenericType))._multiplicityArgumentsAdd(context.pureModel.getMultiplicity(localMappingPropertyInfo.multiplicity));
        return new Root_meta_pure_metamodel_function_property_Property_Impl<>(propertyMapping.property.property)._name(propertyMapping.property.property)._classifierGenericType(propertyClassifierGenericType)._genericType(targetGenericType)._multiplicity(context.pureModel.getMultiplicity(localMappingPropertyInfo.multiplicity));
    }
    return HelperModelBuilder.getPropertyOrResolvedEdgePointProperty(context, context.resolveClass(propertyMapping.property._class, propertyMapping.sourceInformation), Optional.empty(), propertyMapping.property.property, propertyMapping.sourceInformation);
}
Also used : LocalMappingPropertyInfo(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.LocalMappingPropertyInfo) GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) Root_meta_pure_metamodel_type_generics_GenericType_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl) Root_meta_pure_metamodel_function_property_Property_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_function_property_Property_Impl)

Aggregations

LocalMappingPropertyInfo (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.LocalMappingPropertyInfo)3 PropertyPointer (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyPointer)2 RelationalParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.RelationalParserGrammar)1 Multiplicity (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Multiplicity)1 PurePropertyMapping (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.modelToModel.mapping.PurePropertyMapping)1 EmbeddedRelationalPropertyMapping (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.EmbeddedRelationalPropertyMapping)1 OtherwiseEmbeddedRelationalPropertyMapping (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.OtherwiseEmbeddedRelationalPropertyMapping)1 RelationalPropertyMapping (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RelationalPropertyMapping)1 Root_meta_pure_metamodel_function_property_Property_Impl (org.finos.legend.pure.generated.Root_meta_pure_metamodel_function_property_Property_Impl)1 Root_meta_pure_metamodel_type_generics_GenericType_Impl (org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl)1 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)1