Search in sources :

Example 1 with PropertyMappingsImplementation

use of org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation in project legend-pure by finos.

the class RelationalOperationElementProcessor method processJoinTreeNode.

static void processJoinTreeNode(JoinTreeNode joinTreeNode, CoreInstance implementation, Matcher matcher, ProcessorState state, ModelRepository repository, ProcessorSupport processorSupport) {
    String joinName = joinTreeNode._joinName();
    Database database = (Database) ImportStub.withImportStubByPass(joinTreeNode._databaseCoreInstance(), processorSupport);
    if (database == null) {
        throw new PureCompilationException(joinTreeNode.getSourceInformation(), "The system can't figure out which database to use.");
    }
    PostProcessor.processElement(matcher, database, state, processorSupport);
    CoreInstance joinType = joinTreeNode._joinTypeCoreInstance();
    if (joinType != null) {
        StringCoreInstance joinTypeString = (StringCoreInstance) joinType;
        String type = "INNER".equals(joinTypeString.getValue()) ? "INNER" : "LEFT_OUTER";
        Enumeration joinTypeEnumeration = (Enumeration) processorSupport.package_getByUserPath(M2RelationalPaths.JoinType);
        Enum joinTypeEnumInstance = (Enum) org.finos.legend.pure.m3.navigation.enumeration.Enumeration.findEnum(joinTypeEnumeration, type);
        if (joinTypeEnumInstance == null) {
            throw new PureCompilationException(joinTreeNode.getSourceInformation(), "The enum value '" + type + "' can't be found in the enumeration " + PackageableElement.getUserPathForPackageableElement(joinTypeEnumeration, "::"));
        }
        joinTreeNode._joinTypeCoreInstance(joinTypeEnumInstance);
    }
    Join join = findJoin(joinTreeNode, database, joinName, processorSupport);
    joinTreeNode._join(join);
    PropertyMappingsImplementation owner = joinTreeNode._setMappingOwner();
    if (owner == null && implementation != null) {
        joinTreeNode._setMappingOwner((PropertyMappingsImplementation) implementation);
    }
    for (TreeNode child : joinTreeNode._childrenData()) {
        processJoinTreeNode((JoinTreeNode) child, implementation, matcher, state, repository, processorSupport);
    }
}
Also used : Enum(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enum) Enumeration(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Enumeration) TreeNode(org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.TreeNode) JoinTreeNode(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.join.JoinTreeNode) Database(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Database) StringCoreInstance(org.finos.legend.pure.m4.coreinstance.primitive.StringCoreInstance) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) Join(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.join.Join) RelationalOperationElementWithJoin(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.RelationalOperationElementWithJoin) StringCoreInstance(org.finos.legend.pure.m4.coreinstance.primitive.StringCoreInstance) PropertyMappingsImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation) PureCompilationException(org.finos.legend.pure.m4.exception.PureCompilationException)

Example 2 with PropertyMappingsImplementation

use of org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation in project legend-pure by finos.

the class RelationalPropertyMappingProcessor method collectJoinTreeNodes.

private static void collectJoinTreeNodes(Collection<? super JoinTreeNode> targetCollection, PropertyMapping propertyMapping) {
    if (propertyMapping instanceof RelationalPropertyMapping) {
        RelationalOperationElement relationalOperationElement = ((RelationalPropertyMapping) propertyMapping)._relationalOperationElement();
        RelationalOperationElementProcessor.collectJoinTreeNodes(targetCollection, relationalOperationElement);
    }
    if (propertyMapping instanceof OtherwiseEmbeddedRelationalInstanceSetImplementation) {
        PropertyMapping relationalOperationElement = ((OtherwiseEmbeddedRelationalInstanceSetImplementation) propertyMapping)._otherwisePropertyMapping();
        collectJoinTreeNodes(targetCollection, relationalOperationElement);
    }
    if (propertyMapping instanceof PropertyMappingsImplementation) {
        RichIterable<? extends PropertyMapping> propertyMappings = ((PropertyMappingsImplementation) propertyMapping)._propertyMappings();
        for (PropertyMapping subMapping : propertyMappings) {
            collectJoinTreeNodes(targetCollection, subMapping);
        }
    }
}
Also used : RelationalPropertyMapping(org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.RelationalPropertyMapping) OtherwiseEmbeddedRelationalInstanceSetImplementation(org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.OtherwiseEmbeddedRelationalInstanceSetImplementation) RelationalOperationElement(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.RelationalOperationElement) PropertyMapping(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMapping) RelationalPropertyMapping(org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.RelationalPropertyMapping) PropertyMappingsImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation)

Example 3 with PropertyMappingsImplementation

use of org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation in project legend-pure by finos.

the class RelationalOperationElementProcessor method processAliasForJoinTreeNode.

static void processAliasForJoinTreeNode(JoinTreeNode joinTreeNode, RelationalOperationElement startTable, ProcessorSupport processorSupport) {
    TableAlias alias = findAliasForJoinTreeNode(joinTreeNode, startTable, processorSupport);
    TableAlias aliasCopy = org.finos.legend.pure.m2.relational.TableAlias.copyTableAlias(alias, null, processorSupport);
    PropertyMappingsImplementation setMappingOwner = joinTreeNode._setMappingOwner();
    if (setMappingOwner != null) {
        aliasCopy._setMappingOwner(setMappingOwner);
    }
    joinTreeNode._alias(aliasCopy);
    RichIterable<? extends TreeNode> children = joinTreeNode._childrenData();
    if (children.notEmpty()) {
        RelationalOperationElement newStartTable = alias._relationalElement();
        for (TreeNode child : children) {
            processAliasForJoinTreeNode((JoinTreeNode) child, newStartTable, processorSupport);
        }
    }
}
Also used : RelationalOperationElement(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.RelationalOperationElement) TreeNode(org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.TreeNode) JoinTreeNode(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.join.JoinTreeNode) TableAlias(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAlias) PropertyMappingsImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation)

Example 4 with PropertyMappingsImplementation

use of org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation in project legend-pure by finos.

the class TableAlias method copyTableAlias.

private static org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAlias copyTableAlias(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAlias tableAlias, boolean replaceSourceInfo, SourceInformation newSourceInfo, ProcessorSupport processorSupport) {
    org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAlias copy = (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAlias) processorSupport.newAnonymousCoreInstance(replaceSourceInfo ? newSourceInfo : tableAlias.getSourceInformation(), M2RelationalPaths.TableAlias);
    copy._name(tableAlias._name());
    copy._relationalElement(tableAlias._relationalElement());
    PropertyMappingsImplementation setMappingOwner = tableAlias._setMappingOwner();
    if (setMappingOwner != null) {
        copy._setMappingOwner(setMappingOwner);
    }
    Database database = (Database) ImportStub.withImportStubByPass(tableAlias._databaseCoreInstance(), processorSupport);
    if (database != null) {
        copy._databaseCoreInstance(database);
    }
    String schema = tableAlias._schema();
    if (schema != null) {
        copy._schema(schema);
    }
    return copy;
}
Also used : PropertyMappingsImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation) Database(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Database)

Example 5 with PropertyMappingsImplementation

use of org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation in project legend-pure by finos.

the class PropertyMappingUnloaderWalk method run.

@Override
public void run(PropertyMapping propertyMapping, MatcherState state, Matcher matcher, ModelRepository modelRepository, Context context) throws PureCompilationException {
    PropertyMappingsImplementation owner = propertyMapping._owner();
    matcher.fullMatch(owner, state);
}
Also used : PropertyMappingsImplementation(org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation)

Aggregations

PropertyMappingsImplementation (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMappingsImplementation)13 PropertyMapping (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.PropertyMapping)8 Property (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property)8 RelationalOperationElement (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.RelationalOperationElement)6 EngineException (org.finos.legend.engine.shared.core.operational.errorManagement.EngineException)5 OtherwiseEmbeddedRelationalInstanceSetImplementation (org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.OtherwiseEmbeddedRelationalInstanceSetImplementation)5 SetImplementation (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.SetImplementation)4 Class (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Class)4 Type (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type)4 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)4 Database (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Database)4 CoreInstance (org.finos.legend.pure.m4.coreinstance.CoreInstance)4 EngineErrorType (org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType)3 TreeNode (org.finos.legend.pure.m3.coreinstance.meta.pure.functions.collection.TreeNode)3 Mapping (org.finos.legend.pure.m3.coreinstance.meta.pure.mapping.Mapping)3 RootRelationalInstanceSetImplementation (org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.RootRelationalInstanceSetImplementation)3 JoinTreeNode (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.join.JoinTreeNode)3 PureCompilationException (org.finos.legend.pure.m4.exception.PureCompilationException)3 List (java.util.List)2 Optional (java.util.Optional)2