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;
}
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;
}
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);
}
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);
}
Aggregations