Search in sources :

Example 1 with ColumnMapping

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

the class ViewProcessing method processView.

private static void processView(SetIterable<Database> dbsInHierarchy, View view, Matcher matcher, ProcessorState processorState, ModelRepository repository, ProcessorSupport processorSupport) {
    DatabaseProcessor.processColumnsForTableOrView(view);
    RichIterable<? extends ColumnMapping> columnMappings = view._columnMappings();
    MutableMap<String, DataType> colMappingTypeByName = Maps.mutable.ofInitialCapacity(columnMappings.size());
    MutableSet<RelationalOperationElement> columnMappingRootTables = Sets.mutable.empty();
    for (ColumnMapping columnMapping : columnMappings) {
        RelationalOperationElement columnMappingRelationalElement = columnMapping._relationalOperationElement();
        String columnMappingColumnName = columnMapping._columnName();
        RelationalOperationElementProcessor.processColumnExpr(columnMappingRelationalElement, view, null, Sets.mutable.empty(), matcher, processorState, repository, processorSupport);
        RelationalOperationElement columnMappingRootTable = findMainTable(dbsInHierarchy, view, processorSupport, columnMappingRelationalElement);
        if (columnMappingRootTable != null) {
            columnMappingRootTables.add(columnMappingRootTable);
        }
        colMappingTypeByName.put(columnMappingColumnName, getColumnType(columnMappingRelationalElement, processorSupport, repository));
    }
    RelationalOperationElement mainTable = identifyMainTable(view, columnMappingRootTables);
    processDynaFunctionAliases(view, mainTable, processorSupport);
    processFilterMapping(view, null, mainTable, matcher, processorState, repository, processorSupport);
    processGroupByMapping(view, matcher, processorState, repository, mainTable, processorSupport);
    processPrimaryKeys(view, colMappingTypeByName);
    setViewColumnsType(view, colMappingTypeByName);
    setViewMainTableAlias(view, mainTable, processorSupport);
}
Also used : RelationalOperationElement(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.RelationalOperationElement) DataType(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.datatype.DataType) ColumnMapping(org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.ColumnMapping)

Example 2 with ColumnMapping

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

the class DatabaseUnloadUnbind method processView.

private void processView(View view, ModelRepository repository, ProcessorSupport processorSupport) {
    view._schemaRemove();
    this.processTableOrViewColumns(view);
    view._userDefinedPrimaryKeyRemove();
    RelationalMappingSpecificationUnbind.cleanRelationalMappingSpecification(view, repository, processorSupport);
    for (Column column : LazyIterate.concatenate((Iterable<Column>) view._primaryKey(), (Iterable<Column>) view._columns())) {
        column._typeRemove();
    }
    for (ColumnMapping columnMapping : view._columnMappings()) {
        RelationalOperationElement columnMappingRelationalElement = columnMapping._relationalOperationElement();
        RelationalOperationElementUnbind.cleanNode(columnMappingRelationalElement, repository, processorSupport);
    }
}
Also used : Column(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Column) TableAliasColumn(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAliasColumn) RelationalOperationElement(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.RelationalOperationElement) ColumnMapping(org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.ColumnMapping)

Example 3 with ColumnMapping

use of org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.ColumnMapping in project legend-engine by finos.

the class HelperRelationalBuilder method findMainTable.

private static RelationalOperationElement findMainTable(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.View srcView, View view, MutableList<ColumnMapping> columnMappings) {
    MutableSet<RelationalOperationElement> columnMappingRootTables = UnifiedSet.newSet();
    for (ColumnMapping columnMapping : columnMappings) {
        RelationalOperationElement columnMappingRelationalElement = columnMapping._relationalOperationElement();
        RelationalOperationElement columnMappingRootTable = findMainTable(columnMappingRelationalElement);
        if (columnMappingRootTable != null) {
            columnMappingRootTables.add(columnMappingRootTable);
        }
    }
    return identifyMainTable(srcView, view, columnMappingRootTables);
}
Also used : RelationalOperationElement(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.RelationalOperationElement) ColumnMapping(org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.ColumnMapping)

Example 4 with ColumnMapping

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

the class ViewProcessing method populateReferenceUsagesForView.

private static void populateReferenceUsagesForView(View view, ModelRepository repository, ProcessorSupport processorSupport) {
    RichIterable<? extends ColumnMapping> columnMappings = view._columnMappings();
    for (ColumnMapping columnMapping : columnMappings) {
        RelationalOperationElement columnExpression = columnMapping._relationalOperationElement();
        RelationalOperationElementProcessor.populateColumnExpressionReferenceUsages(columnExpression, repository, processorSupport);
    }
    populateFilterMappingReferenceUsages(view, repository, processorSupport);
    populateGroupByMappingReferenceUsages(view, repository, processorSupport);
}
Also used : RelationalOperationElement(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.RelationalOperationElement) ColumnMapping(org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.ColumnMapping)

Example 5 with ColumnMapping

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

the class ViewProcessing method processDynaFunctionAliases.

private static void processDynaFunctionAliases(View view, RelationalOperationElement mainTable, ProcessorSupport processorSupport) {
    RichIterable<? extends ColumnMapping> columnMappings = view._columnMappings();
    columnMappings.forEach(coreInstance -> {
        RelationalOperationElement roe = coreInstance._relationalOperationElement();
        MutableList<JoinTreeNode> joinTreeNodes = Lists.mutable.empty();
        RelationalOperationElementProcessor.collectJoinTreeNodes(joinTreeNodes, roe);
        for (JoinTreeNode joinTreeNode : joinTreeNodes) {
            RelationalOperationElementProcessor.processAliasForJoinTreeNode(joinTreeNode, mainTable, processorSupport);
        }
    });
}
Also used : RelationalOperationElement(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.RelationalOperationElement) JoinTreeNode(org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.join.JoinTreeNode)

Aggregations

RelationalOperationElement (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.RelationalOperationElement)5 ColumnMapping (org.finos.legend.pure.m3.coreinstance.meta.relational.mapping.ColumnMapping)4 Column (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.Column)2 TableAliasColumn (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.TableAliasColumn)2 Root_meta_relational_metamodel_Column_Impl (org.finos.legend.pure.generated.Root_meta_relational_metamodel_Column_Impl)1 Root_meta_relational_metamodel_datatype_Varchar_Impl (org.finos.legend.pure.generated.Root_meta_relational_metamodel_datatype_Varchar_Impl)1 Root_meta_relational_metamodel_relation_View_Impl (org.finos.legend.pure.generated.Root_meta_relational_metamodel_relation_View_Impl)1 DataType (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.datatype.DataType)1 JoinTreeNode (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.join.JoinTreeNode)1 View (org.finos.legend.pure.m3.coreinstance.meta.relational.metamodel.relation.View)1