Package org.modeshape.jcr.query.model

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


        assert operand != null;
        assert context != null;
        assert columns != null;
        assert sources != null;
        if (operand instanceof PropertyValue) {
            PropertyValue propValue = (PropertyValue)operand;
            String propertyName = propValue.getPropertyName();
            String selectorName = propValue.selectorName().name();
            return createExtractFromRow(selectorName, propertyName, context, columns, sources, defaultType, allowMultiValued);
        }
        if (operand instanceof ReferenceValue) {
            ReferenceValue refValue = (ReferenceValue)operand;
            String propertyName = refValue.getPropertyName();
            String selectorName = refValue.selectorName().name();
            if (propertyName == null) {
                return createExtractReferencesFromRow(selectorName, context, columns, sources, defaultType);
            }
            return createExtractFromRow(selectorName, propertyName, context, columns, sources, defaultType, allowMultiValued);
        }
        if (operand instanceof Length) {
            Length length = (Length)operand;
            final PropertyValue value = length.getPropertyValue();
            String propertyName = value.getPropertyName();
            String selectorName = value.selectorName().name();
            final ExtractFromRow getPropValue = createExtractFromRow(selectorName, propertyName, context, columns, sources,
                                                                     defaultType, allowMultiValued);
            final TypeFactory<?> longType = context.getTypeSystem().getLongFactory();
            return new ExtractFromRow() {
                @Override
View Full Code Here


            if (replacement == null) return score;
            return new FullTextSearchScore(replacement);
        }
        if (operand instanceof Length) {
            Length operation = (Length)operand;
            PropertyValue wrapped = operation.getPropertyValue();
            SelectorName replacement = rewrittenSelectors.get(wrapped.selectorName());
            if (replacement == null) return operand;
            return new Length(new PropertyValue(replacement, wrapped.getPropertyName()));
        }
        if (operand instanceof LowerCase) {
            LowerCase operation = (LowerCase)operand;
            SelectorName replacement = rewrittenSelectors.get(operation.selectorName());
            if (replacement == null) return operand;
            return new LowerCase(replaceReferencesToRemovedSource(context, operation.getOperand(), rewrittenSelectors));
        }
        if (operand instanceof UpperCase) {
            UpperCase operation = (UpperCase)operand;
            SelectorName replacement = rewrittenSelectors.get(operation.selectorName());
            if (replacement == null) return operand;
            return new UpperCase(replaceReferencesToRemovedSource(context, operation.getOperand(), rewrittenSelectors));
        }
        if (operand instanceof NodeName) {
            NodeName name = (NodeName)operand;
            SelectorName replacement = rewrittenSelectors.get(name.selectorName());
            if (replacement == null) return name;
            return new NodeName(replacement);
        }
        if (operand instanceof NodeLocalName) {
            NodeLocalName name = (NodeLocalName)operand;
            SelectorName replacement = rewrittenSelectors.get(name.selectorName());
            if (replacement == null) return name;
            return new NodeLocalName(replacement);
        }
        if (operand instanceof PropertyValue) {
            PropertyValue value = (PropertyValue)operand;
            SelectorName replacement = rewrittenSelectors.get(value.selectorName());
            if (replacement == null) return operand;
            return new PropertyValue(replacement, value.getPropertyName());
        }
        if (operand instanceof ReferenceValue) {
            ReferenceValue value = (ReferenceValue)operand;
            SelectorName replacement = rewrittenSelectors.get(value.selectorName());
            if (replacement == null) return operand;
            return new ReferenceValue(replacement, value.getPropertyName());
        }
        if (operand instanceof NodeDepth) {
            NodeDepth depth = (NodeDepth)operand;
            SelectorName replacement = rewrittenSelectors.get(depth.selectorName());
            if (replacement == null) return operand;
View Full Code Here

            if (!mapping.isMappedToSingleSelector()) return name;
            node.addSelector(mapping.getSingleMappedSelectorName());
            return new NodeLocalName(mapping.getSingleMappedSelectorName());
        }
        if (operand instanceof PropertyValue) {
            PropertyValue value = (PropertyValue)operand;
            if (!mapping.getOriginalName().equals(value.selectorName())) return value;
            Column sourceColumn = mapping.getMappedColumn(value.getPropertyName());
            if (sourceColumn == null) {
                if (mapping.getMappedSelectorNames().size() == 1) {
                    SelectorName newSelectorName = mapping.getSingleMappedSelectorName();
                    if (newSelectorName != null) {
                        node.addSelector(newSelectorName);
                        return new PropertyValue(newSelectorName, value.getPropertyName());
                    }
                }
                return value;
            }
            node.addSelector(sourceColumn.selectorName());
            return new PropertyValue(sourceColumn.selectorName(), sourceColumn.getPropertyName());
        }
        if (operand instanceof ReferenceValue) {
            ReferenceValue value = (ReferenceValue)operand;
            if (!mapping.getOriginalName().equals(value.selectorName())) return value;
            Column sourceColumn = mapping.getMappedColumn(value.getPropertyName());
            if (sourceColumn == null) return value;
            node.addSelector(sourceColumn.selectorName());
            return new ReferenceValue(sourceColumn.selectorName(), sourceColumn.getPropertyName());
        }
        if (operand instanceof NodeDepth) {
View Full Code Here

            return new Comparison(lhs, comparison.operator(), comparison.getOperand2());
        }
        if (constraint instanceof Relike) {
            Relike relike = (Relike)constraint;
            StaticOperand op1 = relike.getOperand1();
            PropertyValue op2 = relike.getOperand2();
            PropertyValue newOp2 = replaceAliasesWithProperties(context, op2, propertyByAlias);
            if (op2 == newOp2) return relike;
            return new Relike(op1, op2);
        }
        if (constraint instanceof SetCriteria) {
            SetCriteria criteria = (SetCriteria)constraint;
View Full Code Here

    protected static PropertyValue replaceAliasesWithProperties( QueryContext context,
                                                                 PropertyValue value,
                                                                 Map<String, String> propertyByAlias ) {
        String original = value.getPropertyName();
        String propName = propertyByAlias.get(original);
        return propName != null ? new PropertyValue(value.selectorName(), propName) : value;
    }
View Full Code Here

        if (operand instanceof FullTextSearchScore) {
            return operand;
        }
        if (operand instanceof Length) {
            Length operation = (Length)operand;
            PropertyValue value = operation.getPropertyValue();
            PropertyValue newValue = replaceAliasesWithProperties(context, value, propertyByAlias);
            if (newValue == value) return operation;
            return new Length(newValue);
        }
        if (operand instanceof LowerCase) {
            LowerCase operation = (LowerCase)operand;
            DynamicOperand oldOperand = operation.getOperand();
            DynamicOperand newOperand = replaceAliasesWithProperties(context, oldOperand, propertyByAlias);
            if (oldOperand == newOperand) return operation;
            return new LowerCase(newOperand);
        }
        if (operand instanceof UpperCase) {
            UpperCase operation = (UpperCase)operand;
            DynamicOperand oldOperand = operation.getOperand();
            DynamicOperand newOperand = replaceAliasesWithProperties(context, oldOperand, propertyByAlias);
            if (oldOperand == newOperand) return operation;
            return new UpperCase(newOperand);
        }
        if (operand instanceof NodeName) {
            return operand;
        }
        if (operand instanceof NodeLocalName) {
            return operand;
        }
        if (operand instanceof PropertyValue) {
            PropertyValue value = (PropertyValue)operand;
            return replaceAliasesWithProperties(context, value, propertyByAlias);
        }
        if (operand instanceof ReferenceValue) {
            ReferenceValue value = (ReferenceValue)operand;
            String original = value.getPropertyName();
            String propName = propertyByAlias.get(original);
            if (propName == null) return value;
            return new ReferenceValue(value.selectorName(), propName);
        }
        if (operand instanceof NodeDepth) {
            return operand;
        }
        if (operand instanceof NodePath) {
View Full Code Here

            return new Comparison(lhs, comparison.operator(), newRhs);
        }
        if (constraint instanceof Relike) {
            Relike relike = (Relike)constraint;
            StaticOperand op1 = relike.getOperand1();
            PropertyValue op2 = relike.getOperand2();
            StaticOperand newOp1 = replaceSubqueriesWithBindVariables(context, op1, subqueriesByVariableName);
            if (op1 == newOp1) return relike;
            return new Relike(op1, op2);
        }
        if (constraint instanceof SetCriteria) {
View Full Code Here

    }

    protected DynamicOperand rewrite( QueryContext context,
                                      DynamicOperand operand ) {
        if (operand instanceof PropertyValue) {
            PropertyValue propValue = (PropertyValue)operand;
            String property = propValue.getPropertyName();
            if ("jcr:path".equals(property)) {
                return new NodePath(propValue.selectorName());
            }
            if ("jcr:name".equals(property)) {
                return new NodeName(propValue.selectorName());
            }
            if ("mode:localName".equals(property) || "jcr:localName".equals(property)) {
                return new NodeLocalName(propValue.selectorName());
            }
            if ("mode:depth".equals(property) || "jcr:depth".equals(property)) {
                return new NodeDepth(propValue.selectorName());
            }
            if ("mode:id".equals(property)) {
                return new NodeId(propValue.selectorName());
            }
            if ("jcr:score".equals(property)) {
                return new FullTextSearchScore(propValue.selectorName());
            }
        }
        return operand;
    }
View Full Code Here

            return typeFactory;
        }

        @Override
        public String toString() {
            return "(" + Visitors.readable(new PropertyValue(new SelectorName(selectorName), propertyName)) + ")";
        }
View Full Code Here

                            calculator.addIndex(NODE_BY_ID_INDEX_NAME, null, null, singletonList(constraint), 1, 1L, -1.0f,
                                                ID_PARAMETER, id);
                        }
                    }
                    if (leftSide instanceof PropertyValue) {
                        PropertyValue propValue = (PropertyValue)leftSide;
                        if ("jcr:uuid".equals(propValue.getPropertyName()) || "mode:id".equals(propValue.getPropertyName())) {
                            // This is a constraint on the ID of a node ...
                            StaticOperand rightSide = comparison.getOperand2();
                            String id = stringValue(rightSide, context);
                            if (id != null) {
                                calculator.addIndex(NODE_BY_ID_INDEX_NAME, null, null, singletonList(constraint), 1, 1L, -1.0f,
                                                    ID_PARAMETER, id);
                            }
                        } else if ("jcr:path".equals(propValue.getPropertyName())) {
                            // This is a constraint on the PATH of a node ...
                            StaticOperand rightSide = comparison.getOperand2();
                            String path = stringValue(rightSide, context);
                            if (path != null) {
                                calculator.addIndex(NODE_BY_PATH_INDEX_NAME, null, null, singletonList(constraint), 1, 1L, -1.0f,
View Full Code Here

TOP

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

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.