Search in sources :

Example 1 with PropertyMappingValueSpecificationContext

use of org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingValueSpecificationContext in project legend-pure by finos.

the class PropertyMappingValueSpecificationContextUnloaderWalk method run.

@Override
public void run(PropertyMappingValueSpecificationContext propertyMappingValueSpecificationContext, MatcherState state, Matcher matcher, ModelRepository modelRepository, Context context) throws PureCompilationException {
    PropertyMapping propertyMapping = propertyMappingValueSpecificationContext._propertyMapping();
    matcher.fullMatch(propertyMapping, state);
}
Also used : PropertyMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMapping)

Example 2 with PropertyMappingValueSpecificationContext

use of org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingValueSpecificationContext in project legend-pure by finos.

the class PureInstanceSetImplementationProcessor method process.

@Override
public void process(PureInstanceSetImplementation classMapping, ProcessorState state, Matcher matcher, ModelRepository repository, Context context, ProcessorSupport processorSupport) {
    Type srcClass = (Type) ImportStub.withImportStubByPass(classMapping._srcClassCoreInstance(), processorSupport);
    SourceInformation srcGenericTypeSourceInfo = null;
    LambdaFunction<?> filter = classMapping._filter();
    if (filter != null) {
        state.pushVariableContext();
        if (srcClass != null) {
            FunctionType fType = getFunctionType(filter, processorSupport);
            fType._parameters(Lists.mutable.<VariableExpression>withAll(fType._parameters()).with(createSrcParameter(srcClass, srcGenericTypeSourceInfo, filter.getSourceInformation(), processorSupport)));
        }
        matcher.fullMatch(filter, state);
        state.popVariableContext();
    }
    int i = 0;
    for (PropertyMapping propertyMapping : classMapping._propertyMappings()) {
        state.pushVariableContext();
        if (((PurePropertyMapping) propertyMapping)._transformerCoreInstance() != null) {
            GrammarInfoStub transformerStub = (GrammarInfoStub) ((PurePropertyMapping) propertyMapping)._transformerCoreInstance();
            EnumerationMappingProcessor.processsEnumerationTransformer(transformerStub, propertyMapping, processorSupport);
        }
        LambdaFunction<?> transform = ((PurePropertyMapping) propertyMapping)._transform();
        if (srcClass != null) {
            FunctionType fType = getFunctionType(transform, processorSupport);
            fType._parameters(Lists.mutable.<VariableExpression>withAll(fType._parameters()).with(createSrcParameter(srcClass, srcGenericTypeSourceInfo, propertyMapping.getSourceInformation(), processorSupport)));
        }
        matcher.fullMatch(transform, state);
        ValueSpecification expressionSequence = transform._expressionSequence().getFirst();
        if (expressionSequence != null) {
            PropertyMappingValueSpecificationContext usageContext = (PropertyMappingValueSpecificationContext) processorSupport.newAnonymousCoreInstance(null, M2MappingPaths.PropertyMappingValueSpecificationContext);
            usageContext._offset(i);
            usageContext._propertyMapping(propertyMapping);
            expressionSequence._usageContext(usageContext);
        }
        i++;
        state.popVariableContext();
    }
}
Also used : Type(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type) FunctionType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.FunctionType) GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) FunctionType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.FunctionType) PropertyMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMapping) PurePropertyMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.modelToModel.PurePropertyMapping) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) VariableExpression(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression) GrammarInfoStub(org.finos.legend.pure.m3.coreinstance.meta.pure.tools.GrammarInfoStub) PurePropertyMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.modelToModel.PurePropertyMapping) SourceInformation(org.finos.legend.pure.m4.coreinstance.SourceInformation) PropertyMappingValueSpecificationContext(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingValueSpecificationContext)

Example 3 with PropertyMappingValueSpecificationContext

use of org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingValueSpecificationContext in project legend-pure by finos.

the class XStoreProcessor method process.

@Override
public void process(XStoreAssociationImplementation instance, ProcessorState state, Matcher matcher, ModelRepository repository, Context context, ProcessorSupport processorSupport) {
    Association association = (Association) ImportStub.withImportStubByPass(instance._associationCoreInstance(), processorSupport);
    Mapping mapping = (Mapping) ImportStub.withImportStubByPass(instance._parentCoreInstance(), processorSupport);
    MapIterable<String, SetImplementation> setImpl = org.finos.legend.pure.m2.dsl.mapping.Mapping.getClassMappingsByIdIncludeEmbedded(mapping, processorSupport);
    int i = 0;
    for (XStorePropertyMapping propertyMapping : (RichIterable<XStorePropertyMapping>) instance._propertyMappings()) {
        PropertyMappingProcessor.processPropertyMapping(propertyMapping, repository, processorSupport, association, instance);
        state.pushVariableContext();
        InstanceSetImplementation sourceSetImpl = (InstanceSetImplementation) MappingValidator.validateId(instance, propertyMapping, setImpl, propertyMapping._sourceSetImplementationId(), "source", processorSupport);
        InstanceSetImplementation targetSetImpl = (InstanceSetImplementation) MappingValidator.validateId(instance, propertyMapping, setImpl, propertyMapping._targetSetImplementationId(), "target", processorSupport);
        Class srcClass = getSetImplementationClass(sourceSetImpl, processorSupport);
        Class targetClass = getSetImplementationClass(targetSetImpl, processorSupport);
        VariableExpression thisParam = this.buildParam("this", srcClass, repository, processorSupport);
        VariableExpression thatParam = this.buildParam("that", targetClass, repository, processorSupport);
        FunctionType fType = (FunctionType) ImportStub.withImportStubByPass(propertyMapping._crossExpression()._classifierGenericType()._typeArguments().collect(new Function<GenericType, CoreInstance>() {

            @Override
            public CoreInstance valueOf(GenericType genericType) {
                return genericType._rawTypeCoreInstance();
            }
        }).toList().get(0), processorSupport);
        fType._parameters(Lists.immutable.withAll((ImmutableList<VariableExpression>) fType._parameters()).newWithAll(Lists.immutable.with(thisParam)));
        fType._parameters(Lists.immutable.withAll((ImmutableList<VariableExpression>) fType._parameters()).newWithAll(Lists.immutable.with(thatParam)));
        matcher.fullMatch(propertyMapping._crossExpression(), state);
        ValueSpecification expressionSequence = propertyMapping._crossExpression()._expressionSequence().toList().getFirst();
        if (expressionSequence != null) {
            PropertyMappingValueSpecificationContext usageContext = (PropertyMappingValueSpecificationContext) processorSupport.newAnonymousCoreInstance(null, M2MappingPaths.PropertyMappingValueSpecificationContext);
            usageContext._offset(i);
            usageContext._propertyMapping(propertyMapping);
            expressionSequence._usageContext(usageContext);
        }
        i++;
        state.popVariableContext();
    }
}
Also used : GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) XStorePropertyMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.xStore.XStorePropertyMapping) FunctionType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.FunctionType) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) Mapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping) XStorePropertyMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.xStore.XStorePropertyMapping) VariableExpression(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression) RichIterable(org.eclipse.collections.api.RichIterable) Association(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Association) InstanceSetImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.InstanceSetImplementation) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) MappingClass(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.MappingClass) Class(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class) InstanceSetImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.InstanceSetImplementation) SetImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.SetImplementation) PropertyMappingValueSpecificationContext(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingValueSpecificationContext)

Aggregations

PropertyMapping (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMapping)2 PropertyMappingValueSpecificationContext (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingValueSpecificationContext)2 FunctionType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.FunctionType)2 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)2 ValueSpecification (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification)2 VariableExpression (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression)2 RichIterable (org.eclipse.collections.api.RichIterable)1 InstanceSetImplementation (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.InstanceSetImplementation)1 Mapping (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping)1 MappingClass (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.MappingClass)1 SetImplementation (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.SetImplementation)1 PurePropertyMapping (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.modelToModel.PurePropertyMapping)1 XStorePropertyMapping (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.xStore.XStorePropertyMapping)1 Association (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Association)1 Class (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class)1 Type (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type)1 GrammarInfoStub (org.finos.legend.pure.m3.coreinstance.meta.pure.tools.GrammarInfoStub)1 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)1 SourceInformation (org.finos.legend.pure.m4.coreinstance.SourceInformation)1