protected Boolean walkStartsWithNonPath(Operand lvalue, String path) { Object left = walkReference((Reference) lvalue); // exact match Boolean bool = eqMaybeList(left, path); if (TRUE.equals(bool)) { return TRUE; } // prefix match TODO escape % chars String pattern = path + "/%"; return likeMaybeList(left, pattern, true, false); }
protected Boolean walkStartsWithPath(String path) { // resolve path String ancestorId = pathResolver.getIdForPath(path); // don't return early on null ancestorId, we want to walk all references deterministically Object[] ancestorIds = (Object[]) walkReference(new Reference(NXQL_ECM_ANCESTOR_IDS)); if (ancestorId == null) { // no such path return FALSE; } if (ancestorIds == null) { // placeless return FALSE; } for (Object id : ancestorIds) { if (ancestorId.equals(id)) { return TRUE; } } return FALSE; }
protected Boolean walkAncestorId(Operator op, Operand rvalue) { if (op != Operator.EQ && op != Operator.NOTEQ) { throw new QueryParseException(NXQL.ECM_ANCESTORID + " requires = or <> operator"); } if (!(rvalue instanceof StringLiteral)) { throw new QueryParseException(NXQL.ECM_ANCESTORID + " requires literal id as right argument"); } String ancestorId = ((StringLiteral) rvalue).value; Object[] ancestorIds = (Object[]) walkReference(new Reference(NXQL_ECM_ANCESTOR_IDS)); boolean eq = op == Operator.EQ ? true : false; if (ancestorIds == null) { // placeless return eq ? FALSE : TRUE; } for (Object id : ancestorIds) { if (ancestorId.equals(id)) { return eq ? TRUE : FALSE; } } return eq ? FALSE : TRUE; }
protected Boolean walkEcmPath(Operator op, Operand rvalue) { if (op != Operator.EQ && op != Operator.NOTEQ) { throw new QueryParseException(NXQL.ECM_PATH + " requires = or <> operator"); } if (!(rvalue instanceof StringLiteral)) { throw new QueryParseException(NXQL.ECM_PATH + " requires literal path as right argument"); } String path = ((StringLiteral) rvalue).value; if (path.length() > 1 && path.endsWith("/")) { path = path.substring(0, path.length() - 1); } String id = pathResolver.getIdForPath(path); Object right = walkReference(new Reference(NXQL.ECM_UUID)); if (id == null) { return FALSE; } Boolean eq = eq(id, right); return op == Operator.EQ ? eq : not(eq); }
protected Boolean walkEcmFulltext(String name, Operator op, Operand rvalue) { if (op != Operator.EQ && op != Operator.LIKE) { throw new QueryParseException(NXQL.ECM_FULLTEXT + " requires = or LIKE operator"); } if (!(rvalue instanceof StringLiteral)) { throw new QueryParseException(NXQL.ECM_FULLTEXT + " requires literal string as right argument"); } if (fulltextSearchDisabled) { throw new QueryParseException("Fulltext search disabled by configuration"); } String query = ((StringLiteral) rvalue).value; if (name.equals(NXQL.ECM_FULLTEXT)) { // standard fulltext query hasFulltext = true; String simple = (String) walkReference(new Reference(NXQL_ECM_FULLTEXT_SIMPLE)); String binary = (String) walkReference(new Reference(NXQL_ECM_FULLTEXT_BINARY)); return fulltext(simple, binary, query); } else { // secondary index match with explicit field // do a regexp on the field if (name.charAt(NXQL.ECM_FULLTEXT.length()) != '.') { throw new QueryParseException(name + " has incorrect syntax for a secondary fulltext index"); } String prop = name.substring(NXQL.ECM_FULLTEXT.length() + 1); String ft = query.replace(" ", "%"); rvalue = new StringLiteral(ft); return walkLike(new Reference(prop), rvalue, true, true); } }
public Object walkOperand(Operand op) { if (op instanceof Literal) { return walkLiteral((Literal) op); } else if (op instanceof LiteralList) { return walkLiteralList((LiteralList) op); } else if (op instanceof Function) { return walkFunction((Function) op); } else if (op instanceof Expression) { return walkExpression((Expression) op); } else if (op instanceof Reference) { return walkReference((Reference) op); } else { throw new QueryParseException("Unknown operand: " + op); } }