Search in sources :

Example 1 with PropertyPointer

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

the class DiagramParseTreeWalker method visitPropertyView.

private PropertyView visitPropertyView(DiagramParserGrammar.PropertyViewContext ctx) {
    PropertyView propertyView = new PropertyView();
    propertyView.sourceInformation = walkerSourceInformation.getSourceInformation(ctx);
    // Property
    PropertyPointer propertyPointer = new PropertyPointer();
    DiagramParserGrammar.PropertyHolderViewPropertyPropContext propertyPropContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.propertyHolderViewPropertyProp(), "property", propertyView.sourceInformation);
    propertyPointer._class = PureGrammarParserUtility.fromQualifiedName(propertyPropContext.qualifiedName().packagePath() == null ? Collections.emptyList() : propertyPropContext.qualifiedName().packagePath().identifier(), propertyPropContext.qualifiedName().identifier());
    propertyPointer.property = PureGrammarParserUtility.fromIdentifier(propertyPropContext.identifier());
    propertyPointer.sourceInformation = walkerSourceInformation.getSourceInformation(propertyPropContext.qualifiedName());
    propertyView.property = propertyPointer;
    // Line
    Line line = new Line();
    DiagramParserGrammar.RelationshipViewPointsPropContext pointsPropContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.relationshipViewPointsProp(), "points", propertyView.sourceInformation);
    line.points = ListIterate.collect(pointsPropContext.numberPair(), this::visitPoint);
    propertyView.line = line;
    // Source
    DiagramParserGrammar.RelationshipViewSourcePropContext sourcePropContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.relationshipViewSourceProp(), "source", propertyView.sourceInformation);
    propertyView.sourceView = sourcePropContext.viewId().getText();
    propertyView.sourceViewSourceInformation = walkerSourceInformation.getSourceInformation(sourcePropContext.viewId());
    // Target
    DiagramParserGrammar.RelationshipViewTargetPropContext targetPropContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.relationshipViewTargetProp(), "target", propertyView.sourceInformation);
    propertyView.targetView = targetPropContext.viewId().getText();
    propertyView.targetViewSourceInformation = walkerSourceInformation.getSourceInformation(targetPropContext.viewId());
    return propertyView;
}
Also used : Line(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.diagram.geometry.Line) DiagramParserGrammar(org.finos.legend.engine.language.pure.grammar.from.antlr4.DiagramParserGrammar) PropertyPointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyPointer) PropertyView(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.diagram.PropertyView)

Example 2 with PropertyPointer

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

the class RelationalParseTreeWalker method visitOtherwisePropertyMapping.

private RelationalPropertyMapping visitOtherwisePropertyMapping(RelationalParserGrammar.OtherwisePropertyMappingContext ctx, PropertyPointer propertyPointer, ScopeInfo scopeInfo) {
    RelationalPropertyMapping relationalPropertyMapping = new RelationalPropertyMapping();
    relationalPropertyMapping.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx);
    relationalPropertyMapping.property = propertyPointer;
    relationalPropertyMapping.target = PureGrammarParserUtility.fromIdentifier(ctx.identifier());
    String database = ctx.databasePointer() != null ? this.visitDatabasePointer(ctx.databasePointer()) : null;
    ElementWithJoins operation = new ElementWithJoins();
    operation.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx);
    operation.joins = this.visitJoinSequence(ctx.joinSequence(), database, scopeInfo);
    relationalPropertyMapping.relationalOperation = operation;
    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) ElementWithJoins(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.operation.ElementWithJoins)

Example 3 with PropertyPointer

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

the class RelationalParseTreeWalker method visitInlineEmbeddedPropertyMapping.

private PropertyMapping visitInlineEmbeddedPropertyMapping(RelationalParserGrammar.InlineEmbeddedPropertyMappingContext ctx, PropertyPointer propertyPointer, String targetId) {
    InlineEmbeddedPropertyMapping inlineEmbeddedPropertyMapping = new InlineEmbeddedPropertyMapping();
    inlineEmbeddedPropertyMapping.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx);
    inlineEmbeddedPropertyMapping.id = targetId;
    inlineEmbeddedPropertyMapping.target = targetId;
    inlineEmbeddedPropertyMapping.property = propertyPointer;
    inlineEmbeddedPropertyMapping.setImplementationId = PureGrammarParserUtility.fromIdentifier(ctx.identifier());
    return inlineEmbeddedPropertyMapping;
}
Also used : InlineEmbeddedPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.InlineEmbeddedPropertyMapping)

Example 4 with PropertyPointer

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyPointer 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 5 with PropertyPointer

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

the class XStoreAssociationMappingParseTreeWalker method visitXStorePropertyMapping.

private XStorePropertyMapping visitXStorePropertyMapping(XStoreAssociationMappingParserGrammar.XStorePropertyMappingContext ctx, String association) {
    XStorePropertyMapping xStorePropertyMapping = new XStorePropertyMapping();
    xStorePropertyMapping.property = new PropertyPointer();
    xStorePropertyMapping.property._class = association;
    xStorePropertyMapping.property.property = PureGrammarParserUtility.fromQualifiedName(ctx.qualifiedName().packagePath() == null ? Collections.emptyList() : ctx.qualifiedName().packagePath().identifier(), ctx.qualifiedName().identifier());
    xStorePropertyMapping.property.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx.qualifiedName());
    xStorePropertyMapping.source = ctx.sourceAndTargetMappingId() == null ? "" : ctx.sourceAndTargetMappingId().sourceId().getText();
    xStorePropertyMapping.target = ctx.sourceAndTargetMappingId() == null ? "" : ctx.sourceAndTargetMappingId().targetId().getText();
    xStorePropertyMapping.crossExpression = visitLambda(ctx.combinedExpression());
    xStorePropertyMapping.sourceInformation = this.walkerSourceInformation.getSourceInformation(ctx);
    return xStorePropertyMapping;
}
Also used : XStorePropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.xStore.XStorePropertyMapping) PropertyPointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyPointer)

Aggregations

PropertyPointer (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyPointer)5 LocalMappingPropertyInfo (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.LocalMappingPropertyInfo)3 EmbeddedRelationalPropertyMapping (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.EmbeddedRelationalPropertyMapping)3 OtherwiseEmbeddedRelationalPropertyMapping (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.OtherwiseEmbeddedRelationalPropertyMapping)3 RelationalPropertyMapping (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RelationalPropertyMapping)3 RelationalParserGrammar (org.finos.legend.engine.language.pure.grammar.from.antlr4.RelationalParserGrammar)2 Multiplicity (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Multiplicity)2 InlineEmbeddedPropertyMapping (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.InlineEmbeddedPropertyMapping)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 ParserRuleContext (org.antlr.v4.runtime.ParserRuleContext)1 Token (org.antlr.v4.runtime.Token)1 Interval (org.antlr.v4.runtime.misc.Interval)1 Sets (org.eclipse.collections.api.factory.Sets)1 MutableList (org.eclipse.collections.api.list.MutableList)1 ImmutableSet (org.eclipse.collections.api.set.ImmutableSet)1 FastList (org.eclipse.collections.impl.list.mutable.FastList)1