Search in sources :

Example 1 with EnumStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.EnumStub in project legend-pure by finos.

the class TestEnumerationMapping method testValidComplexEnumToEnumMapping.

@Test
public void testValidComplexEnumToEnumMapping() {
    this.runtime.createInMemorySource("model.pure", "###Pure\n" + "\n" + "Enum my::SourceEnum\n" + "{\n" + "   A, B, C\n" + "}\n" + "\n" + "Enum my::TargetEnum\n" + "{\n" + "   X, Y\n" + "}\n" + "\n" + "###Mapping\n" + "import my::*;\n" + "\n" + "Mapping my::TestMapping\n" + "(\n" + "   TargetEnum : EnumerationMapping\n" + "   {\n" + "      X : SourceEnum.A,\n" + "      Y : [SourceEnum.B, my::SourceEnum.C]\n" + "   }\n" + ")");
    this.runtime.compile();
    org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping mapping = (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping) this.runtime.getCoreInstance("my::TestMapping");
    EnumerationMapping enumerationMapping = mapping._enumerationMappings().getFirst();
    Assert.assertEquals("my::TargetEnum", PackageableElement.getUserPathForPackageableElement(enumerationMapping._enumeration()));
    ImmutableList<EnumValueMapping> enumValueMappings = (ImmutableList<EnumValueMapping>) enumerationMapping._enumValueMappings();
    Assert.assertEquals(2, enumValueMappings.size());
    EnumValueMapping enumValueMapping1 = enumValueMappings.get(0);
    Assert.assertEquals("X", enumValueMapping1._enum()._name());
    ImmutableList<CoreInstance> sourceValuesCoreInstances1 = (ImmutableList<CoreInstance>) enumValueMapping1._sourceValuesCoreInstance();
    Assert.assertEquals(1, sourceValuesCoreInstances1.size());
    Assert.assertTrue(sourceValuesCoreInstances1.get(0) instanceof EnumStub);
    Assert.assertEquals("my::SourceEnum", PackageableElement.getUserPathForPackageableElement(((EnumStub) sourceValuesCoreInstances1.get(0))._enumeration()));
    ImmutableList<CoreInstance> sourceValues1 = (ImmutableList<CoreInstance>) enumValueMapping1._sourceValues();
    Assert.assertEquals(1, sourceValues1.size());
    Assert.assertTrue(sourceValues1.get(0) instanceof Enum);
    Assert.assertEquals("A", ((Enum) sourceValues1.get(0))._name());
    EnumValueMapping enumValueMapping2 = enumValueMappings.get(1);
    Assert.assertEquals("Y", enumValueMapping2._enum()._name());
    ImmutableList<CoreInstance> sourceValuesCoreInstances2 = (ImmutableList<CoreInstance>) enumValueMapping2._sourceValuesCoreInstance();
    Assert.assertEquals(2, sourceValuesCoreInstances2.size());
    Assert.assertTrue(sourceValuesCoreInstances2.get(0) instanceof EnumStub);
    Assert.assertEquals("my::SourceEnum", PackageableElement.getUserPathForPackageableElement(((EnumStub) sourceValuesCoreInstances2.get(0))._enumeration()));
    Assert.assertTrue(sourceValuesCoreInstances2.get(1) instanceof EnumStub);
    Assert.assertEquals("my::SourceEnum", PackageableElement.getUserPathForPackageableElement(((EnumStub) sourceValuesCoreInstances2.get(1))._enumeration()));
    ImmutableList<CoreInstance> sourceValues2 = (ImmutableList<CoreInstance>) enumValueMapping2._sourceValues();
    Assert.assertEquals(2, sourceValues2.size());
    Assert.assertTrue(sourceValues2.get(0) instanceof Enum);
    Assert.assertEquals("B", ((Enum) sourceValues2.get(0))._name());
    Assert.assertTrue(sourceValues2.get(1) instanceof Enum);
    Assert.assertEquals("C", ((Enum) sourceValues2.get(1))._name());
}
Also used : Enum(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enum) EnumStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.EnumStub) EnumerationMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumerationMapping) ImmutableList(org.eclipse.collections.api.list.ImmutableList) EnumValueMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumValueMapping) EnumerationMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumerationMapping) EnumValueMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumValueMapping) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) IntegerCoreInstance(org.finos.legend.pure.m4.coreinstance.primitive.IntegerCoreInstance) Test(org.junit.Test)

Example 2 with EnumStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.EnumStub in project legend-pure by finos.

the class TestEnumerationMapping method testValidSimpleEnumToEnumMapping.

@Test
public void testValidSimpleEnumToEnumMapping() {
    this.runtime.createInMemorySource("model.pure", "###Pure\n" + "\n" + "Enum my::SourceEnum\n" + "{\n" + "   A, B\n" + "}\n" + "\n" + "Enum my::TargetEnum\n" + "{\n" + "   X, Y\n" + "}\n" + "\n" + "###Mapping\n" + "import my::*;\n" + "\n" + "Mapping my::TestMapping\n" + "(\n" + "   TargetEnum : EnumerationMapping\n" + "   {\n" + "      X : SourceEnum.A,\n" + "      Y : my::SourceEnum.B\n" + "   }\n" + ")");
    this.runtime.compile();
    org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping mapping = (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping) this.runtime.getCoreInstance("my::TestMapping");
    EnumerationMapping enumerationMapping = mapping._enumerationMappings().getFirst();
    Assert.assertEquals("my::TargetEnum", PackageableElement.getUserPathForPackageableElement(enumerationMapping._enumeration()));
    ImmutableList<EnumValueMapping> enumValueMappings = (ImmutableList<EnumValueMapping>) enumerationMapping._enumValueMappings();
    Assert.assertEquals(2, enumValueMappings.size());
    EnumValueMapping enumValueMapping1 = enumValueMappings.get(0);
    Assert.assertEquals("X", enumValueMapping1._enum()._name());
    ImmutableList<CoreInstance> sourceValuesCoreInstances1 = (ImmutableList<CoreInstance>) enumValueMapping1._sourceValuesCoreInstance();
    Assert.assertEquals(1, sourceValuesCoreInstances1.size());
    Assert.assertTrue(sourceValuesCoreInstances1.get(0) instanceof EnumStub);
    Assert.assertEquals("my::SourceEnum", PackageableElement.getUserPathForPackageableElement(((EnumStub) sourceValuesCoreInstances1.get(0))._enumeration()));
    ImmutableList<CoreInstance> sourceValues1 = (ImmutableList<CoreInstance>) enumValueMapping1._sourceValues();
    Assert.assertEquals(1, sourceValues1.size());
    Assert.assertTrue(sourceValues1.get(0) instanceof Enum);
    Assert.assertEquals("A", ((Enum) sourceValues1.get(0))._name());
    EnumValueMapping enumValueMapping2 = enumValueMappings.get(1);
    Assert.assertEquals("Y", enumValueMapping2._enum()._name());
    ImmutableList<CoreInstance> sourceValuesCoreInstances2 = (ImmutableList<CoreInstance>) enumValueMapping2._sourceValuesCoreInstance();
    Assert.assertEquals(1, sourceValuesCoreInstances2.size());
    Assert.assertTrue(sourceValuesCoreInstances2.get(0) instanceof EnumStub);
    Assert.assertEquals("my::SourceEnum", PackageableElement.getUserPathForPackageableElement(((EnumStub) sourceValuesCoreInstances2.get(0))._enumeration()));
    ImmutableList<CoreInstance> sourceValues2 = (ImmutableList<CoreInstance>) enumValueMapping2._sourceValues();
    Assert.assertEquals(1, sourceValues2.size());
    Assert.assertTrue(sourceValues2.get(0) instanceof Enum);
    Assert.assertEquals("B", ((Enum) sourceValues2.get(0))._name());
}
Also used : Enum(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enum) EnumStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.EnumStub) EnumerationMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumerationMapping) ImmutableList(org.eclipse.collections.api.list.ImmutableList) EnumValueMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumValueMapping) EnumerationMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumerationMapping) EnumValueMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumValueMapping) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) IntegerCoreInstance(org.finos.legend.pure.m4.coreinstance.primitive.IntegerCoreInstance) Test(org.junit.Test)

Example 3 with EnumStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.EnumStub in project legend-pure by finos.

the class TestEnumerationMapping method testValidHybridEnumToEnumMapping.

@Test
public void testValidHybridEnumToEnumMapping() {
    this.runtime.createInMemorySource("model.pure", "###Pure\n" + "\n" + "Enum my::SourceEnum1\n" + "{\n" + "   A, B, C\n" + "}\n" + "\n" + "Enum my::SourceEnum2\n" + "{\n" + "   P, Q, R\n" + "}\n" + "\n" + "Enum my::TargetEnum\n" + "{\n" + "   U, V, W, X, Y, Z\n" + "}\n" + "\n" + "###Mapping\n" + "import my::*;\n" + "\n" + "Mapping my::TestMapping\n" + "(\n" + "   TargetEnum : EnumerationMapping enumsATargetEnum\n" + "   {\n" + "      U : my::SourceEnum1.A,\n" + "      V : my::SourceEnum1.A,\n" + "      W : [my::SourceEnum1.A, my::SourceEnum1.B],\n" + "      X : [my::SourceEnum1.A, my::SourceEnum1.B, my::SourceEnum1.C],\n" + "      Y : [my::SourceEnum1.A, my::SourceEnum1.B, my::SourceEnum1.C],\n" + "      Z : my::SourceEnum1.C\n" + "   }\n" + "   TargetEnum : EnumerationMapping enumsBTargetEnum\n" + "   {\n" + "      U : my::SourceEnum2.P,\n" + "      V : my::SourceEnum2.P\n," + "      W : [my::SourceEnum2.P, my::SourceEnum2. Q,my::SourceEnum2.R]\n" + "   }\n" + "   TargetEnum : EnumerationMapping integersTargetEnum2\n" + "   {\n" + "      X : [4,5,6],\n" + "      Y : 3\n" + "   }\n" + "   TargetEnum : EnumerationMapping stringsTargetEnum2\n" + "   {\n" + "      Y : ['One','Two','Three'],\n" + "      Z : 'A'\n" + "   }\n" + ")");
    this.runtime.compile();
    org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping mapping = (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping) this.runtime.getCoreInstance("my::TestMapping");
    EnumerationMapping enumerationMapping = mapping._enumerationMappings().detect(detectByEnumerationMappingName("enumsATargetEnum"));
    Assert.assertEquals("my::TargetEnum", PackageableElement.getUserPathForPackageableElement(enumerationMapping._enumeration()));
    ImmutableList<EnumValueMapping> enumValueMappings = (ImmutableList<EnumValueMapping>) enumerationMapping._enumValueMappings();
    Assert.assertEquals(6, enumValueMappings.size());
    EnumValueMapping enumValueMapping1 = enumValueMappings.get(0);
    Assert.assertEquals("U", enumValueMapping1._enum()._name());
    ImmutableList<CoreInstance> sourceValuesCoreInstances1 = (ImmutableList<CoreInstance>) enumValueMapping1._sourceValuesCoreInstance();
    Assert.assertEquals(1, sourceValuesCoreInstances1.size());
    Assert.assertTrue(sourceValuesCoreInstances1.get(0) instanceof EnumStub);
    Assert.assertEquals("my::SourceEnum1", PackageableElement.getUserPathForPackageableElement(((EnumStub) sourceValuesCoreInstances1.get(0))._enumeration()));
    ImmutableList<CoreInstance> sourceValues1 = (ImmutableList<CoreInstance>) enumValueMapping1._sourceValues();
    Assert.assertEquals(1, sourceValues1.size());
    Assert.assertTrue(sourceValues1.get(0) instanceof Enum);
    Assert.assertEquals("A", ((Enum) sourceValues1.get(0))._name());
    enumValueMappings = (ImmutableList<EnumValueMapping>) mapping._enumerationMappings().detect(detectByEnumerationMappingName("enumsBTargetEnum"))._enumValueMappings();
    EnumValueMapping enumValueMapping2 = enumValueMappings.get(1);
    Assert.assertEquals("V", enumValueMapping2._enum()._name());
    ImmutableList<CoreInstance> sourceValuesCoreInstances2 = (ImmutableList<CoreInstance>) enumValueMapping2._sourceValuesCoreInstance();
    Assert.assertEquals(1, sourceValuesCoreInstances2.size());
    Assert.assertTrue(sourceValuesCoreInstances2.get(0) instanceof EnumStub);
    Assert.assertEquals("my::SourceEnum2", PackageableElement.getUserPathForPackageableElement(((EnumStub) sourceValuesCoreInstances2.get(0))._enumeration()));
    ImmutableList<CoreInstance> sourceValues2 = (ImmutableList<CoreInstance>) enumValueMapping2._sourceValues();
    Assert.assertEquals(1, sourceValues2.size());
    Assert.assertTrue(sourceValues2.get(0) instanceof Enum);
    Assert.assertEquals("P", ((Enum) sourceValues2.get(0))._name());
    EnumValueMapping enumValueMapping3 = enumValueMappings.get(2);
    Assert.assertEquals("W", enumValueMapping3._enum()._name());
    ImmutableList<CoreInstance> sourceValuesCoreInstances3 = (ImmutableList<CoreInstance>) enumValueMapping3._sourceValuesCoreInstance();
    Assert.assertEquals(3, sourceValuesCoreInstances3.size());
    Assert.assertTrue(sourceValuesCoreInstances3.get(0) instanceof EnumStub);
    Assert.assertEquals("my::SourceEnum2", PackageableElement.getUserPathForPackageableElement(((EnumStub) sourceValuesCoreInstances3.get(0))._enumeration()));
    Assert.assertTrue(sourceValuesCoreInstances3.get(1) instanceof EnumStub);
    Assert.assertEquals("my::SourceEnum2", PackageableElement.getUserPathForPackageableElement(((EnumStub) sourceValuesCoreInstances3.get(1))._enumeration()));
    ImmutableList<CoreInstance> sourceValues3 = (ImmutableList<CoreInstance>) enumValueMapping3._sourceValues();
    Assert.assertEquals(3, sourceValues3.size());
    Assert.assertTrue(sourceValues3.get(0) instanceof Enum);
    Assert.assertEquals("P", ((Enum) sourceValues3.get(0))._name());
    Assert.assertTrue(sourceValues3.get(1) instanceof Enum);
    Assert.assertEquals("Q", ((Enum) sourceValues3.get(1))._name());
    Assert.assertTrue(sourceValues3.get(2) instanceof Enum);
    Assert.assertEquals("R", ((Enum) sourceValues3.get(2))._name());
    enumValueMappings = (ImmutableList<EnumValueMapping>) mapping._enumerationMappings().detect(detectByEnumerationMappingName("integersTargetEnum2"))._enumValueMappings();
    enumValueMapping1 = enumValueMappings.get(0);
    Assert.assertEquals("X", enumValueMapping1._enum()._name());
    ImmutableList<CoreInstance> sourceValuesCoreInstances4 = (ImmutableList<CoreInstance>) enumValueMapping1._sourceValuesCoreInstance();
    Assert.assertEquals(3, sourceValuesCoreInstances4.size());
    Assert.assertTrue(sourceValuesCoreInstances4.get(0) instanceof IntegerCoreInstance);
    MutableList<? extends Object> sourceValues4 = enumValueMapping1._sourceValues().toList();
    Assert.assertEquals(3, sourceValues4.size());
    Assert.assertEquals(4L, sourceValues4.get(0));
    Assert.assertEquals(5L, sourceValues4.get(1));
    Assert.assertEquals(6L, sourceValues4.get(2));
    enumValueMapping2 = enumValueMappings.get(1);
    Assert.assertEquals("Y", enumValueMapping2._enum()._name());
    ImmutableList<CoreInstance> sourceValuesCoreInstances5 = (ImmutableList<CoreInstance>) enumValueMapping2._sourceValuesCoreInstance();
    Assert.assertEquals(1, sourceValuesCoreInstances5.size());
    Assert.assertTrue(sourceValuesCoreInstances4.get(0) instanceof IntegerCoreInstance);
    MutableList<? extends Object> sourceValues5 = enumValueMapping2._sourceValues().toList();
    Assert.assertEquals(1, sourceValues5.size());
    Assert.assertEquals(3L, sourceValues5.get(0));
    enumValueMappings = (ImmutableList<EnumValueMapping>) mapping._enumerationMappings().detect(detectByEnumerationMappingName("stringsTargetEnum2"))._enumValueMappings();
    enumValueMapping1 = enumValueMappings.get(0);
    Assert.assertEquals("Y", enumValueMapping1._enum()._name());
    ImmutableList<CoreInstance> sourceValuesCoreInstances6 = (ImmutableList<CoreInstance>) enumValueMapping1._sourceValuesCoreInstance();
    Assert.assertEquals(3, sourceValuesCoreInstances6.size());
    Assert.assertTrue(sourceValuesCoreInstances4.get(0) instanceof IntegerCoreInstance);
    MutableList<? extends Object> sourceValues6 = enumValueMapping1._sourceValues().toList();
    Assert.assertEquals(3, sourceValues6.size());
    Assert.assertEquals("One", sourceValues6.get(0));
    Assert.assertEquals("Two", sourceValues6.get(1));
    Assert.assertEquals("Three", sourceValues6.get(2));
    enumValueMapping2 = enumValueMappings.get(1);
    Assert.assertEquals("Z", enumValueMapping2._enum()._name());
    ImmutableList<CoreInstance> sourceValuesCoreInstances7 = (ImmutableList<CoreInstance>) enumValueMapping2._sourceValuesCoreInstance();
    Assert.assertEquals(1, sourceValuesCoreInstances7.size());
    Assert.assertTrue(sourceValuesCoreInstances4.get(0) instanceof IntegerCoreInstance);
    MutableList<? extends Object> sourceValues7 = enumValueMapping2._sourceValues().toList();
    Assert.assertEquals(1, sourceValues7.size());
    Assert.assertEquals("A", sourceValues7.get(0));
}
Also used : Enum(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enum) EnumStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.EnumStub) EnumerationMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumerationMapping) ImmutableList(org.eclipse.collections.api.list.ImmutableList) EnumValueMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumValueMapping) EnumerationMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumerationMapping) IntegerCoreInstance(org.finos.legend.pure.m4.coreinstance.primitive.IntegerCoreInstance) EnumValueMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumValueMapping) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) IntegerCoreInstance(org.finos.legend.pure.m4.coreinstance.primitive.IntegerCoreInstance) Test(org.junit.Test)

Example 4 with EnumStub

use of org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.EnumStub in project legend-pure by finos.

the class RootGraphFetchTreeProcessor method processPropertyGraphFetchTree.

private void processPropertyGraphFetchTree(PropertyGraphFetchTree propertyGraphFetchTree, CoreInstance _class, ProcessorState state, Matcher matcher, ModelRepository repository, ProcessorSupport processorSupport) {
    ClassInstance type = (ClassInstance) processorSupport.package_getByUserPath(M3GraphPaths.PropertyGraphFetchTree);
    GenericType classifierGT = GenericTypeInstance.createPersistent(repository);
    classifierGT._rawTypeCoreInstance(type);
    propertyGraphFetchTree._classifierGenericType(classifierGT);
    PropertyStub propertyStubNonResolved = (PropertyStub) propertyGraphFetchTree._propertyCoreInstance();
    String propertyName = propertyStubNonResolved._propertyName();
    propertyStubNonResolved._ownerCoreInstance(_class);
    for (ValueSpecification vs : propertyGraphFetchTree._parameters()) {
        PostProcessor.processElement(matcher, vs, state, processorSupport);
        if (vs instanceof InstanceValue) {
            for (CoreInstance value : ((InstanceValue) vs)._valuesCoreInstance()) {
                if (value instanceof EnumStub) {
                    EnumStub enumStub = (EnumStub) value;
                    Enumeration<?> enumerationCoreInstance = (Enumeration<?>) ImportStub.withImportStubByPass(enumStub._enumerationCoreInstance(), processorSupport);
                    org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enum enumValue = (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enum) org.finos.legend.pure.m3.navigation.enumeration.Enumeration.findEnum(enumerationCoreInstance, enumStub._enumName());
                    if (enumValue == null) {
                        throw new PureCompilationException(enumStub.getSourceInformation(), "The enum value '" + enumStub._enumName() + "' can't be found in the enumeration " + PackageableElement.getUserPathForPackageableElement(enumerationCoreInstance, "::"));
                    }
                }
            }
        }
        InstanceValueProcessor.updateInstanceValue(vs, processorSupport);
    }
    AbstractProperty<?> property = null;
    if (propertyGraphFetchTree._parameters().isEmpty()) {
        CoreInstance resolvedProperty = processorSupport.class_findPropertyUsingGeneralization(_class, propertyName);
        if (resolvedProperty != null) {
            property = (AbstractProperty<?>) resolvedProperty;
            Instance.addValueToProperty(propertyStubNonResolved, M3Properties.resolvedProperty, property, processorSupport);
        }
    }
    if (property == null) {
        // Qualified
        VariableExpression firstParam = (VariableExpression) processorSupport.newAnonymousCoreInstance(null, M3Paths.VariableExpression);
        firstParam._genericType((GenericType) org.finos.legend.pure.m3.navigation.type.Type.wrapGenericType(_class, processorSupport));
        firstParam._multiplicity((Multiplicity) processorSupport.package_getByUserPath(M3Paths.PureOne));
        MutableList<ValueSpecification> params = FastList.newList();
        params.add(firstParam);
        for (ValueSpecification vs : propertyGraphFetchTree._parameters()) {
            params.add(vs);
        }
        ListIterable<QualifiedProperty<?>> qualifiedProperties = _Class.findQualifiedPropertiesUsingGeneralization(_class, propertyName, processorSupport);
        ListIterable<QualifiedProperty<?>> foundQualifiedProperties = FunctionExpressionMatcher.getFunctionMatches(qualifiedProperties, params, propertyName, propertyStubNonResolved.getSourceInformation(), true, processorSupport);
        if (foundQualifiedProperties.isEmpty()) {
            StringBuilder message = new StringBuilder("The system can't find a match for the property / qualified property: ");
            FunctionExpression.printFunctionSignatureFromExpression(message, propertyName, params.without(firstParam), processorSupport);
            if (qualifiedProperties.notEmpty()) {
                if (MilestoningFunctions.isGeneratedQualifiedProperty(qualifiedProperties.getFirst(), processorSupport)) {
                    CoreInstance noArgPropertyReturnType = ImportStub.withImportStubByPass(qualifiedProperties.getFirst()._genericType()._rawTypeCoreInstance(), processorSupport);
                    ListIterable<String> temporalPropertyNames = MilestoningFunctions.getTemporalStereoTypePropertyNamesFromTopMostNonTopTypeGeneralizations(noArgPropertyReturnType, processorSupport);
                    message.append(". No-Arg milestoned property: '").append(propertyName).append("' is not supported yet in graph fetch flow! It needs to be supplied with ").append(temporalPropertyNames.makeString("[", ",", "]")).append(" parameters");
                }
            }
            throw new PureCompilationException(propertyStubNonResolved.getSourceInformation(), message.toString());
        }
        property = foundQualifiedProperties.getFirst();
        Instance.addValueToProperty(propertyStubNonResolved, M3Properties.resolvedProperty, property, processorSupport);
    }
    FunctionType functionType = (FunctionType) processorSupport.function_getFunctionType(property);
    CoreInstance returnType = ImportStub.withImportStubByPass(functionType._returnType()._rawTypeCoreInstance(), processorSupport);
    PostProcessor.processElement(matcher, returnType, state, processorSupport);
    CoreInstance subTypeClass;
    if (propertyGraphFetchTree._subTypeCoreInstance() != null) {
        subTypeClass = ImportStub.withImportStubByPass(propertyGraphFetchTree._subTypeCoreInstance(), processorSupport);
        PostProcessor.processElement(matcher, subTypeClass, state, processorSupport);
        returnType = subTypeClass;
    }
    for (GraphFetchTree subTree : propertyGraphFetchTree._subTrees()) {
        this.processPropertyGraphFetchTree((PropertyGraphFetchTree) subTree, returnType, state, matcher, repository, processorSupport);
    }
    if (MilestoningFunctions.isGeneratedQualifiedProperty(property, processorSupport)) {
        CoreInstance propReturnType = ImportStub.withImportStubByPass(property._genericType()._rawTypeCoreInstance(), processorSupport);
        ListIterable<String> temporalPropertyNames = MilestoningFunctions.getTemporalStereoTypePropertyNamesFromTopMostNonTopTypeGeneralizations(propReturnType, processorSupport);
        if (propertyGraphFetchTree._parameters().size() != temporalPropertyNames.size()) {
            this.throwMilestoningPropertyPathValidationException(property, propertyStubNonResolved.getSourceInformation(), processorSupport);
        }
    }
}
Also used : PropertyStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub) EnumStub(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.EnumStub) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) InstanceValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue) ClassInstance(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ClassInstance) PureCompilationException(org.finos.legend.pure.m4.exception.PureCompilationException) GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) Enumeration(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enumeration) FunctionType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.FunctionType) VariableExpression(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression) RootGraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree) GraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.GraphFetchTree) PropertyGraphFetchTree(org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.PropertyGraphFetchTree) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) QualifiedProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty)

Aggregations

EnumStub (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.EnumStub)4 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)4 ImmutableList (org.eclipse.collections.api.list.ImmutableList)3 EnumValueMapping (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumValueMapping)3 EnumerationMapping (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumerationMapping)3 Enum (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enum)3 IntegerCoreInstance (org.finos.legend.pure.m4.coreinstance.primitive.IntegerCoreInstance)3 Test (org.junit.Test)3 GraphFetchTree (org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.GraphFetchTree)1 PropertyGraphFetchTree (org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.PropertyGraphFetchTree)1 RootGraphFetchTree (org.finos.legend.pure.m3.coreinstance.meta.pure.graphFetch.RootGraphFetchTree)1 PropertyStub (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.PropertyStub)1 QualifiedProperty (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty)1 ClassInstance (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.ClassInstance)1 Enumeration (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enumeration)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 ValueSpecification (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification)1 VariableExpression (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.VariableExpression)1