/** * Get the ids for a constraint. * @param con The constraint. * @return A collection of ids. null if this makes no sense. */ public static Collection<Integer> getIds(PathConstraint con) { if (con instanceof PathConstraintIds) { return ((PathConstraintIds) con).getIds(); } else { return null; } }
/** * Creates a constraint for a path to be IN a collection of ids. * * @param path the path to apply the constraint to * @param ids the Collection of ids to constrain to * @return a new PathConstraint object */ public static PathConstraintIds inIds(String path, Collection<Integer> ids) { return new PathConstraintIds(path, ConstraintOp.IN, ids); }
/** * Get the ids for a constraint. * @param con The constraint. * @return A collection of ids. null if this makes no sense. */ public static Collection<Integer> getIds(PathConstraint con) { if (con instanceof PathConstraintIds) { return ((PathConstraintIds) con).getIds(); } else { return null; } }
/** * Creates a constraint for a path to be IN a collection of ids. * * @param path the path to apply the constraint to * @param ids the Collection of ids to constrain to * @return a new PathConstraint object */ public static PathConstraintIds inIds(String path, Collection<Integer> ids) { return new PathConstraintIds(path, ConstraintOp.IN, ids); }
StringBuilder sb = new StringBuilder(); boolean needComma = false; for (Integer id : ((PathConstraintIds) constraint.getKey()).getIds()) { if (needComma) { sb.append(", ");
/** * Creates a constraint for a path to be NOT IN a collection of ids. * * @param path the path to apply the constraint to * @param ids the Collection of ids to constrain to * @return a new PathConstraint object */ public static PathConstraintIds notInIds(String path, Collection<Integer> ids) { return new PathConstraintIds(path, ConstraintOp.NOT_IN, ids); }
StringBuilder sb = new StringBuilder(); boolean needComma = false; for (Integer id : ((PathConstraintIds) constraint.getKey()).getIds()) { if (needComma) { sb.append(", ");
/** * Creates a constraint for a path to be NOT IN a collection of ids. * * @param path the path to apply the constraint to * @param ids the Collection of ids to constrain to * @return a new PathConstraint object */ public static PathConstraintIds notInIds(String path, Collection<Integer> ids) { return new PathConstraintIds(path, ConstraintOp.NOT_IN, ids); }
codeToConstraint.put(code, new BagConstraint(new QueryField( (QueryClass) field, "id"), constraint.getOp(), ((PathConstraintIds) constraint).getIds())); } else if (constraint instanceof PathConstraintRange) { PathConstraintRange pcr = (PathConstraintRange) constraint;
ids.add(Integer.parseInt(id)); constraint = new PathConstraintIds(path, constraintOp, ids);
codeToConstraint.put(code, new BagConstraint(new QueryField( (QueryClass) field, "id"), constraint.getOp(), ((PathConstraintIds) constraint).getIds())); } else if (constraint instanceof PathConstraintRange) { PathConstraintRange pcr = (PathConstraintRange) constraint;
ids.add(Integer.parseInt(id)); constraint = new PathConstraintIds(path, constraintOp, ids);
return new PathConstraintIds(path, constraintOp, idsCollection); } else { throw new SAXException("Invalid query: operation was: "
return new PathConstraintIds(path, constraintOp, idsCollection); } else { throw new SAXException("Invalid query: operation was: "
public void testIdBags() throws Exception { PathQuery pq = new PathQuery(Model.getInstanceByName("testmodel")); pq.addViews("Company.name"); pq.addViews("Company.vatNumber"); List ids = Arrays.asList("1","5","7"); pq.addConstraint(new PathConstraintIds("Company", ConstraintOp.IN, ids)); assertEquals(pq.toString(), savedQueries.get("idBagConstraints").toString()); }
q.addConstraint(new PathConstraintBag("Department.name", ConstraintOp.IN, "bagname")); q.addConstraint(new PathConstraintBag("Department", ConstraintOp.NOT_IN, "bagname")); q.addConstraint(new PathConstraintIds("Department.name", ConstraintOp.IN, Arrays.asList(1, 2, 3))); q.addConstraint(new PathConstraintIds("Department", ConstraintOp.NOT_IN, Arrays.asList(1, 2, 3, 4))); q.addConstraint(new PathConstraintMultiValue("Department.name", ConstraintOp.NONE_OF, Arrays.asList("Fred", "Bernie"))); q.addConstraint(new PathConstraintMultiValue("Department", ConstraintOp.ONE_OF, Arrays.asList("Albert", "Charlie")));