/** * Creates a constraint for a path to be null. * * @param path the path to apply the constraint to * @return a new PathConstraint object */ public static PathConstraintNull isNull(String path) { return new PathConstraintNull(path, ConstraintOp.IS_NULL); }
/** * A static method for accessing values without having to handle * the subclasses manually. * @param con The constraint. * @return A string representing the value. */ public static String getValue(PathConstraint con) { if (con instanceof PathConstraintAttribute) { return ((PathConstraintAttribute) con).getValue(); } else if (con instanceof PathConstraintBag) { return ((PathConstraintBag) con).getBag(); } else if (con instanceof PathConstraintLookup) { return ((PathConstraintLookup) con).getValue(); } else if (con instanceof PathConstraintSubclass) { return ((PathConstraintSubclass) con).getType(); } else if (con instanceof PathConstraintLoop) { return ((PathConstraintLoop) con).getLoopPath(); } else if (con instanceof PathConstraintNull) { return ((PathConstraintNull) con).getOp().toString(); } return null; }
/** * A static method for accessing values without having to handle * the subclasses manually. * @param con The constraint. * @return A string representing the value. */ public static String getValue(PathConstraint con) { if (con instanceof PathConstraintAttribute) { return ((PathConstraintAttribute) con).getValue(); } else if (con instanceof PathConstraintBag) { return ((PathConstraintBag) con).getBag(); } else if (con instanceof PathConstraintLookup) { return ((PathConstraintLookup) con).getValue(); } else if (con instanceof PathConstraintSubclass) { return ((PathConstraintSubclass) con).getType(); } else if (con instanceof PathConstraintLoop) { return ((PathConstraintLoop) con).getLoopPath(); } else if (con instanceof PathConstraintNull) { return ((PathConstraintNull) con).getOp().toString(); } return null; }
/** * Creates a constraint for a path to be null. * * @param path the path to apply the constraint to * @return a new PathConstraint object */ public static PathConstraintNull isNull(String path) { return new PathConstraintNull(path, ConstraintOp.IS_NULL); }
/** * Creates a constraint for a path to be not null. * * @param path the path to apply the constraint to * @return a new PathConstraint object */ public static PathConstraintNull isNotNull(String path) { return new PathConstraintNull(path, ConstraintOp.IS_NOT_NULL); }
/** * Creates a constraint for a path to be not null. * * @param path the path to apply the constraint to * @return a new PathConstraint object */ public static PathConstraintNull isNotNull(String path) { return new PathConstraintNull(path, ConstraintOp.IS_NOT_NULL); }
constraint = new PathConstraintNull(path, constraintOp); } else if ("WITHIN".equals(op) || "OVERLAPS".equals(op) || "DOES NOT OVERLAP".equals(op) || "OUTSIDE".equals(op)) {
constraint = new PathConstraintNull(path, constraintOp); } else if ("WITHIN".equals(op) || "OVERLAPS".equals(op) || "DOES NOT OVERLAP".equals(op) || "OUTSIDE".equals(op)) {
return new PathConstraintNull(path, constraintOp); } else if (PathConstraintBag.VALID_OPS.contains(constraintOp)) { String bag = attrs.get("value");
return new PathConstraintNull(path, constraintOp); } else if (PathConstraintBag.VALID_OPS.contains(constraintOp)) { String bag = attrs.get("value");
public void testNullConstraints() throws Exception { PathQuery pq = new PathQuery(Model.getInstanceByName("testmodel")); pq.addViews("Department.name"); pq.addConstraint(new PathConstraintNull("Department.manager", ConstraintOp.IS_NULL)); pq.addOrderBy("Department.name", OrderDirection.ASC); assertEquals(pq.toString(), savedQueries.get("nullConstraint").toString()); }
@Test public void nullPathQueryCollectionsSynonyms() { PathQuery pq = new PathQuery(osw.getModel()); pq.addView("Department.name"); pq.addConstraint(Constraints.eq("Department.name", "temp-*")); pq.addConstraint(new PathConstraintNull("Department.employees", ConstraintOp.IS_EMPTY)); Query q = makeQuery(pq); System.out.println(q.toString()); doNullCollectionTests(q); }
((PathConstraintLoop) pathConstraint).getLoopPath()); } else if (pathConstraint instanceof PathConstraintNull) { newPathConstraint = new PathConstraintNull(newPath, op);
((PathConstraintLoop) pathConstraint).getLoopPath()); } else if (pathConstraint instanceof PathConstraintNull) { newPathConstraint = new PathConstraintNull(newPath, op);
public void testNullReference() throws Exception { PathQuery pq = new PathQuery(os.getModel()); pq.addView("Department.name"); pq.addConstraint(new PathConstraintNull("Department.company", ConstraintOp.IS_NULL)); Query expected = new Query(); QueryClass qc = new QueryClass(Department.class); expected.addFrom(qc); expected.addToSelect(qc); QueryObjectReference ref = new QueryObjectReference(qc, "company"); ContainsConstraint cc = new ContainsConstraint(ref, ConstraintOp.IS_NULL); expected.setConstraint(cc); expected.addToOrderBy(new QueryField(qc, "name")); Query actual = MainHelper.makeQuery(pq, new HashMap(), null, bagQueryRunner, new HashMap()); assertEquals(expected.toString(), actual.toString()); // Same test for IS_NOT_NULL pq = new PathQuery(os.getModel()); pq.addView("Department.name"); pq.addConstraint(new PathConstraintNull("Department.company", ConstraintOp.IS_NOT_NULL)); cc = new ContainsConstraint(ref, ConstraintOp.IS_NOT_NULL); expected.setConstraint(cc); actual = MainHelper.makeQuery(pq, new HashMap(), null, bagQueryRunner, new HashMap()); assertEquals(expected.toString(), actual.toString()); }
public void testNullCollection() throws Exception { PathQuery pq = new PathQuery(os.getModel()); pq.addView("Company.name"); pq.addConstraint(new PathConstraintNull("Company.contractors", ConstraintOp.IS_NULL)); Query expected = new Query(); QueryClass qc = new QueryClass(Company.class); expected.addFrom(qc); expected.addToSelect(qc); QueryCollectionReference col = new QueryCollectionReference(qc, "contractors"); ContainsConstraint cc = new ContainsConstraint(col, ConstraintOp.IS_NULL); expected.setConstraint(cc); expected.addToOrderBy(new QueryField(qc, "name")); Query actual = MainHelper.makeQuery(pq, new HashMap(), null, bagQueryRunner, new HashMap()); assertEquals(expected.toString(), actual.toString()); // Same test for IS_NOT_NULL pq = new PathQuery(os.getModel()); pq.addView("Company.name"); pq.addConstraint(new PathConstraintNull("Company.contractors", ConstraintOp.IS_NOT_NULL)); cc = new ContainsConstraint(col, ConstraintOp.IS_NOT_NULL); expected.setConstraint(cc); actual = MainHelper.makeQuery(pq, new HashMap(), null, bagQueryRunner, new HashMap()); assertEquals(expected.toString(), actual.toString()); }
public void testNullReferenceOuterJoin() throws Exception { PathQuery pq = new PathQuery(os.getModel()); pq.addViews("Department.company.name"); pq.addConstraint(new PathConstraintNull("Department.company", ConstraintOp.IS_NOT_NULL)); pq.setOuterJoinStatus("Department.company", OuterJoinStatus.OUTER); Query expected = new Query(); QueryClass qc = new QueryClass(Department.class); expected.addFrom(qc); expected.addToSelect(qc); // outer join to select Department.company.name QueryObjectPathExpression comOuter = new QueryObjectPathExpression(qc, "company"); expected.addToSelect(comOuter); // Company IS_NOT_NULL QueryObjectReference ref = new QueryObjectReference(qc, "company"); ContainsConstraint cc = new ContainsConstraint(ref, ConstraintOp.IS_NOT_NULL); expected.setConstraint(cc); Query actual = MainHelper.makeQuery(pq, new HashMap(), null, bagQueryRunner, new HashMap()); assertEquals(expected.toString(), actual.toString()); // Same test for IS_NOT_NULL pq = new PathQuery(os.getModel()); pq.addView("Department.company.name"); pq.addConstraint(new PathConstraintNull("Department.company", ConstraintOp.IS_NOT_NULL)); pq.setOuterJoinStatus("Department.company", OuterJoinStatus.OUTER); cc = new ContainsConstraint(ref, ConstraintOp.IS_NOT_NULL); expected.setConstraint(cc); actual = MainHelper.makeQuery(pq, new HashMap(), null, bagQueryRunner, new HashMap()); assertEquals(expected.toString(), actual.toString()); }
pq.addConstraint(new PathConstraintNull("Department.company", ConstraintOp.IS_NOT_NULL)); pq.addConstraint(new PathConstraintNull("Department.company", ConstraintOp.IS_NULL)); pq.addConstraint(new PathConstraintAttribute("Department.company.name", ConstraintOp.EQUALS, "Com1"));