Search in sources :

Example 1 with Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl

use of org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl in project legend-engine by finos.

the class HelperMappingBuilder method processPurePropertyMappingTransform.

public static LambdaFunction processPurePropertyMappingTransform(PurePropertyMapping ppm, Lambda lambda, PropertyMappingsImplementation owner, org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type inputVarType, CompileContext context, String mappingName) {
    List<ValueSpecification> expressions = lambda.body;
    VariableExpression lambdaParam = new Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl("")._name("src")._multiplicity(context.pureModel.getMultiplicity("one"))._genericType(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(inputVarType));
    MutableList<VariableExpression> pureParameters = Lists.mutable.with(lambdaParam);
    ProcessingContext ctx = new ProcessingContext("Pure M2M Transform Lambda");
    ctx.addInferredVariables("src", lambdaParam);
    MutableList<String> openVariables = Lists.mutable.empty();
    MutableList<org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification> valueSpecifications = ListIterate.collect(expressions, p -> p.accept(new ValueSpecificationBuilder(context, openVariables, ctx)));
    MutableList<String> cleanedOpenVariables = openVariables.distinct();
    cleanedOpenVariables.removeAll(pureParameters.collect(e -> e._name()));
    GenericType functionType = context.pureModel.buildFunctionType(pureParameters, valueSpecifications.getLast()._genericType(), valueSpecifications.getLast()._multiplicity());
    String propertyName = owner._id() + "." + ppm.property.property;
    String mappingPath = Root_meta_pure_functions_meta_elementToPath_PackageableElement_1__String_1_(owner._parent(), context.pureModel.getExecutionSupport()).replace("::", "_");
    ctx.flushVariable("src");
    return new Root_meta_pure_metamodel_function_LambdaFunction_Impl(propertyName, new SourceInformation(mappingPath, 0, 0, 0, 0), null)._classifierGenericType(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::metamodel::function::LambdaFunction"))._typeArguments(FastList.newListWith(functionType)))._openVariables(cleanedOpenVariables)._expressionSequence(valueSpecifications);
}
Also used : AggregationFunctionSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.aggregationAware.AggregationFunctionSpecification) EngineErrorType(org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType) PurePropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.modelToModel.mapping.PurePropertyMapping) XStoreAssociationImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.xStore.XStoreAssociationImplementation) SetIterable(org.eclipse.collections.api.set.SetIterable) Generalization(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization) MutableList(org.eclipse.collections.api.list.MutableList) MutableSet(org.eclipse.collections.api.set.MutableSet) Handlers(org.finos.legend.engine.language.pure.compiler.toPureGraph.handlers.Handlers) PropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyMapping) RichIterable(org.eclipse.collections.api.RichIterable) Variable(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.Variable) Property(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property) Store(org.finos.legend.pure.m3.coreinstance.meta.pure.store.Store) EnumValueMappingEnumSourceValue(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.EnumValueMappingEnumSourceValue) Root_meta_pure_metamodel_function_LambdaFunction_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_function_LambdaFunction_Impl) Map(java.util.Map) InstanceSetImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.InstanceSetImplementation) Multiplicity(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Multiplicity) AssociationImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.AssociationImplementation) EnumerationMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.EnumerationMapping) MappingClass(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.MappingClass) GroupByFunctionSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.aggregationAware.GroupByFunctionSpecification) Root_meta_pure_mapping_SubstituteStore_Impl(org.finos.legend.pure.generated.Root_meta_pure_mapping_SubstituteStore_Impl) MappingTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.mappingTest.MappingTest) Root_meta_pure_metamodel_function_property_Property_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_function_property_Property_Impl) LocalMappingPropertyInfo(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.LocalMappingPropertyInfo) Class(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class) Root_meta_pure_mapping_xStore_XStoreAssociationImplementation_Impl(org.finos.legend.pure.generated.Root_meta_pure_mapping_xStore_XStoreAssociationImplementation_Impl) Collectors(java.util.stream.Collectors) Root_meta_pure_mapping_MappingClass_Impl(org.finos.legend.pure.generated.Root_meta_pure_mapping_MappingClass_Impl) Objects(java.util.Objects) Root_meta_pure_mapping_aggregationAware_AggregationFunctionSpecification_Impl(org.finos.legend.pure.generated.Root_meta_pure_mapping_aggregationAware_AggregationFunctionSpecification_Impl) List(java.util.List) ClassMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.ClassMapping) Mapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping) Procedure2(org.eclipse.collections.api.block.procedure.Procedure2) GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) Lists(org.eclipse.collections.impl.factory.Lists) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) Optional(java.util.Optional) InputData(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.mappingTest.InputData) EnumValueMappingStringSourceValue(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.EnumValueMappingStringSourceValue) VariableExpression(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression) Lambda(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.Lambda) PropertyMappingsImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation) AggregateSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.aggregationAware.AggregateSpecification) Root_meta_pure_mapping_EnumValueMapping_Impl(org.finos.legend.pure.generated.Root_meta_pure_mapping_EnumValueMapping_Impl) MappingInclude(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.MappingInclude) AssociationMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.AssociationMapping) XStoreAssociationMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.xStore.XStoreAssociationMapping) EnumValueMappingIntegerSourceValue(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.EnumValueMappingIntegerSourceValue) Root_meta_pure_functions_meta_elementToPath_PackageableElement_1__String_1_(org.finos.legend.pure.generated.platform_pure_corefunctions_meta.Root_meta_pure_functions_meta_elementToPath_PackageableElement_1__String_1_) FastList(org.eclipse.collections.impl.list.mutable.FastList) EnumValueMappingSourceValue(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.EnumValueMappingSourceValue) HelperModelBuilder.getElementFullPath(org.finos.legend.engine.language.pure.compiler.toPureGraph.HelperModelBuilder.getElementFullPath) ObjectInputData(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.modelToModel.mapping.ObjectInputData) Root_meta_pure_mapping_EnumerationMapping_Impl(org.finos.legend.pure.generated.Root_meta_pure_mapping_EnumerationMapping_Impl) AggregateFunction(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.aggregationAware.AggregateFunction) GroupByFunction(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.aggregationAware.GroupByFunction) Root_meta_pure_metamodel_relationship_Generalization_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Generalization_Impl) Root_meta_pure_mapping_MappingInclude_Impl(org.finos.legend.pure.generated.Root_meta_pure_mapping_MappingInclude_Impl) Root_meta_pure_metamodel_type_generics_GenericType_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl) PackageableElement(org.finos.legend.pure.m3.navigation.PackageableElement.PackageableElement) SourceInformation(org.finos.legend.pure.m4.coreinstance.SourceInformation) Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl) ValueSpecification(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.ValueSpecification) ListIterate(org.eclipse.collections.impl.utility.ListIterate) SetImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.SetImplementation) LambdaFunction(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.LambdaFunction) Root_meta_pure_mapping_aggregationAware_AggregateSpecification_Impl(org.finos.legend.pure.generated.Root_meta_pure_mapping_aggregationAware_AggregateSpecification_Impl) InstanceValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue) Root_meta_pure_mapping_aggregationAware_GroupByFunctionSpecification_Impl(org.finos.legend.pure.generated.Root_meta_pure_mapping_aggregationAware_GroupByFunctionSpecification_Impl) AggregateSetImplementationContainer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.aggregationAware.AggregateSetImplementationContainer) Sets(org.eclipse.collections.impl.factory.Sets) Root_meta_pure_mapping_aggregationAware_AggregateSetImplementationContainer_Impl(org.finos.legend.pure.generated.Root_meta_pure_mapping_aggregationAware_AggregateSetImplementationContainer_Impl) ImmutableSet(org.eclipse.collections.api.set.ImmutableSet) GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) Root_meta_pure_metamodel_function_LambdaFunction_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_function_LambdaFunction_Impl) ValueSpecification(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.ValueSpecification) VariableExpression(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression) SourceInformation(org.finos.legend.pure.m4.coreinstance.SourceInformation) Root_meta_pure_metamodel_type_generics_GenericType_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl) Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl)

Example 2 with Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl

use of org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl in project legend-engine by finos.

the class HelperModelBuilder method createVariableValueSpecification.

public static org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification createVariableValueSpecification(CompileContext context, String variableName) {
    org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification ve = new Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl("")._name(variableName);
    final GenericType genericType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("Number"));
    ve._genericType(genericType);
    Multiplicity multiplicity = new Multiplicity();
    multiplicity.lowerBound = 1;
    multiplicity.setUpperBound(1);
    ve._multiplicity(context.pureModel.getMultiplicity(multiplicity));
    return ve;
}
Also used : GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) Root_meta_pure_metamodel_type_generics_GenericType_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl) Multiplicity(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Multiplicity) Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification)

Example 3 with Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl

use of org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl in project legend-engine by finos.

the class Milestoning method generateMilestoningRangeQualifiedProperty.

private static MutableList<QualifiedProperty<?>> generateMilestoningRangeQualifiedProperty(CompileContext context, Class<?> sourceClass, PropertyOwner propertyOwner, Property originalProperty, MilestoningStereotype returnTypeMilestoningStereotype, MutableList<Stereotype> stereotypes, Property edgePointProperty) {
    MutableList<QualifiedProperty<?>> generatedMilestoningRangeQualifiedProperty = Lists.mutable.empty();
    if (UNI_TEMPORAL_STEREOTYPE_NAMES.contains(returnTypeMilestoningStereotype.getPurePlatformStereotypeName())) {
        String qualifiedPropertyName = MilestoningFunctions.getRangePropertyName(originalProperty._name());
        String temporalDatePropertyName = returnTypeMilestoningStereotype.getTemporalDatePropertyNames().getFirst();
        VariableExpression thisVar = new Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl("")._name("this")._multiplicity(context.pureModel.getMultiplicity("one"))._genericType(sourceClass._classifierGenericType()._typeArguments().getFirst());
        VariableExpression v_milestoning = new Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl("")._name("v_milestoning")._multiplicity(context.pureModel.getMultiplicity("one"))._genericType(edgePointProperty._genericType());
        VariableExpression inputStartDate = new Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl("")._name("start")._multiplicity(context.pureModel.getMultiplicity("one"))._genericType(context.pureModel.getGenericType("Date"));
        VariableExpression inputEndDate = new Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl("")._name("end")._multiplicity(context.pureModel.getMultiplicity("one"))._genericType(context.pureModel.getGenericType("Date"));
        SimpleFunctionExpression temporalDatePropertyExp = new Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl("")._func(HelperModelBuilder.getOwnedProperty((Class<Object>) originalProperty._genericType()._rawType(), temporalDatePropertyName, context.pureModel.getExecutionSupport()))._propertyName(new Root_meta_pure_metamodel_valuespecification_InstanceValue_Impl("")._values(Lists.mutable.of(temporalDatePropertyName)))._genericType(context.pureModel.getGenericType("Date"))._multiplicity(context.pureModel.getMultiplicity("one"))._parametersValues(Lists.mutable.of(v_milestoning));
        SimpleFunctionExpression equalExpression = new Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl("")._func(context.pureModel.getFunction("meta::pure::functions::boolean::eq_Any_1__Any_1__Boolean_1_", true))._functionName("eq")._genericType(context.pureModel.getGenericType("Boolean"))._multiplicity(context.pureModel.getMultiplicity("one"))._parametersValues(Lists.mutable.of(temporalDatePropertyExp, inputStartDate));
        LambdaFunction filterLambda = new Root_meta_pure_metamodel_function_LambdaFunction_Impl("")._classifierGenericType(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::metamodel::function::LambdaFunction"))._typeArguments(Lists.mutable.of(PureModel.buildFunctionType(Lists.mutable.of(v_milestoning), context.pureModel.getGenericType("Boolean"), context.pureModel.getMultiplicity("one")))))._openVariables(Lists.mutable.of(temporalDatePropertyName))._expressionSequence(Lists.mutable.of(equalExpression));
        InstanceValue filterInstanceValue = new Root_meta_pure_metamodel_valuespecification_InstanceValue_Impl("")._genericType(filterLambda._classifierGenericType())._multiplicity(context.pureModel.getMultiplicity("one"))._values(Lists.mutable.of(filterLambda));
        SimpleFunctionExpression filterLhs = new Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl("")._func(edgePointProperty)._propertyName(new Root_meta_pure_metamodel_valuespecification_InstanceValue_Impl("")._values(Lists.mutable.of(edgePointProperty._name())))._genericType(edgePointProperty._genericType())._multiplicity(edgePointProperty._multiplicity())._parametersValues(Lists.mutable.of(thisVar));
        SimpleFunctionExpression filterExpression = new Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl("")._func(context.pureModel.getFunction("meta::pure::functions::collection::filter_T_MANY__Function_1__T_MANY_", true))._functionName("filter")._genericType(originalProperty._genericType())._multiplicity(context.pureModel.getMultiplicity("zeromany"))._parametersValues(Lists.mutable.of(filterLhs, filterInstanceValue));
        QualifiedProperty<?> milestoningRangeQualifiedProperty = getQualifiedProperty(propertyOwner, originalProperty, qualifiedPropertyName, originalProperty._multiplicity(), stereotypes)._classifierGenericType(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::metamodel::function::property::QualifiedProperty"))._typeArguments(Lists.mutable.of(PureModel.buildFunctionType(Lists.mutable.of(thisVar, inputStartDate, inputEndDate), originalProperty._genericType(), originalProperty._multiplicity()))))._expressionSequence(Lists.mutable.of(filterExpression));
        generatedMilestoningRangeQualifiedProperty.add(milestoningRangeQualifiedProperty);
    }
    return generatedMilestoningRangeQualifiedProperty;
}
Also used : Root_meta_pure_metamodel_function_LambdaFunction_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_function_LambdaFunction_Impl) Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl) VariableExpression(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression) LambdaFunction(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.LambdaFunction) Root_meta_pure_metamodel_valuespecification_InstanceValue_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_InstanceValue_Impl) InstanceValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue) SimpleFunctionExpression(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.SimpleFunctionExpression) Root_meta_pure_metamodel_type_generics_GenericType_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl) Class(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class) Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl) QualifiedProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty)

Example 4 with Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl

use of org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl in project legend-engine by finos.

the class Milestoning method newSingleDateMilestoningQualifiedPropertyWithArg.

private static MutableList<QualifiedProperty<?>> newSingleDateMilestoningQualifiedPropertyWithArg(CompileContext context, Class<?> sourceClass, PropertyOwner propertyOwner, Property originalProperty, MilestoningStereotype returnTypeMilestoningStereotype, MutableList<Stereotype> stereotypes, Property edgePointProperty) {
    String qualifiedPropertyName = originalProperty._name();
    org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty<?> qualifiedProperty = getQualifiedProperty(propertyOwner, originalProperty, qualifiedPropertyName, originalProperty._multiplicity(), stereotypes);
    VariableExpression thisVar = new Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl("")._name("this")._multiplicity(context.pureModel.getMultiplicity("one"))._genericType(sourceClass._classifierGenericType()._typeArguments().toList().get(0));
    VariableExpression v_milestoning = new Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl("")._name("v_milestoning")._multiplicity(context.pureModel.getMultiplicity("one"))._genericType(edgePointProperty._genericType());
    ListIterable<Pair<VariableExpression, SimpleFunctionExpression>> datesToCompare = returnTypeMilestoningStereotype.getTemporalDatePropertyNames().collect(d -> {
        VariableExpression inputTemporalDate = new Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl("")._name(d)._multiplicity(context.pureModel.getMultiplicity("one"))._genericType(context.pureModel.getGenericType("Date"));
        org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property<?, ?> temporalDateProperty = ((Class<Object>) originalProperty._genericType()._rawType())._properties().detect(p -> p._name().equals(d));
        SimpleFunctionExpression temporalDatePropertyExp = new Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl("")._func(temporalDateProperty)._propertyName(new Root_meta_pure_metamodel_valuespecification_InstanceValue_Impl("")._values(Lists.fixedSize.of(d)))._genericType(context.pureModel.getGenericType("Date"))._multiplicity(context.pureModel.getMultiplicity("one"))._parametersValues(Lists.fixedSize.of(v_milestoning));
        return Tuples.pair(inputTemporalDate, temporalDatePropertyExp);
    });
    ListIterable<SimpleFunctionExpression> equalExpressions = datesToCompare.collect(p -> new Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl("")._func(context.pureModel.getFunction("meta::pure::functions::boolean::eq_Any_1__Any_1__Boolean_1_", true))._functionName("eq")._genericType(context.pureModel.getGenericType("Boolean"))._multiplicity(context.pureModel.getMultiplicity("one"))._parametersValues(Lists.fixedSize.<ValueSpecification>of(p.getTwo(), p.getOne())));
    SimpleFunctionExpression equalExpression = equalExpressions.size() == 1 ? equalExpressions.get(0) : new Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl("")._func(context.pureModel.getFunction("meta::pure::functions::boolean::and_Boolean_1__Boolean_1__Boolean_1_", true))._functionName("and")._genericType(context.pureModel.getGenericType("Boolean"))._multiplicity(context.pureModel.getMultiplicity("one"))._parametersValues(equalExpressions);
    GenericType functionType = PureModel.buildFunctionType(Lists.fixedSize.of(v_milestoning), context.pureModel.getGenericType("Boolean"), context.pureModel.getMultiplicity("one"));
    LambdaFunction filterLambda = new Root_meta_pure_metamodel_function_LambdaFunction_Impl("")._classifierGenericType(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::metamodel::function::LambdaFunction"))._typeArguments(FastList.newListWith(functionType)))._openVariables(returnTypeMilestoningStereotype.getTemporalDatePropertyNames())._expressionSequence(Lists.fixedSize.of(equalExpression));
    InstanceValue filterInstanceValue = new Root_meta_pure_metamodel_valuespecification_InstanceValue_Impl("")._genericType(filterLambda._classifierGenericType())._multiplicity(context.pureModel.getMultiplicity("one"))._values(Lists.fixedSize.of(filterLambda));
    SimpleFunctionExpression filterLhs = new Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl("")._func(edgePointProperty)._propertyName(new Root_meta_pure_metamodel_valuespecification_InstanceValue_Impl("")._values(Lists.fixedSize.of(edgePointProperty._name())))._genericType(edgePointProperty._genericType())._multiplicity(edgePointProperty._multiplicity())._parametersValues(Lists.fixedSize.of(thisVar));
    SimpleFunctionExpression filterExpression = new Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl("")._func(context.pureModel.getFunction("meta::pure::functions::collection::filter_T_MANY__Function_1__T_MANY_", true))._functionName("filter")._genericType(qualifiedProperty._genericType())._multiplicity(context.pureModel.getMultiplicity("zeromany"))._parametersValues(Lists.fixedSize.of(filterLhs, filterInstanceValue));
    GenericType classifierGenericType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::metamodel::function::property::QualifiedProperty"))._typeArguments(Lists.fixedSize.of(PureModel.buildFunctionType(Lists.mutable.of(thisVar).withAll(datesToCompare.collect(Functions.firstOfPair())), qualifiedProperty._genericType(), originalProperty._multiplicity())));
    qualifiedProperty._classifierGenericType(classifierGenericType);
    qualifiedProperty._expressionSequence(Lists.fixedSize.of(filterExpression));
    return Lists.mutable.of(qualifiedProperty);
}
Also used : GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) Root_meta_pure_metamodel_function_LambdaFunction_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_function_LambdaFunction_Impl) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl) VariableExpression(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression) LambdaFunction(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.LambdaFunction) Root_meta_pure_metamodel_valuespecification_InstanceValue_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_InstanceValue_Impl) InstanceValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue) SimpleFunctionExpression(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.SimpleFunctionExpression) Root_meta_pure_metamodel_type_generics_GenericType_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl) Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl) Pair(org.eclipse.collections.api.tuple.Pair)

Example 5 with Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl

use of org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl in project legend-engine by finos.

the class ValueSpecificationBuilder method visit.

@Override
public ValueSpecification visit(AppliedFunction appliedFunction) {
    processingContext.push("Applying " + appliedFunction.function);
    if (appliedFunction.function.equals("letFunction")) {
        MutableList<org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification> vs = ListIterate.collect(appliedFunction.parameters, expression -> expression.accept(new ValueSpecificationBuilder(this.context, openVariables, processingContext)));
        String letName = ((CString) appliedFunction.parameters.get(0)).values.get(0);
        org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification ve = new Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl("")._name(letName);
        ve._genericType(vs.get(1)._genericType());
        ve._multiplicity(vs.get(1)._multiplicity());
        processingContext.addInferredVariables(letName, ve);
    }
    org.eclipse.collections.api.tuple.Pair<SimpleFunctionExpression, List<ValueSpecification>> func = this.context.buildFunctionExpression(appliedFunction.function, appliedFunction.fControl, appliedFunction.parameters, openVariables, appliedFunction.sourceInformation, processingContext);
    processingContext.pop();
    Assert.assertTrue(func != null, () -> "Can't find a match for function '" + appliedFunction.function + "(?)'", appliedFunction.sourceInformation, EngineErrorType.COMPILATION);
    Assert.assertTrue(func.getOne() != null, () -> "Can't find a match for function '" + appliedFunction.function + "(" + (func.getTwo() == null ? "?" : LazyIterate.collect(func.getTwo(), v -> (v._genericType() == null ? "?" : v._genericType()._rawType()._name()) + org.finos.legend.pure.m3.navigation.multiplicity.Multiplicity.print(v._multiplicity())).makeString(",")) + ")'", appliedFunction.sourceInformation, EngineErrorType.COMPILATION);
    ValueSpecification result = func.getOne();
    result.setSourceInformation(SourceInformationHelper.toM3SourceInformation(appliedFunction.sourceInformation));
    return result;
}
Also used : ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) CString(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.CString) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) SimpleFunctionExpression(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.SimpleFunctionExpression) MutableList(org.eclipse.collections.api.list.MutableList) List(java.util.List) PureList(org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.PureList) FastList(org.eclipse.collections.impl.list.mutable.FastList) Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl)

Aggregations

Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl (org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_VariableExpression_Impl)11 VariableExpression (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression)8 Root_meta_pure_metamodel_type_generics_GenericType_Impl (org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl)7 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)7 Root_meta_pure_metamodel_function_LambdaFunction_Impl (org.finos.legend.pure.generated.Root_meta_pure_metamodel_function_LambdaFunction_Impl)5 LambdaFunction (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.LambdaFunction)5 ValueSpecification (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification)5 Multiplicity (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Multiplicity)4 MutableList (org.eclipse.collections.api.list.MutableList)3 FastList (org.eclipse.collections.impl.list.mutable.FastList)3 Root_meta_pure_metamodel_valuespecification_InstanceValue_Impl (org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_InstanceValue_Impl)3 Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl (org.finos.legend.pure.generated.Root_meta_pure_metamodel_valuespecification_SimpleFunctionExpression_Impl)3 InstanceValue (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue)3 SimpleFunctionExpression (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.SimpleFunctionExpression)3 List (java.util.List)2 Optional (java.util.Optional)2 RichIterable (org.eclipse.collections.api.RichIterable)2 Pair (org.eclipse.collections.api.tuple.Pair)2 Lists (org.eclipse.collections.impl.factory.Lists)2 ListIterate (org.eclipse.collections.impl.utility.ListIterate)2