- .literal(session.getValueFactory().createValue(comp.getValue().toString()));
- qomConstraint = factory.comparison(dynamicOperand, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,
- staticOperand);
+ .literal(JcrContent.convertSingleObject(session.getValueFactory(), comp.getValue()));
+ javax.jcr.query.qom.Constraint res;
+ if (comp instanceof Eq)
+ res = factory.comparison(dynamicOperand, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO,
+ staticOperand);
+ else if (comp instanceof Lt)
+ res = factory.comparison(dynamicOperand, QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN,
+ staticOperand);
+ else if (comp instanceof Lte)
+ res = factory.comparison(dynamicOperand, QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO,
+ staticOperand);
+ else if (comp instanceof Gt)
+ res = factory.comparison(dynamicOperand, QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN,
+ staticOperand);
+ else if (comp instanceof Gte)
+ res = factory.comparison(dynamicOperand,
+ QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO, staticOperand);
+ else if (comp instanceof Like)
+ res = factory.comparison(dynamicOperand, QueryObjectModelConstants.JCR_OPERATOR_LIKE, staticOperand);
+ else
+ throw new UnsupportedOperationException("Constraint of type " + comp.getClass() + " is not supported");
+ return res;