Package org.jboss.dna.graph.query.model

Examples of org.jboss.dna.graph.query.model.Selector


                                       Source source,
                                       Map<SelectorName, Table> usedSelectors ) {
        if (source instanceof Selector) {
            // No join required ...
            assert source instanceof AllNodes || source instanceof NamedSelector;
            Selector selector = (Selector)source;
            PlanNode node = new PlanNode(Type.SOURCE);
            if (selector.hasAlias()) {
                node.addSelector(selector.getAlias());
                node.setProperty(Property.SOURCE_ALIAS, selector.getAlias());
                node.setProperty(Property.SOURCE_NAME, selector.getName());
            } 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;
        }
        if (source instanceof Join) {
            Join join = (Join)source;
View Full Code Here


            name = selector(parts[0]);
            propertyName = parts[1];
            columnName = parts[1];
        } else {
            if (source instanceof Selector) {
                Selector selector = (Selector)source;
                name = selector.hasAlias() ? selector.getAlias() : selector.getName();
                propertyName = parts[0];
                columnName = parts[0];
            } else {
                throw new IllegalArgumentException(GraphI18n.columnMustBeScoped.text(parts[0]));
            }
View Full Code Here

     *
     * @param tableNameWithOptionalAlias the name of the table, optionally including the alias
     * @return this builder object, for convenience in method chaining
     */
    public QueryBuilder from( String tableNameWithOptionalAlias ) {
        Selector selector = namedSelector(tableNameWithOptionalAlias);
        SelectorName oldName = this.source instanceof Selector ? ((Selector)source).getName() : null;
        // Go through the columns and change the selector name to use the new alias ...
        for (int i = 0; i != columns.size(); ++i) {
            Column old = columns.get(i);
            if (old.getSelectorName().equals(oldName)) {
                columns.set(i, new Column(selector.getAliasOrName(), old.getPropertyName(), old.getColumnName()));
            }
        }
        this.source = selector;
        return this;
    }
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.query.model.Selector

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.