Search in sources :

Example 1 with MilestoningDates

use of org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningDates in project legend-pure by finos.

the class MilestoningDatesPropagationFunctions method getMilestonedDates.

public static MilestoningDates getMilestonedDates(FunctionExpression milestonedQualifiedProperty, ProcessorSupport processorSupport) {
    CoreInstance func = milestonedQualifiedProperty._funcCoreInstance();
    CoreInstance propertyReturnType = (func instanceof AbstractProperty) ? ImportStub.withImportStubByPass(((AbstractProperty<?>) func)._genericType()._rawTypeCoreInstance(), processorSupport) : null;
    MilestoningStereotype milestoningStereotype = MilestoningFunctions.getTemporalStereoTypesFromTopMostNonTopTypeGeneralizations(propertyReturnType, processorSupport).getFirst();
    return new MilestoningDates(milestoningStereotype, ListHelper.tail(milestonedQualifiedProperty._parametersValues()).toList());
}
Also used : CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) AbstractProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty)

Example 2 with MilestoningDates

use of org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningDates in project legend-pure by finos.

the class PathProcessor method process.

@Override
public void process(Path instance, ProcessorState state, Matcher matcher, ModelRepository repository, Context context, ProcessorSupport processorSupport) {
    CoreInstance _class = ImportStub.withImportStubByPass(instance._start()._rawTypeCoreInstance(), processorSupport);
    CoreInstance source = _class;
    boolean possiblyZero = false;
    boolean toMany = false;
    MilestoningDates propagatedDates = state.getMilestoningDates(MilestoningDatesPropagationFunctions.PATH_MILESTONING_DATES_VARIABLE_NAME);
    for (PathElement pathElement : (RichIterable<PathElement>) instance._path()) {
        PostProcessor.processElement(matcher, _class, state, processorSupport);
        if (pathElement instanceof PropertyPathElement) {
            PropertyStub propertyStubNonResolved = (PropertyStub) ((PropertyPathElement) pathElement)._propertyCoreInstance();
            propertyStubNonResolved._ownerCoreInstance(_class);
            AbstractProperty property = (AbstractProperty) ImportStub.withImportStubByPass(((PropertyPathElement) pathElement)._propertyCoreInstance(), processorSupport);
            FunctionType functionType = (FunctionType) processorSupport.function_getFunctionType(property);
            _class = ImportStub.withImportStubByPass(functionType._returnType()._rawTypeCoreInstance(), processorSupport);
            toMany = toMany || !org.finos.legend.pure.m3.navigation.multiplicity.Multiplicity.isToOne(functionType._returnMultiplicity(), false);
            possiblyZero = possiblyZero || org.finos.legend.pure.m3.navigation.multiplicity.Multiplicity.isLowerZero(functionType._returnMultiplicity());
            for (ValueSpecification vs : ((PropertyPathElement) pathElement)._parameters()) {
                if (vs instanceof InstanceValue) {
                    InstanceValueProcessor.updateInstanceValue(vs, processorSupport);
                }
            }
            propagatedDates = processMilestoningQualifiedProperty(_class, state, propagatedDates, (PropertyPathElement) pathElement, propertyStubNonResolved, property, repository, processorSupport);
        }
    }
    GenericType classifierGenericType = (GenericType) processorSupport.newEphemeralAnonymousCoreInstance(M3Paths.GenericType);
    classifierGenericType._rawTypeCoreInstance(instance.getClassifier());
    classifierGenericType._typeArgumentsAdd((GenericType) Type.wrapGenericType(source, processorSupport));
    classifierGenericType._typeArgumentsAdd((GenericType) Type.wrapGenericType(_class, processorSupport));
    CoreInstance multiplicity = null;
    if (possiblyZero && !toMany) {
        multiplicity = processorSupport.package_getByUserPath(M3Paths.ZeroOne);
    }
    if (possiblyZero && toMany) {
        multiplicity = processorSupport.package_getByUserPath(M3Paths.ZeroMany);
    }
    if (!possiblyZero && toMany) {
        multiplicity = processorSupport.package_getByUserPath(M3Paths.OneMany);
    }
    if (!possiblyZero && !toMany) {
        multiplicity = processorSupport.package_getByUserPath(M3Paths.PureOne);
    }
    classifierGenericType._multiplicityArgumentsAdd((Multiplicity) multiplicity);
    instance._classifierGenericType(classifierGenericType);
}
Also used : RichIterable(org.eclipse.collections.api.RichIterable) PropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub) GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) PathElement(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.path.PathElement) PropertyPathElement(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.path.PropertyPathElement) FunctionType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.FunctionType) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) AbstractProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty) InstanceValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue) PropertyPathElement(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.path.PropertyPathElement) MilestoningDates(org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningDates)

Example 3 with MilestoningDates

use of org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningDates in project legend-pure by finos.

the class PathProcessor method processMilestoningQualifiedProperty.

private MilestoningDates processMilestoningQualifiedProperty(CoreInstance _class, ProcessorState state, MilestoningDates propagatedDates, PropertyPathElement pathElement, PropertyStub propertyStubNonResolved, AbstractProperty property, ModelRepository repository, ProcessorSupport processorSupport) {
    if (MilestoningFunctions.isGeneratedQualifiedProperty(property, processorSupport)) {
        MilestoningStereotype milestoningStereotype = MilestoningFunctions.getTemporalStereoTypesFromTopMostNonTopTypeGeneralizations(_class, processorSupport).getFirst();
        CoreInstance milestonedPropertyWithArg = MilestoningDatesPropagationFunctions.getMatchingMilestoningQualifiedPropertyWithDateArg(property, property._functionName(), processorSupport);
        propertyStubNonResolved._resolvedPropertyCoreInstance(milestonedPropertyWithArg);
        if (milestoningStereotype == MilestoningStereotypeEnum.businesstemporal) {
            if (pathElement._parameters().isEmpty()) {
                if (propagatedDates != null) {
                    pathElement._parameters(Lists.fixedSize.of((ValueSpecification) propagatedDates.getBusinessDate()));
                } else {
                    throwMilestoningPropertyPathValidationException(property, pathElement.getSourceInformation(), processorSupport);
                }
            } else {
                ValueSpecification businessDate = pathElement._parameters().getFirst();
                propagatedDates = new MilestoningDates(businessDate, null);
            }
        }
    } else {
        propagatedDates = null;
    }
    return propagatedDates;
}
Also used : MilestoningStereotype(org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningStereotype) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) MilestoningDates(org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningDates)

Aggregations

CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)3 MilestoningDates (org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningDates)2 AbstractProperty (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty)2 ValueSpecification (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification)2 RichIterable (org.eclipse.collections.api.RichIterable)1 MilestoningStereotype (org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningStereotype)1 PropertyStub (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub)1 PathElement (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.path.PathElement)1 PropertyPathElement (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.path.PropertyPathElement)1 FunctionType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.FunctionType)1 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)1 InstanceValue (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue)1