@Override public String apply(PropertyValue operand, Map<String, Object> variables) { return operand.getPropertyName(); } };
/** * Returns the identified property from the given node. * * Can return <code>null</code> is the property doesn't exist or it is not * accessible. * * @param operand * @param node * @return identified property * @throws RepositoryException */ private Property getProperty(PropertyValue operand, Node node) throws RepositoryException { if (node == null) { return null; } try { return node.getProperty(operand.getPropertyName()); } catch (PathNotFoundException e) { return null; } } }
/** * Returns the identified property from the given node. * * Can return <code>null</code> is the property doesn't exist or it is not * accessible. * * @param operand * @param node * @return identified property * @throws RepositoryException */ private Property getProperty(PropertyValue operand, Node node) throws RepositoryException { if (node == null) { return null; } try { return node.getProperty(operand.getPropertyName()); } catch (PathNotFoundException e) { return null; } } }
/** * Returns the identified property from the given node. * * Can return <code>null</code> is the property doesn't exist or it is not * accessible. * * @param operand * @param node * @return identified property * @throws RepositoryException */ private Property getProperty(PropertyValue operand, Node node) throws RepositoryException { if (node == null) { return null; } try { return node.getProperty(operand.getPropertyName()); } catch (PathNotFoundException e) { return null; } } }
private boolean isPrimaryTypeConstraint( DynamicOperand operand ) { if (operand instanceof PropertyValue) { PropertyValue propValue = (PropertyValue)operand; if (propValue.getSelectorName().equals(selectorName.getString())) { // The property value matches our selector name, so this might be a constraint on the // primary type or mixin types. If so, then the selector name is an alias ... String propName = propValue.getPropertyName(); return "jcr:primaryType".equals(propName) || "jcr:mixinTypes".equals(propName); } } return false; }
private boolean isPrimaryTypeConstraint( DynamicOperand operand ) { if (operand instanceof PropertyValue) { PropertyValue propValue = (PropertyValue)operand; if (propValue.getSelectorName().equals(selectorName.getString())) { // The property value matches our selector name, so this might be a constraint on the // primary type or mixin types. If so, then the selector name is an alias ... String propName = propValue.getPropertyName(); return "jcr:primaryType".equals(propName) || "jcr:mixinTypes".equals(propName); } } return false; }
private PropertyExistence getPropertyExistence(PropertyValue p) throws InvalidQueryException, RepositoryException { return factory.propertyExistence(p.getSelectorName(), p.getPropertyName()); }
private PropertyExistence getPropertyExistence(PropertyValue p) throws InvalidQueryException, RepositoryException { return factory.propertyExistence(p.getSelectorName(), p.getPropertyName()); }
private PropertyExistence getPropertyExistence(PropertyValue p) throws InvalidQueryException, RepositoryException { return factory.propertyExistence(p.getSelectorName(), p.getPropertyName()); }
private void append(PropertyValue operand) { appendName(operand.getSelectorName()); append("."); appendName(operand.getPropertyName()); }
private void append(PropertyValue operand) { appendName(operand.getSelectorName()); append("."); appendName(operand.getPropertyName()); }
private void append(PropertyValue operand) { appendName(operand.getSelectorName()); append("."); appendName(operand.getPropertyName()); }
/** * Test case for {@link QueryObjectModelFactory#propertyValue(String, String)} */ public void testPropertyValueWithSelector() throws RepositoryException { PropertyValue propVal = qf.propertyValue(SELECTOR_NAME1, propertyName1); assertEquals("Wrong selector name", SELECTOR_NAME1, propVal.getSelectorName()); assertEquals("Wrong property name", propertyName1, propVal.getPropertyName()); }
/** * Test case for {@link QueryObjectModelFactory#propertyValue(String, String)} */ public void testPropertyValue() throws RepositoryException { PropertyValue propVal = qf.propertyValue(SELECTOR_NAME1, propertyName1); assertEquals("Wrong selector name", SELECTOR_NAME1, propVal.getSelectorName()); assertEquals("Wrong property name", propertyName1, propVal.getPropertyName()); }
protected Query getComparisonQuery( DynamicOperand left, int transform, String operator, StaticOperand rigth, Map<String, NodeType> selectorMap) throws RepositoryException { if (left instanceof PropertyValue) { PropertyValue pv = (PropertyValue) left; String field = npResolver.getJCRName(session.getQName( pv.getPropertyName())); int type = PropertyType.UNDEFINED; NodeType nt = selectorMap.get(pv.getSelectorName()); if (nt != null) { for (PropertyDefinition pd : nt.getPropertyDefinitions()) { if (pd.getName().equals(pv.getPropertyName())) { type = pd.getRequiredType(); break; } } } return getPropertyValueQuery( field, operator, evaluator.getValue(rigth), type, transform); } else if (left instanceof NodeName) { return getNodeNameQuery(transform, operator, rigth); } else if (left instanceof NodeLocalName) { return getNodeLocalNameQuery(transform, operator, rigth); } else { throw new UnsupportedRepositoryOperationException( "Unknown operand type: " + left); // FIXME } }
protected Query getComparisonQuery( DynamicOperand left, int transform, String operator, StaticOperand rigth, Map<String, NodeType> selectorMap) throws RepositoryException { if (left instanceof PropertyValue) { PropertyValue pv = (PropertyValue) left; String field = npResolver.getJCRName(session.getQName( pv.getPropertyName())); int type = PropertyType.UNDEFINED; NodeType nt = selectorMap.get(pv.getSelectorName()); if (nt != null) { for (PropertyDefinition pd : nt.getPropertyDefinitions()) { if (pd.getName().equals(pv.getPropertyName())) { type = pd.getRequiredType(); break; } } } return getPropertyValueQuery( field, operator, evaluator.getValue(rigth), type, transform); } else if (left instanceof NodeName) { return getNodeNameQuery(transform, operator, rigth); } else if (left instanceof NodeLocalName) { return getNodeLocalNameQuery(transform, operator, rigth); } else { throw new UnsupportedRepositoryOperationException( "Unknown operand type: " + left); // FIXME } }
String propName = ((PropertyValue) operand1).getPropertyName(); dynamicOperandValues = QOMUtil.getPropertyValueFromName(propName, node); if(dynamicOperandValues == null) { scalarOperandValue = valueFactory.createValue(((BindVariableValue) operand2).getBindVariableName()); } else if (operand2 instanceof PropertyValue) { String propName = ((PropertyValue) operand2).getPropertyName(); scalarOperandValue = QOMUtil.getPropertyValueFromName(propName, node)[0];
@Test public void propertyValue() throws RepositoryException { PropertyValue pv = f.propertyValue("selectorName", "propertyName"); assertEquals("selectorName", pv.getSelectorName()); assertEquals("propertyName", pv.getPropertyName()); assertEquals("[selectorName].[propertyName]", pv.toString()); assertEquals("*", f.propertyValue(null, null).toString()); assertEquals("[s].*", f.propertyValue("s", null).toString()); assertEquals("[p]", f.propertyValue(null, "p").toString()); assertEquals("[s].[p]", f.propertyValue("s", "p").toString()); }