Search in sources :

Example 1 with MilestoningStereotypeEnum

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

the class GetAllValidator method validate.

public static void validate(FunctionExpression instance, ProcessorSupport processorSupport) throws PureCompilationException {
    if (canDetermineGenericType(instance, processorSupport)) {
        Type sourceRawType = (Type) ImportStub.withImportStubByPass(instance._genericType()._rawTypeCoreInstance(), processorSupport);
        ListIterable<String> temporalPropertyNames = MilestoningFunctions.getTemporalStereoTypePropertyNamesFromTopMostNonTopTypeGeneralizations(sourceRawType, processorSupport);
        ListIterable<MilestoningStereotypeEnum> temporalStereotypes = MilestoningFunctions.getTemporalStereoTypesFromTopMostNonTopTypeGeneralizations(sourceRawType, processorSupport);
        ListIterable<? extends ValueSpecification> params = instance._parametersValues().toList().drop(1);
        validateParameterCount(instance, params, sourceRawType, temporalPropertyNames, temporalStereotypes, processorSupport);
    }
}
Also used : Type(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type) MilestoningStereotypeEnum(org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningStereotypeEnum)

Example 2 with MilestoningStereotypeEnum

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

the class GetAllVersionsInRangeValidator method validate.

public static void validate(FunctionExpression instance, ProcessorSupport processorSupport) throws PureCompilationException {
    if (canDetermineGenericType(instance, processorSupport)) {
        Type sourceRawType = (Type) ImportStub.withImportStubByPass(instance._genericType()._rawTypeCoreInstance(), processorSupport);
        ListIterable<MilestoningStereotypeEnum> temporalStereotypes = MilestoningFunctions.getTemporalStereoTypesFromTopMostNonTopTypeGeneralizations(sourceRawType, processorSupport);
        ListIterable<? extends ValueSpecification> params = instance._parametersValues().toList().drop(1);
        validateAllVersionsInRangeUsage(instance, temporalStereotypes);
        validateLatestDateUsage(instance, params, processorSupport);
    }
}
Also used : Type(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type) MilestoningStereotypeEnum(org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningStereotypeEnum)

Example 3 with MilestoningStereotypeEnum

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

the class MilestoningClassValidator method validateTemporalStereotypesAppliedForAllSubTypesInTemporalHierarchy.

static void validateTemporalStereotypesAppliedForAllSubTypesInTemporalHierarchy(Class<?> cls, ProcessorSupport processorSupport) {
    if (!Type.directSubTypeOf(cls, processorSupport.type_TopType(), processorSupport)) {
        ListIterable<MilestoningStereotypeEnum> topMostTypeMilestoningStereotypes = MilestoningFunctions.getTemporalStereoTypesFromTopMostNonTopTypeGeneralizations(cls, processorSupport);
        MilestoningStereotype subTypeMilestoningStereotype = MilestoningFunctions.getTemporalStereoTypesExcludingParents(cls).getFirst();
        boolean subTypeIsTemporal = subTypeMilestoningStereotype != null;
        if (topMostTypeMilestoningStereotypes.notEmpty()) {
            MilestoningStereotypeEnum topMostTypeMilestoningStereotype = topMostTypeMilestoningStereotypes.getFirst();
            boolean topMostTypeIsTemporal = topMostTypeMilestoningStereotype != null;
            if (topMostTypeIsTemporal && !subTypeIsTemporal) {
                MutableSet<CoreInstance> topNonAnyTypes = Type.getTopMostNonTopTypeGeneralizations(cls, processorSupport);
                StringBuilder builder = new StringBuilder("Temporal stereotypes must be applied at all levels in a temporal class hierarchy, top most supertype");
                if (topNonAnyTypes.size() != 1) {
                    builder.append('s');
                }
                topNonAnyTypes.collect(PackageableElement::getUserPathForPackageableElement, Lists.mutable.ofInitialCapacity(topNonAnyTypes.size())).sortThis().appendString(builder, " ", ", ", " ");
                builder.append((topNonAnyTypes.size() == 1) ? "has" : "have");
                builder.append(" milestoning stereotype: '").append(topMostTypeMilestoningStereotype).append("'");
                throw new PureCompilationException(cls.getSourceInformation(), builder.toString());
            }
            if (topMostTypeIsTemporal && subTypeIsTemporal && (topMostTypeMilestoningStereotype != subTypeMilestoningStereotype)) {
                MutableSet<CoreInstance> topNonAnyTypes = Type.getTopMostNonTopTypeGeneralizations(cls, processorSupport);
                StringBuilder builder = PackageableElement.writeUserPathForPackageableElement(new StringBuilder("All temporal stereotypes in a hierarchy must be the same, class "), cls);
                builder.append(" is ").append(subTypeMilestoningStereotype).append(", top most supertype");
                if (topNonAnyTypes.size() != 1) {
                    builder.append('s');
                }
                topNonAnyTypes.collect(PackageableElement::getUserPathForPackageableElement, Lists.mutable.ofInitialCapacity(topNonAnyTypes.size())).sortThis().appendString(builder, " ", ", ", " ");
                builder.append((topNonAnyTypes.size() == 1) ? "has" : "have");
                builder.append(" milestoning stereotype: '").append(topMostTypeMilestoningStereotype).append("'");
                throw new PureCompilationException(cls.getSourceInformation(), builder.toString());
            }
        } else if (subTypeIsTemporal) {
            MutableSet<CoreInstance> topNonAnyTypes = Type.getTopMostNonTopTypeGeneralizations(cls, processorSupport);
            StringBuilder builder = PackageableElement.writeUserPathForPackageableElement(new StringBuilder("All temporal stereotypes in a hierarchy must be the same, class "), cls);
            builder.append(" is ").append(subTypeMilestoningStereotype).append(", top most supertype");
            if (topNonAnyTypes.size() != 1) {
                builder.append('s');
            }
            topNonAnyTypes.collect(PackageableElement::getUserPathForPackageableElement, Lists.mutable.ofInitialCapacity(topNonAnyTypes.size())).sortThis().appendString(builder, " ", ", ", " ");
            builder.append((topNonAnyTypes.size() == 1) ? "is" : "are").append(" not temporal");
            throw new PureCompilationException(cls.getSourceInformation(), builder.toString());
        }
    }
}
Also used : MutableSet(org.eclipse.collections.api.set.MutableSet) PackageableElement(org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement) MilestoningStereotype(org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningStereotype) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) MilestoningStereotypeEnum(org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningStereotypeEnum) PureCompilationException(org.finos.legend.pure.m4.exception.PureCompilationException)

Example 4 with MilestoningStereotypeEnum

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

the class GetAllVersionsValidator method validate.

public static void validate(FunctionExpression instance, ProcessorSupport processorSupport) throws PureCompilationException {
    if (canDetermineGenericType(instance, processorSupport)) {
        Type sourceRawType = (Type) ImportStub.withImportStubByPass(instance._genericType()._rawTypeCoreInstance(), processorSupport);
        ListIterable<MilestoningStereotypeEnum> temporalStereotypes = MilestoningFunctions.getTemporalStereoTypesFromTopMostNonTopTypeGeneralizations(sourceRawType, processorSupport);
        validateGenericTypeIsTemporal(instance, sourceRawType, temporalStereotypes);
    }
}
Also used : Type(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type) MilestoningStereotypeEnum(org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningStereotypeEnum)

Example 5 with MilestoningStereotypeEnum

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

the class MilestoningPropertyProcessor method getSynthesizedMilestonedProperties.

public static ListIterable<GeneratedMilestonedProperties> getSynthesizedMilestonedProperties(PropertyOwner propertyOwner, CoreInstance propertySourceType, Iterable<? extends Property<?, ?>> properties, ModelRepository modelRepository, Context context, ProcessorSupport processorSupport) throws PureCompilationException {
    MutableList<GeneratedMilestonedProperties> synthesizedMilestonedProperties = Lists.mutable.empty();
    ListIterable<MilestoningStereotypeEnum> ownerMilestoneStereotypes = MilestoningFunctions.getTemporalStereoTypesFromTopMostNonTopTypeGeneralizations(propertySourceType, processorSupport);
    properties.forEach(property -> {
        CoreInstance returnType = ImportStub.withImportStubByPass(property._genericType()._rawTypeCoreInstance(), processorSupport);
        if (returnType != null) {
            ListIterable<MilestoningStereotypeEnum> returnTypeMilestoneStereotypes = MilestoningFunctions.getTemporalStereoTypesFromTopMostNonTopTypeGeneralizations(returnType, processorSupport);
            if (returnTypeMilestoneStereotypes.notEmpty()) {
                GeneratedMilestonedProperties generatedMilestonedProperties = new GeneratedMilestonedProperties(property);
                String returnTypeIdOrPath = PackageableElement.getUserPathForPackageableElement(returnType);
                org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.multiplicity.Multiplicity multiplicity = property._multiplicity();
                returnTypeMilestoneStereotypes.forEach(milestoneStereotype -> {
                    ListIterable<AbstractProperty<?>> qualifiedProperties = getQualifiedProperties(property, propertyOwner, multiplicity, returnTypeIdOrPath, milestoneStereotype, ownerMilestoneStereotypes, context, processorSupport, modelRepository);
                    generatedMilestonedProperties.addQualifiedProperties(qualifiedProperties);
                });
                generatedMilestonedProperties.setEdgePointProperty(getEdgePointProperty(property, propertyOwner, multiplicity, returnTypeIdOrPath, modelRepository, context, processorSupport));
                synthesizedMilestonedProperties.add(generatedMilestonedProperties);
            }
        }
    });
    return synthesizedMilestonedProperties;
}
Also used : AbstractProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance)

Aggregations

MilestoningStereotypeEnum (org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningStereotypeEnum)4 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)4 AbstractProperty (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.AbstractProperty)3 Type (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type)3 MutableSet (org.eclipse.collections.api.set.MutableSet)1 PropertyOwnerStrategy (org.finos.legend.pure.m3.compiler.PropertyOwnerStrategy)1 MilestoningStereotype (org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningStereotype)1 PropertyOwner (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PropertyOwner)1 QualifiedProperty (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty)1 PackageableElement (org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement)1 PureCompilationException (org.finos.legend.pure.m4.exception.PureCompilationException)1