Search in sources :

Example 1 with Root_meta_pure_metamodel_relationship_Generalization_Impl

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

the class HelperMappingBuilder method buildMappingClassOutOfLocalProperties.

public static void buildMappingClassOutOfLocalProperties(SetImplementation setImplementation, RichIterable<? extends org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMapping> propertyMappings, CompileContext context) {
    if (setImplementation instanceof InstanceSetImplementation && propertyMappings != null) {
        List<? extends org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMapping> localPropertyMappings = ListIterate.select(propertyMappings.toList(), x -> x._localMappingProperty() != null && x._localMappingProperty());
        if (!localPropertyMappings.isEmpty()) {
            String mappingClassName = setImplementation._class().getName() + "_" + setImplementation._parent().getName() + "_" + setImplementation._id();
            final MappingClass mappingClass = new Root_meta_pure_mapping_MappingClass_Impl<>(mappingClassName);
            mappingClass._name(mappingClassName);
            GenericType classifierGenericType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::metamodel::type::Class"))._typeArguments(Lists.fixedSize.of(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(mappingClass)));
            mappingClass._classifierGenericType(classifierGenericType);
            GenericType superType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(setImplementation._class());
            Generalization newGeneralization = new Root_meta_pure_metamodel_relationship_Generalization_Impl("")._specific(mappingClass)._general(superType);
            mappingClass._generalizations(Lists.immutable.with(newGeneralization));
            setImplementation._class()._specializationsAdd(newGeneralization);
            mappingClass._properties(ListIterate.collect(localPropertyMappings, pm -> {
                Property property = pm._property();
                property._owner(mappingClass);
                property._classifierGenericType()._typeArguments().toList().get(0)._rawType(mappingClass);
                return property;
            }));
            ((InstanceSetImplementation) setImplementation)._mappingClass(mappingClass);
        }
    }
}
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_relationship_Generalization_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Generalization_Impl) Generalization(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization) Root_meta_pure_mapping_MappingClass_Impl(org.finos.legend.pure.generated.Root_meta_pure_mapping_MappingClass_Impl) InstanceSetImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.InstanceSetImplementation) Root_meta_pure_metamodel_type_generics_GenericType_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl) MappingClass(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.MappingClass) Property(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property)

Example 2 with Root_meta_pure_metamodel_relationship_Generalization_Impl

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

the class PackageableElementSecondPassBuilder method visit.

@Override
public PackageableElement visit(Class srcClass) {
    String fullPath = this.context.pureModel.buildPackageString(srcClass._package, srcClass.name);
    org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class _class = this.context.pureModel.getClass(fullPath, srcClass.sourceInformation);
    final GenericType _classGenericType = this.context.resolveGenericType(fullPath, srcClass.sourceInformation);
    Set<String> uniqueSuperTypes = new HashSet<>();
    MutableList<Generalization> generalization = ListIterate.collect(srcClass.superTypes, superType -> {
        // validate no duplicated class supertype
        if (!uniqueSuperTypes.add(superType)) {
            throw new EngineException("Duplicated super type '" + superType + "' in class '" + this.context.pureModel.buildPackageString(srcClass._package, srcClass.name) + "'", srcClass.sourceInformation, EngineErrorType.COMPILATION);
        }
        Generalization g = new Root_meta_pure_metamodel_relationship_Generalization_Impl("")._general(this.context.resolveGenericType(superType, srcClass.sourceInformation))._specific(_class);
        if (!this.context.pureModel.isImmutable(superType)) {
            org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class<?> superTypeClass;
            Type type = this.context.resolveType(superType, srcClass.sourceInformation);
            try {
                superTypeClass = (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class<?>) type;
            } catch (ClassCastException e) {
                throw new EngineException("Invalid supertype: '" + srcClass.name + "' cannot extend '" + superType + "' as it is not a class.", srcClass.sourceInformation, EngineErrorType.COMPILATION);
            }
            superTypeClass._specializationsAdd(g);
        }
        return g;
    });
    MutableList<org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property<?, ?>> properties = ListIterate.collect(srcClass.properties, HelperModelBuilder.processProperty(this.context, _classGenericType, _class));
    MutableList<org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property<?, ?>> withMilestoningProperties = properties.withAll(Milestoning.generateMilestoningProperties(_class, this.context));
    ProcessingContext ctx = new ProcessingContext("Class '" + this.context.pureModel.buildPackageString(srcClass._package, srcClass.name) + "' Second Pass");
    org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification thisVariable = HelperModelBuilder.createThisVariableForClass(this.context, this.context.pureModel.buildPackageString(srcClass._package, srcClass.name));
    ctx.addInferredVariables("this", thisVariable);
    RichIterable<QualifiedProperty<?>> qualifiedProperties = ListIterate.collect(srcClass.qualifiedProperties, HelperModelBuilder.processQualifiedPropertyFirstPass(this.context, _class, this.context.pureModel.buildPackageString(srcClass._package, srcClass.name), ctx));
    _class._originalMilestonedProperties(ListIterate.collect(srcClass.originalMilestonedProperties, HelperModelBuilder.processProperty(this.context, _classGenericType, _class)))._generalizations(generalization)._qualifiedProperties(qualifiedProperties)._properties(withMilestoningProperties);
    ctx.flushVariable("this");
    return _class;
}
Also used : GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) Root_meta_pure_metamodel_relationship_Generalization_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Generalization_Impl) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) Generalization(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization) LoggingEventType(org.finos.legend.engine.shared.core.operational.logs.LoggingEventType) EngineErrorType(org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType) FunctionType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.FunctionType) Type(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type) GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) QualifiedProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty) HashSet(java.util.HashSet) QualifiedProperty(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty)

Example 3 with Root_meta_pure_metamodel_relationship_Generalization_Impl

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

the class HelperMappingBuilder method processMappingClass.

public static Root_meta_pure_mapping_MappingClass_Impl processMappingClass(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.MappingClass mappingclass, CompileContext context, Mapping parent) {
    Root_meta_pure_mapping_MappingClass_Impl mappingClass = new Root_meta_pure_mapping_MappingClass_Impl<>(" ");
    mappingClass._name(mappingclass.name);
    MutableList<Generalization> generalizations = ListIterate.collect(mappingclass.superTypes, (superType) -> {
        Generalization generalization = new Root_meta_pure_metamodel_relationship_Generalization_Impl("")._general(context.resolveGenericType(superType))._specific(mappingClass);
        context.resolveType(superType)._specializationsAdd(generalization);
        return generalization;
    });
    mappingClass._generalizations(generalizations);
    if (mappingclass.setImplementation != null) {
        mappingClass._setImplementation(mappingclass.setImplementation.accept(new ClassMappingFirstPassBuilder(context, parent)).getOne());
    }
    if (mappingclass.rootClass != null) {
        mappingClass._class((org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class) mappingclass.rootClass.accept(new PackageableElementThirdPassBuilder(context)));
    }
    return mappingClass;
}
Also used : Root_meta_pure_metamodel_relationship_Generalization_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Generalization_Impl) Generalization(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization) Root_meta_pure_mapping_MappingClass_Impl(org.finos.legend.pure.generated.Root_meta_pure_mapping_MappingClass_Impl)

Example 4 with Root_meta_pure_metamodel_relationship_Generalization_Impl

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

the class PackageableElementFourthPassBuilder method visit.

@Override
public PackageableElement visit(Class srcClass) {
    org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class<?> targetClass = this.context.pureModel.getClass(this.context.pureModel.buildPackageString(srcClass._package, srcClass.name), srcClass.sourceInformation);
    ProcessingContext ctx = new ProcessingContext("Class '" + this.context.pureModel.buildPackageString(srcClass._package, srcClass.name) + "' Fourth Pass");
    org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification thisVariable = HelperModelBuilder.createThisVariableForClass(this.context, this.context.pureModel.buildPackageString(srcClass._package, srcClass.name));
    ListIterate.collect(srcClass.qualifiedProperties, property -> {
        ctx.push("Qualified Property " + property.name);
        ctx.addInferredVariables("this", thisVariable);
        MutableList<ValueSpecification> body;
        try {
            property.parameters.forEach(p -> p.accept(new ValueSpecificationBuilder(this.context, Lists.mutable.empty(), ctx)));
            body = ListIterate.collect(property.body, expression -> expression.accept(new ValueSpecificationBuilder(this.context, Lists.mutable.empty(), ctx)));
        } catch (Exception e) {
            LOGGER.warn(new LogInfo(null, LoggingEventType.GRAPH_EXPRESSION_ERROR, "Can't build derived property '" + property.name + " of class '" + this.context.pureModel.buildPackageString(srcClass._package, srcClass.name) + "' - stack: " + ctx.getStack()).toString());
            if (e instanceof EngineException) {
                throw e;
            }
            throw new EngineException(e.getMessage(), property.sourceInformation, EngineErrorType.COMPILATION);
        }
        ctx.flushVariable("this");
        org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty<?> prop = targetClass._qualifiedProperties().select(o -> HelperModelBuilder.isCompatibleDerivedProperty(o, property)).getFirst();
        HelperModelBuilder.checkCompatibility(this.context, body.getLast()._genericType()._rawType(), body.getLast()._multiplicity(), prop._genericType()._rawType(), prop._multiplicity(), "Error in derived property '" + srcClass.name + "." + property.name + "'", property.body.get(property.body.size() - 1).sourceInformation);
        ctx.pop();
        return prop._expressionSequence(body);
    });
    HelperModelBuilder.processClassConstraints(srcClass, this.context, targetClass, ctx, thisVariable);
    if (targetClass._generalizations().isEmpty()) {
        Generalization g = new Root_meta_pure_metamodel_relationship_Generalization_Impl("")._general(this.context.pureModel.getGenericType("meta::pure::metamodel::type::Any"))._specific(targetClass);
        targetClass._generalizationsAdd(g);
    }
    return targetClass;
}
Also used : LoggingEventType(org.finos.legend.engine.shared.core.operational.logs.LoggingEventType) Class(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Class) Logger(org.slf4j.Logger) PackageableElementVisitor(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElementVisitor) EngineErrorType(org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType) Mapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.Mapping) Generalization(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization) ListIterate(org.eclipse.collections.impl.utility.ListIterate) MutableList(org.eclipse.collections.api.list.MutableList) DataElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.data.DataElement) LogInfo(org.finos.legend.engine.shared.core.operational.logs.LogInfo) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) RichIterable(org.eclipse.collections.api.RichIterable) PackageableConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.PackageableConnection) org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain) PackageableElement(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.PackageableElement) Lists(org.eclipse.collections.impl.factory.Lists) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) SectionIndex(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.section.SectionIndex) AssociationImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.AssociationImplementation) Root_meta_pure_metamodel_relationship_Generalization_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Generalization_Impl) PackageableRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime) LogInfo(org.finos.legend.engine.shared.core.operational.logs.LogInfo) Root_meta_pure_metamodel_relationship_Generalization_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Generalization_Impl) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) Generalization(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization) EngineException(org.finos.legend.engine.shared.core.operational.errorManagement.EngineException) ValueSpecification(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.ValueSpecification)

Example 5 with Root_meta_pure_metamodel_relationship_Generalization_Impl

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

the class HelperRelationalBuilder method processRelationalClassMapping.

public static SetImplementation processRelationalClassMapping(RelationalClassMapping relationalClassMapping, CompileContext context, RelationalInstanceSetImplementation base, RootRelationalInstanceSetImplementation topParent, Mapping parent, MutableList<org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.EmbeddedRelationalInstanceSetImplementation> embeddedRelationalPropertyMappings, RichIterable<org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.EnumerationMapping<Object>> enumerationMappings, MutableMap<String, TableAlias> aliasMap) {
    final org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class pureClass = relationalClassMapping._class != null ? context.resolveClass(relationalClassMapping._class, relationalClassMapping.classSourceInformation) : base._class();
    RichIterable<org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.RelationalOperationElement> primaryKey = ListIterate.collect(relationalClassMapping.primaryKey, p -> processRelationalOperationElement(p, context, UnifiedMap.newMap(), FastList.newList()));
    MutableList<org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyMapping> localMappingProperties = ListIterate.select(relationalClassMapping.propertyMappings, p -> p.localMappingProperty != null);
    if (localMappingProperties.notEmpty()) {
        MappingClass mappingClass = new Root_meta_pure_mapping_MappingClass_Impl<>("");
        mappingClass._name(pureClass._name() + "_" + parent._name() + "_" + base._id());
        GenericType gType = new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::mapping::MappingClass"))._typeArguments(Lists.mutable.with(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(mappingClass)));
        mappingClass._classifierGenericType(gType);
        Generalization g = new Root_meta_pure_metamodel_relationship_Generalization_Impl("")._specific(mappingClass)._general(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(pureClass));
        mappingClass._generalizations(Lists.mutable.with(g));
        mappingClass._properties(localMappingProperties.collect((Function<org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.PropertyMapping, Property>) propertyMapping -> {
            GenericType returnGenericType = context.resolveGenericType(propertyMapping.localMappingProperty.type, propertyMapping.localMappingProperty.sourceInformation);
            return new Root_meta_pure_metamodel_function_property_Property_Impl<>(propertyMapping.property.property)._name(propertyMapping.property.property)._classifierGenericType(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(context.pureModel.getType("meta::pure::metamodel::function::property::Property"))._typeArguments(Lists.fixedSize.of(new Root_meta_pure_metamodel_type_generics_GenericType_Impl("")._rawType(mappingClass), returnGenericType)))._genericType(returnGenericType)._multiplicity(context.pureModel.getMultiplicity(propertyMapping.localMappingProperty.multiplicity))._owner(mappingClass);
        }));
        base._mappingClass(mappingClass);
    }
    base._class(pureClass)._primaryKey(primaryKey)._propertyMappings(ListIterate.collect(relationalClassMapping.propertyMappings, propertyMapping -> processAbstractRelationalPropertyMapping(propertyMapping, context, base, topParent, embeddedRelationalPropertyMappings, enumerationMappings, aliasMap)))._parent(parent);
    return base;
}
Also used : RelationalOperationElement(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.RelationalOperationElement) MilestoningStereotype(org.finos.legend.pure.m3.compiler.postprocessing.processor.milestoning.MilestoningStereotype) Generalization(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization) Function(org.eclipse.collections.api.block.function.Function) DynaFunction(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.DynaFunction) Root_meta_pure_metamodel_type_generics_GenericType_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_type_generics_GenericType_Impl) GenericType(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType) Root_meta_pure_metamodel_relationship_Generalization_Impl(org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Generalization_Impl) Class(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class) Root_meta_pure_mapping_MappingClass_Impl(org.finos.legend.pure.generated.Root_meta_pure_mapping_MappingClass_Impl) PropertyMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMapping) OtherwiseEmbeddedRelationalPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.OtherwiseEmbeddedRelationalPropertyMapping) RelationalPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.RelationalPropertyMapping) AggregationAwarePropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.aggregationAware.AggregationAwarePropertyMapping) EmbeddedRelationalPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.EmbeddedRelationalPropertyMapping) InlineEmbeddedPropertyMapping(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.mapping.InlineEmbeddedPropertyMapping) MappingClass(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.MappingClass)

Aggregations

Root_meta_pure_metamodel_relationship_Generalization_Impl (org.finos.legend.pure.generated.Root_meta_pure_metamodel_relationship_Generalization_Impl)5 Generalization (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.relationship.Generalization)5 EngineErrorType (org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType)3 EngineException (org.finos.legend.engine.shared.core.operational.errorManagement.EngineException)3 Root_meta_pure_mapping_MappingClass_Impl (org.finos.legend.pure.generated.Root_meta_pure_mapping_MappingClass_Impl)3 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)3 RichIterable (org.eclipse.collections.api.RichIterable)2 MutableList (org.eclipse.collections.api.list.MutableList)2 Lists (org.eclipse.collections.impl.factory.Lists)2 ListIterate (org.eclipse.collections.impl.utility.ListIterate)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Function (org.eclipse.collections.api.block.function.Function)1 Procedure2 (org.eclipse.collections.api.block.procedure.Procedure2)1 ImmutableSet (org.eclipse.collections.api.set.ImmutableSet)1 MutableSet (org.eclipse.collections.api.set.MutableSet)1