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