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