@Test public void testVisitProperty() throws Exception { Value v = getValueFactory(root).createValue(SERACH_EXPR); for (RelationOp op : RelationOp.values()) { if (op == RelationOp.EX || op == RelationOp.LIKE) { continue; } visitor.visit(new Condition.PropertyValue(REL_PATH, op, v)); String s = statement.toString(); String expected = QueryUtils.escapeForQuery(REL_PATH) + op.getOp() + QueryUtil.format(v); assertEquals(expected, s); statement.delete(0, statement.length()); } }
@Override public void visit(@NotNull Condition.Node condition) { statement.append('(') .append("jcr:like(@") .append(QueryUtil.escapeForQuery(UserConstants.REP_AUTHORIZABLE_ID, namePathMapper)) .append(",'") .append(QueryUtil.escapeForQuery(condition.getPattern())) .append("')") .append(" or ") .append("jcr:like(@") .append(QueryUtil.escapeForQuery(UserConstants.REP_PRINCIPAL_NAME, namePathMapper)) .append(",'") .append(QueryUtil.escapeForQuery(condition.getPattern())) .append("')") .append(" or ") .append("jcr:like(fn:name(),'") .append(QueryUtil.escapeForQuery(QueryUtil.escapeNodeName(condition.getPattern()))) .append("')") .append(')'); }
XPathConditionVisitor implements ConditionVisitor { @Override public void visit(@NotNull Condition.Node condition) { statement.append('(') .append("jcr:like(@") .append(QueryUtil.escapeForQuery(UserConstants.REP_AUTHORIZABLE_ID, namePathMapper)) .append(",'") .append(QueryUtil.escapeForQuery(condition.getPattern())) .append("')") .append(" or ") .append("jcr:like(@") .append(QueryUtil.escapeForQuery(UserConstants.REP_PRINCIPAL_NAME, namePathMapper)) .append(",'") .append(QueryUtil.escapeForQuery(condition.getPattern())) .append("')") .append(" or ") .append("jcr:like(fn:name(),'") .append(QueryUtil.escapeForQuery(QueryUtil.escapeNodeName(condition.getPattern()))) .append("')") .append(')'); } }
XPathConditionVisitor implements ConditionVisitor { @Override public void visit(@NotNull Condition.Node condition) { statement.append('(') .append("jcr:like(@") .append(QueryUtil.escapeForQuery(UserConstants.REP_AUTHORIZABLE_ID, namePathMapper)) .append(",'") .append(QueryUtil.escapeForQuery(condition.getPattern())) .append("')") .append(" or ") .append("jcr:like(@") .append(QueryUtil.escapeForQuery(UserConstants.REP_PRINCIPAL_NAME, namePathMapper)) .append(",'") .append(QueryUtil.escapeForQuery(condition.getPattern())) .append("')") .append(" or ") .append("jcr:like(fn:name(),'") .append(QueryUtil.escapeForQuery(QueryUtil.escapeNodeName(condition.getPattern()))) .append("')") .append(')'); } XPathConditionVisitor(@NotNull StringBuilder statement, @NotNull NamePathMapper namePathMapper,
                          @NotNull UserManager userMgr); }
XPathConditionVisitor implements ConditionVisitor { @Override public void visit(@NotNull Condition.Node condition) { statement.append('(') .append("jcr:like(@") .append(QueryUtil.escapeForQuery(UserConstants.REP_AUTHORIZABLE_ID, namePathMapper)) .append(",'") .append(QueryUtil.escapeForQuery(condition.getPattern())) .append("')") .append(" or ") .append("jcr:like(@") .append(QueryUtil.escapeForQuery(UserConstants.REP_PRINCIPAL_NAME, namePathMapper)) .append(",'") .append(QueryUtil.escapeForQuery(condition.getPattern())) .append("')") .append(" or ") .append("jcr:like(fn:name(),'") .append(QueryUtil.escapeForQuery(QueryUtil.escapeNodeName(condition.getPattern()))) .append("')") .append(')'); } XPathConditionVisitor(@NotNull StringBuilder statement, @NotNull NamePathMapper namePathMapper,
                          @NotNull UserManager userMgr); @Override void visit(@NotNull Condition.Node condition); @Override void visit(@NotNull Condition.PropertyValue condition); @Override void visit(Condition.@NotNull PropertyLike condition); @Override void visit(Condition.@NotNull PropertyExists condition); @Override void visit(@NotNull Condition.Contains condition); @Override void visit(@NotNull Condition.Impersonation condition); @Override void visit(@NotNull Condition.Not condition); @Override void visit(@NotNull Condition.And condition); @Override void visit(@NotNull Condition.Or condition); }
XPathConditionVisitor implements ConditionVisitor { @Override public void visit(@NotNull Condition.Node condition) { statement.append('(') .append("jcr:like(@") .append(QueryUtil.escapeForQuery(UserConstants.REP_AUTHORIZABLE_ID, namePathMapper)) .append(",'") .append(QueryUtil.escapeForQuery(condition.getPattern())) .append("')") .append(" or ") .append("jcr:like(@") .append(QueryUtil.escapeForQuery(UserConstants.REP_PRINCIPAL_NAME, namePathMapper)) .append(",'") .append(QueryUtil.escapeForQuery(condition.getPattern())) .append("')") .append(" or ") .append("jcr:like(fn:name(),'") .append(QueryUtil.escapeForQuery(QueryUtil.escapeNodeName(condition.getPattern()))) .append("')") .append(')'); } XPathConditionVisitor(@NotNull StringBuilder statement, @NotNull NamePathMapper namePathMapper,
                          @NotNull UserManager userMgr); @Override void visit(@NotNull Condition.Node condition); @Override void visit(@NotNull Condition.PropertyValue condition); @Override void visit(Condition.@NotNull PropertyLike condition); @Override void visit(Condition.@NotNull PropertyExists condition); @Override void visit(@NotNull Condition.Contains condition); @Override void visit(@NotNull Condition.Impersonation condition); @Override void visit(@NotNull Condition.Not condition); @Override void visit(@NotNull Condition.And condition); @Override void visit(@NotNull Condition.Or condition);  }