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