Package org.jboss.dna.graph.query.validate.Schemata

Examples of org.jboss.dna.graph.query.validate.Schemata.Table


            // Resolve the node to find the definition in the schemata ...
            SelectorName tableName = sourceNode.getProperty(Property.SOURCE_NAME, SelectorName.class);
            SelectorName tableAlias = sourceNode.getProperty(Property.SOURCE_ALIAS, SelectorName.class);
            if (tableAlias != null) {
                Table table = schemata.getTable(tableName);
                // We also need to replace references to the alias for the view ...
                PlanUtil.ColumnMapping aliasMappings = PlanUtil.createMappingForAliased(tableAlias, table, sourceNode);
                // Adjust the plan nodes above the SOURCE node ...
                PlanUtil.replaceViewReferences(context, sourceNode.getParent(), aliasMappings);
                // And adjust the SOURCE node ...
View Full Code Here


                if (!leftTableName.equals(rightTableName)) {
                    // The join is not joining the same table, so this doesn't meet the condition ...
                    continue;
                }
                // Find the schemata columns referenced by the join condition ...
                Table table = schemata.getTable(leftTableName);
                if (table == null) {
                    context.getProblems().addError(GraphI18n.tableDoesNotExist, leftTableName);
                    continue;
                }
                String leftColumnName = equiJoin.getProperty1Name();
                String rightColumnName = equiJoin.getProperty2Name();
                Schemata.Column leftColumn = table.getColumn(leftColumnName);
                Schemata.Column rightColumn = table.getColumn(rightColumnName);
                if (leftColumn == null) {
                    context.getProblems().addError(GraphI18n.columnDoesNotExistOnTable, leftColumnName, leftTableName);
                    continue;
                }
                if (rightColumn == null) {
                    context.getProblems().addError(GraphI18n.columnDoesNotExistOnTable, rightColumnName, leftTableName);
                    continue;
                }
                // Are the join columns (on both sides) keys?
                if (table.hasKey(leftColumn) && (rightColumn == leftColumn || table.hasKey(rightColumn))) {
                    // It meets all the criteria, so rewrite this join node ...
                    if (rewrittenSelectors == null) rewrittenSelectors = new HashMap<SelectorName, SelectorName>();
                    rewriteJoinNode(context, joinNode, rewrittenSelectors);
                    ++rewrittenJoins;
                }
View Full Code Here

                processedSources.add(sourceNode);

                // Resolve the node to find the definition in the schemata ...
                SelectorName tableName = sourceNode.getProperty(Property.SOURCE_NAME, SelectorName.class);
                SelectorName tableAlias = sourceNode.getProperty(Property.SOURCE_ALIAS, SelectorName.class);
                Table table = schemata.getTable(tableName);
                if (table instanceof View) {
                    View view = (View)table;
                    PlanNode viewPlan = viewPlanCache.get(tableName);
                    if (viewPlan == null) {
                        viewPlan = planner.createPlan(context, view.getDefinition());
View Full Code Here

            } else {
                node.addSelector(selector.getName());
                node.setProperty(Property.SOURCE_NAME, selector.getName());
            }
            // Validate the source name and set the available columns ...
            Table table = context.getSchemata().getTable(selector.getName());
            if (table != null) {
                if (table instanceof View) context.getHints().hasView = true;
                if (usedSelectors.put(selector.getAliasOrName(), table) != null) {
                    // There was already a table with this alias or name ...
                }
                node.setProperty(Property.SOURCE_COLUMNS, table.getColumns());
            } else {
                context.getProblems().addError(GraphI18n.tableDoesNotExist, selector.getName());
            }
            return node;
        }
View Full Code Here

        if (columns.isEmpty()) {
            columns = new LinkedList<Column>();
            // SELECT *, so find all of the columns that are available from all the sources ...
            for (Map.Entry<SelectorName, Table> entry : selectors.entrySet()) {
                SelectorName tableName = entry.getKey();
                Table table = entry.getValue();
                // Add the selector that is being used ...
                projectNode.addSelector(tableName);
                // Compute the columns from this selector ...
                for (Schemata.Column column : table.getColumns()) {
                    String columnName = column.getName();
                    String propertyName = columnName;
                    columns.add(new Column(tableName, propertyName, columnName));
                }
            }
        } else {
            // Add the selector used by each column ...
            for (Column column : columns) {
                SelectorName tableName = column.getSelectorName();
                // Add the selector that is being used ...
                projectNode.addSelector(tableName);

                // Verify that each column is available in the appropriate source ...
                Table table = selectors.get(tableName);
                if (table == null) {
                    context.getProblems().addError(GraphI18n.tableDoesNotExist, tableName);
                } else {
                    // Make sure that the column is in the table ...
                    String columnName = column.getPropertyName();
                    String name = columnName;
                    if (table.getColumn(name) == null) {
                        context.getProblems().addError(GraphI18n.columnDoesNotExistOnTable, name, tableName);
                    }
                }
            }
        }
View Full Code Here

                if (!column.isFullTextSearchable()) {
                    problems.addError(GraphI18n.columnIsNotFullTextSearchable, column.getName(), selectorName);
                }
            }
        } else {
            Table table = verify(selectorName);
            if (table != null) {
                // Make sure there is at least one column on the table that is full-text searchable ...
                boolean searchable = false;
                for (Schemata.Column column : table.getColumns()) {
                    if (column.isFullTextSearchable()) {
                        searchable = true;
                        break;
                    }
                }
View Full Code Here

    public void visit( Query obj ) {
        // Collect the map of columns by alias for this query ...
        this.columnsByAlias.clear();
        for (Column column : obj.getColumns()) {
            // Find the schemata column ...
            Table table = tableWithNameOrAlias(column.getSelectorName());
            if (table != null) {
                Schemata.Column tableColumn = table.getColumn(column.getPropertyName());
                if (tableColumn != null) {
                    this.columnsByAlias.put(column.getColumnName(), tableColumn);
                }
            }
        }
View Full Code Here

        verify(obj.getSelector1Name());
        verify(obj.getSelector2Name());
    }

    protected Table tableWithNameOrAlias( SelectorName tableName ) {
        Table table = selectorsByNameOrAlias.get(tableName);
        if (table == null) {
            // Try looking up the table by it's real name (if an alias were used) ...
            table = selectorsByName.get(tableName);
        }
        return table;
View Full Code Here

        }
        return table;
    }

    protected Table verify( SelectorName selectorName ) {
        Table table = tableWithNameOrAlias(selectorName);
        if (table == null) {
            problems.addError(GraphI18n.tableDoesNotExist, selectorName.getName());
        }
        return table;
    }
View Full Code Here

        }
        return table;
    }

    protected Table verifyTable( SelectorName tableName ) {
        Table table = tableWithNameOrAlias(tableName);
        if (table == null) {
            problems.addError(GraphI18n.tableDoesNotExist, tableName.getName());
        }
        return table;
    }
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.query.validate.Schemata.Table

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.