Search in sources :

Example 1 with Property

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property in project legend-pure by finos.

the class AssociationProcessor method updateClassifierGenericTypeForQualifiedPropertiesThisVarExprParams.

private static void updateClassifierGenericTypeForQualifiedPropertiesThisVarExprParams(Association association, QualifiedProperty qualifiedProperty, final Class qualifiedPropertyReturnType, ListIterable<? extends Property> assnProperties, final Context context, final ProcessorSupport processorSupport) {
    validateQualifiedPropertyLeftSideOfFilterByPropertyName(association, qualifiedProperty, qualifiedPropertyReturnType, assnProperties, context, processorSupport);
    Property leftSideOfFilterProperty = getQualifiedPropertiesFilterLeftSideParam(qualifiedPropertyReturnType, assnProperties, processorSupport);
    Property leftSideOfFilterOtherProperty = assnProperties.detect(Predicates.notEqual(leftSideOfFilterProperty));
    GenericType leftSideOfFilterOtherPropertyGenericType = leftSideOfFilterOtherProperty._genericType();
    FunctionType functionType = (FunctionType) qualifiedProperty._classifierGenericType()._typeArguments().toList().getFirst()._rawTypeCoreInstance();
    Iterable<? extends VariableExpression> functionTypeParams = functionType._parameters();
    for (VariableExpression functionTypeParam : functionTypeParams) {
        if (functionTypeParam != null && "this".equals(functionTypeParam._name())) {
            GenericType genericTypeCopy = (GenericType) org.finos.legend.pure.m3.navigation.generictype.GenericType.copyGenericType(leftSideOfFilterOtherPropertyGenericType, processorSupport);
            functionTypeParam._genericType(genericTypeCopy);
            context.update(functionTypeParam);
            if (functionTypeParam.hasBeenValidated()) {
                functionTypeParam.markNotValidated();
                context.update(functionTypeParam);
            }
        }
    }
}
Also used : 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) VariableExpression(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression) AbstractProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty) QualifiedProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty) Property(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property)

Example 2 with Property

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property in project legend-pure by finos.

the class AssociationProcessor method processAssociationQualifiedProperty_internal.

private static void processAssociationQualifiedProperty_internal(Association association, QualifiedProperty qualifiedProperty, Class sourceRawType, Context context, ProcessorSupport processorSupport) {
    addQualifiedPropertyToRawType(qualifiedProperty, sourceRawType, context);
    Class qualifiedPropertyReturnType = (Class) ImportStub.withImportStubByPass(qualifiedProperty._genericType()._rawTypeCoreInstance(), processorSupport);
    ListIterable<? extends Property<?, ?>> assnProperties = association._properties().toList();
    updateClassifierGenericTypeForQualifiedPropertiesThisVarExprParams(association, qualifiedProperty, qualifiedPropertyReturnType, assnProperties, context, processorSupport);
    context.update(qualifiedProperty);
}
Also used : Class(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class)

Example 3 with Property

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property in project legend-pure by finos.

the class AssociationProcessor method processNonMilestonedQualifiedProperties.

private static void processNonMilestonedQualifiedProperties(Association association, Class leftRawType, Class rightRawType, Context context, ProcessorSupport processorSupport) {
    RichIterable<? extends QualifiedProperty> qualifiedProperties = association._qualifiedProperties();
    if (qualifiedProperties.notEmpty()) {
        SetIterable<? extends Class> validReturnTypes = Sets.immutable.with(leftRawType, rightRawType);
        ListIterable<? extends Property<?, ?>> assnProperties = association._properties().toList();
        for (QualifiedProperty qualifiedProperty : qualifiedProperties) {
            Class qualifiedPropertyReturnType = (Class) ImportStub.withImportStubByPass(qualifiedProperty._genericType()._rawTypeCoreInstance(), processorSupport);
            validateQualifiedPropertyReturnType(association, qualifiedProperty, qualifiedPropertyReturnType, validReturnTypes);
            Class sourceType = (leftRawType == qualifiedPropertyReturnType) ? rightRawType : leftRawType;
            addQualifiedPropertyToRawType(qualifiedProperty, sourceType, context);
            updateClassifierGenericTypeForQualifiedPropertiesThisVarExprParams(association, qualifiedProperty, qualifiedPropertyReturnType, assnProperties, context, processorSupport);
            context.update(qualifiedProperty);
        }
    }
}
Also used : Class(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class) QualifiedProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty)

Example 4 with Property

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property in project legend-pure by finos.

the class AssociationProcessor method process.

@Override
public void process(Association association, ProcessorState state, Matcher matcher, ModelRepository repository, Context context, ProcessorSupport processorSupport) {
    RichIterable<? extends AbstractProperty> properties = association._properties();
    RichIterable<? extends AbstractProperty> originalMilestonedProperties = association._originalMilestonedProperties();
    RichIterable<? extends AbstractProperty> qualifiedProperties = association._qualifiedProperties();
    for (AbstractProperty property : LazyIterate.concatenate((Iterable<AbstractProperty>) properties, (Iterable<AbstractProperty>) qualifiedProperties).concatenate((Iterable<AbstractProperty>) originalMilestonedProperties)) {
        PostProcessor.processElement(matcher, property, state, processorSupport);
    }
}
Also used : SetIterable(org.eclipse.collections.api.set.SetIterable) RichIterable(org.eclipse.collections.api.RichIterable) ListIterable(org.eclipse.collections.api.list.ListIterable) AbstractProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty)

Example 5 with Property

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property in project legend-pure by finos.

the class AssociationProcessor method processAssociationProperty.

private static ListIterable<AbstractProperty<?>> processAssociationProperty(Association association, Property property, GenericType sourceGenericType, Class sourceRawType, ModelRepository modelRepository, Context context, ProcessorSupport processorSupport) {
    GeneratedMilestonedProperties generatedMilestonedProperties = MilestoningPropertyProcessor.processAssociationProperty(association, sourceRawType, property, context, processorSupport, modelRepository);
    if (generatedMilestonedProperties.hasGeneratedProperties()) {
        processOriginalMilestonedProperty(association, property, sourceGenericType, context, processorSupport);
        Property edgePointProperty = (Property) generatedMilestonedProperties.getEdgePointProperty();
        processAssociationProperty_internal(edgePointProperty, sourceGenericType, sourceRawType, context);
        for (CoreInstance qualifiedProperty : generatedMilestonedProperties.getQualifiedProperties()) {
            processAssociationQualifiedProperty_internal(association, (QualifiedProperty) qualifiedProperty, sourceRawType, context, processorSupport);
        }
        if (association.hasBeenValidated()) {
            association.markNotValidated();
        }
        return generatedMilestonedProperties.getAllGeneratedProperties();
    } else {
        processAssociationProperty_internal(property, sourceGenericType, sourceRawType, context);
        return Lists.immutable.empty();
    }
}
Also used : CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) GeneratedMilestonedProperties(org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.GeneratedMilestonedProperties) AbstractProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty) QualifiedProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty) Property(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property)

Aggregations

CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)95 Property (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property)49 Test (org.junit.Test)48 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)46 RichIterable (org.eclipse.collections.api.RichIterable)42 PureCompilationException (org.finos.legend.pure.m4.exception.PureCompilationException)41 PureExecutionException (org.finos.legend.pure.m3.exception.PureExecutionException)35 AbstractProperty (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty)34 QualifiedProperty (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty)34 Type (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type)34 Class (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class)29 FunctionType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.FunctionType)26 ValueSpecification (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification)25 ProcessorSupport (org.finos.legend.pure.m3.navigation.ProcessorSupport)25 MutableList (org.eclipse.collections.api.list.MutableList)24 InstanceValue (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue)24 VariableExpression (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression)24 ListIterable (org.eclipse.collections.api.list.ListIterable)23 LambdaFunction (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.LambdaFunction)20 SourceInformation (org.finos.legend.pure.m4.coreinstance.SourceInformation)18