Package org.modeshape.jcr.query.model

Examples of org.modeshape.jcr.query.model.Column


            String columnName = column.getName();
            String propertyName = columnName;
            if (includeSelectorNameInColumnName) {
                columnName = tableName.getString() + "." + columnName;
            }
            Column newColumn = new Column(tableName, propertyName, columnName);
            if (!columns.contains(column)) {
                columns.add(newColumn);
                columnTypes.add(column.getPropertyTypeName());
            }
        }
View Full Code Here


        if (selectNode.getSelectors().size() != 1 || !selectNode.getSelectors().contains(selectorName)) return null;

        Constraint constraint = selectNode.getProperty(Property.SELECT_CRITERIA, Constraint.class);
        Set<Column> columns = getColumnsReferencedBy(constraint);
        if (columns.size() != 1) return null;
        Column column = columns.iterator().next();
        if (!column.selectorName().equals(selectorName)) return null;
        if (!column.getPropertyName().equals(propertyName)) return null;

        // We know that this constraint ONLY applies to the referenced selector and property,
        // so we will duplicate this constraint ...

        // Create the new node ...
        PlanNode copy = new PlanNode(Type.SELECT, copySelectorName);

        // Copy the constraint, but change the references to the copy selector and property ...
        PlanUtil.ColumnMapping mappings = new PlanUtil.ColumnMapping(selectorName);
        mappings.map(propertyName, new Column(copySelectorName, copyPropertyName, copyPropertyName));
        Constraint newCriteria = PlanUtil.replaceReferences(context, constraint, mappings, copy);
        copy.setProperty(Property.SELECT_CRITERIA, newCriteria);

        return copy;
    }
View Full Code Here

        final Set<Column> symbols = new HashSet<Column>();
        // Walk the entire structure, so only supply a StrategyVisitor (that does no navigation) ...
        Visitors.visitAll(visitable, new AbstractVisitor() {
            protected void addColumnFor( SelectorName selectorName,
                                         String property ) {
                symbols.add(new Column(selectorName, property, property));
            }

            @Override
            public void visit( Column column ) {
                symbols.add(column);
View Full Code Here

        // Go through the columns and make sure that the property names and types match ...
        // (we can't just check column names, since the column names may include the selector if more than one selector)
        int numColumns = results1.getColumns().size();
        boolean noProblems = true;
        for (int i = 0; i != numColumns; ++i) {
            Column thisColumn = results1.getColumns().get(i);
            Column thatColumn = results2.getColumns().get(i);
            if (!thisColumn.getPropertyName().equalsIgnoreCase(thatColumn.getPropertyName())) return false;
            String thisType = results1.getColumnTypeForProperty(thisColumn.getSelectorName(), thisColumn.getPropertyName());
            String thatType = results2.getColumnTypeForProperty(thatColumn.getSelectorName(), thatColumn.getPropertyName());
            if (!thisType.equalsIgnoreCase(thatType)) {
                // The query is not compatible
                context.getProblems().addError(JcrI18n.setQueryContainsResultSetsWithDifferentColumns, thisColumn, thatColumn);
                noProblems = false;
            }
View Full Code Here

            List<Schemata.Column> schemataColumns = source.getPropertyAsList(Property.SOURCE_COLUMNS, Schemata.Column.class);
            List<Column> columns = new ArrayList<>(schemataColumns.size());
            List<String> columnTypes = new ArrayList<>(schemataColumns.size());
            SelectorName selector = source.getSelectors().iterator().next();
            for (Schemata.Column schemataColumn : schemataColumns) {
                Column column = new Column(selector, schemataColumn.getName(), schemataColumn.getName());
                columns.add(column);
                columnTypes.add(schemataColumn.getPropertyTypeName());
            }
            return new ResultColumns(columns, columnTypes, hints.hasFullTextSearch, null);
        }
View Full Code Here

                Columns indepColumns = context.columnsFor(indepPlan);
                String variableName = indepPlan.getProperty(Property.VARIABLE_NAME, String.class);
                NodeSequence independent = createNodeSequence(originalQuery, context, indepPlan, indepColumns, sources);

                // Create an extractor to get the value specified in the columns ...
                Column column = indepColumns.getColumns().get(0);
                boolean allowMultiValued = false;
                String typeName = indepColumns.getColumnTypeForProperty(column.getSelectorName(), column.getPropertyName());
                TypeFactory<?> type = context.getTypeSystem().getTypeFactory(typeName);
                ExtractFromRow indepExtractor = createExtractFromRow(column.getSelectorName(), column.getPropertyName(), context,
                                                                     indepColumns, sources, type, allowMultiValued);
                // Create the sequence for the dependent query ...
                PlanNode depPlan = plan.getLastChild();
                Columns depColumns = context.columnsFor(depPlan);
                NodeSequence dependent = createNodeSequence(originalQuery, context, depPlan, depColumns, sources);
View Full Code Here

            Set<Column> sameNameColumns = findColumnsWithSameNames(this.columns);

            // Find all the selector names ...
            int selectorIndex = 0;
            for (int i = 0, max = this.columns.size(); i != max; ++i) {
                Column column = this.columns.get(i);
                assert column != null;
                String selectorName = column.selectorName().name();
                if (selectors.add(selectorName)) {
                    selectorNames.add(selectorName);
                    int index = selectorIndex;
                    if (precedingColumns != null) {
                        index = precedingColumns.getSelectorIndex(selectorName);
                        if (index < 0) index = selectorIndex;
                    }
                    selectorIndexBySelectorName.put(selectorName, index);
                    ++selectorIndex;
                }
            }

            // Now, find all of the column names ...
            for (int i = 0, max = this.columns.size(); i != max; ++i) {
                Column column = this.columns.get(i);
                assert column != null;
                String selectorName = column.selectorName().name();
                String columnName = columnNameFor(column, names, sameNameColumns, selectors);
                assert columnName != null;
                propertyNameByColumnName.put(columnName, column.getPropertyName());
                selectorNameByColumnName.put(columnName, selectorName);
                // Insert the entry by selector name and property name ...
                Map<String, ColumnInfo> byPropertyName = columnIndexByPropertyNameBySelectorName.get(selectorName);
                if (byPropertyName == null) {
                    byPropertyName = new HashMap<String, ColumnInfo>();
                    columnIndexByPropertyNameBySelectorName.put(selectorName, byPropertyName);
                }
                String columnType = this.columnTypes.get(i);
                byPropertyName.put(column.getPropertyName(), new ColumnInfo(i, columnType));
            }
            if (columns != null && selectorNames.isEmpty()) {
                String selectorName = DEFAULT_SELECTOR_NAME;
                selectorNames.add(selectorName);
                selectorIndexBySelectorName.put(selectorName, 0);
View Full Code Here

            StringBuilder sb = new StringBuilder();
            sb.append("{ ").append("\n");
            if (this.columnNames != null) {
                boolean first = true;
                for (int i = 0; i != columns.size(); ++i) {
                    Column column = columns.get(i);
                    String type = columnTypes.get(i);
                    if (first) first = false;
                    else sb.append(", ").append("\n");
                    sb.append(Visitors.readable(column)).append("{").append(type.toUpperCase()).append("}");
                }
View Full Code Here

                for (PlanNode project : projects) {
                    List<Column> projectedColumns = project.getPropertyAsList(Property.PROJECT_COLUMNS, Column.class);
                    List<String> projectedTypes = project.getPropertyAsList(Property.PROJECT_COLUMN_TYPES, String.class);
                    if (projectedTypes == null) continue;
                    for (int i = 0; i != projectedColumns.size(); ++i) {
                        Column projectedColumn = projectedColumns.get(i);
                        if (column.equals(projectedColumn)) {
                            types.add(projectedTypes.get(i));
                            added = true;
                            break;
                        }
View Full Code Here

                                                         Map<SelectorName, SelectorName> rewrittenSelectors ) {
        switch (planNode.getType()) {
            case PROJECT:
                List<Column> columns = planNode.getPropertyAsList(Property.PROJECT_COLUMNS, Column.class);
                for (int i = 0; i != columns.size(); ++i) {
                    Column column = columns.get(i);
                    SelectorName replacement = rewrittenSelectors.get(column.selectorName());
                    if (replacement != null) {
                        columns.set(i, new Column(replacement, column.getPropertyName(), column.getColumnName()));
                    }
                }
                break;
            case SELECT:
                Constraint constraint = planNode.getProperty(Property.SELECT_CRITERIA, Constraint.class);
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.query.model.Column

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.