/** * Perform test for NOT NULL constraint on node * @param c the constraint to test */ public void apply(Constraint c) { if (c instanceof SimpleConstraint) { SimpleConstraint sc = (SimpleConstraint) c; if (sc.getOp().equals(ConstraintOp.IS_NOT_NULL)) { if (node.equals(sc.getArg1())) { exists = true; } } } } }
/** * Perform test for NOT NULL constraint on node * @param c the constraint to test */ public void apply(Constraint c) { if (c instanceof SimpleConstraint) { SimpleConstraint sc = (SimpleConstraint) c; if (sc.getOp().equals(ConstraintOp.IS_NOT_NULL)) { if (node.equals(sc.getArg1())) { exists = true; } } } } }
/** * Returns true if the given constraint is related to no FromElement. This should * only return true if c is a SimpleConstraint that only references constants. * * @param c the constraint to examine * @return true if constraint is not associated with a FromElement */ public static boolean isRelatedToNothing(Constraint c) { if (c instanceof SimpleConstraint) { SimpleConstraint sc = (SimpleConstraint) c; Set<QueryField> fields = getQueryFields(sc.getArg1()); fields.addAll(getQueryFields(sc.getArg2())); if (fields.size() == 0) { return true; } } return false; }
/** * Returns true if the given constraint is related to no FromElement. This should * only return true if c is a SimpleConstraint that only references constants. * * @param c the constraint to examine * @return true if constraint is not associated with a FromElement */ public static boolean isRelatedToNothing(Constraint c) { if (c instanceof SimpleConstraint) { SimpleConstraint sc = (SimpleConstraint) c; Set<QueryField> fields = getQueryFields(sc.getArg1()); fields.addAll(getQueryFields(sc.getArg2())); if (fields.size() == 0) { return true; } } return false; }
/** * Returns true if the Constraint is a cross-reference between two QueryClasses. * A constraint is deemed to be a cross-reference if it compares fields of * two different QueryClasses, either directly or via QueryExpressions. * * @param constraint the contraint to test * @return true if the contraint is a cross-reference */ public static boolean isCrossReference(Constraint constraint) { if (constraint instanceof SimpleConstraint) { // if QueryField exposed part of a subquery QueryField.getFromElement() // returns a query, does not cause any problem. Set<FromElement> qcs = new HashSet<FromElement>(); for (QueryField qf : getQueryFields(((SimpleConstraint) constraint).getArg1())) { qcs.add(qf.getFromElement()); } for (QueryField qf : getQueryFields(((SimpleConstraint) constraint).getArg2())) { qcs.add(qf.getFromElement()); } if (qcs.size() > 1) { return true; } } return false; }
/** * Returns true if the Constraint is a cross-reference between two QueryClasses. * A constraint is deemed to be a cross-reference if it compares fields of * two different QueryClasses, either directly or via QueryExpressions. * * @param constraint the contraint to test * @return true if the contraint is a cross-reference */ public static boolean isCrossReference(Constraint constraint) { if (constraint instanceof SimpleConstraint) { // if QueryField exposed part of a subquery QueryField.getFromElement() // returns a query, does not cause any problem. Set<FromElement> qcs = new HashSet<FromElement>(); for (QueryField qf : getQueryFields(((SimpleConstraint) constraint).getArg1())) { qcs.add(qf.getFromElement()); } for (QueryField qf : getQueryFields(((SimpleConstraint) constraint).getArg2())) { qcs.add(qf.getFromElement()); } if (qcs.size() > 1) { return true; } } return false; }
left = ((ContainsConstraint) constraint).getReference(); } else if (constraint instanceof SimpleConstraint) { left = ((SimpleConstraint) constraint).getArg1(); } else if (constraint instanceof BagConstraint) { left = ((BagConstraint) constraint).getQueryNode();
left = ((ContainsConstraint) constraint).getReference(); } else if (constraint instanceof SimpleConstraint) { left = ((SimpleConstraint) constraint).getArg1(); } else if (constraint instanceof BagConstraint) { left = ((BagConstraint) constraint).getQueryNode();
/** * Converts a SimpleConstraint object into a String suitable for putting in an SQL query. * * @param state the current SqlGenerator state * @param buffer the StringBuffer to place text into * @param c the SimpleConstraint object * @param q the Query * @throws ObjectStoreException if something goes wrong */ protected static void simpleConstraintToString(State state, StringBuffer buffer, SimpleConstraint c, Query q) throws ObjectStoreException { queryEvaluableToString(buffer, c.getArg1(), q, state); buffer.append(" " + c.getOp().toString()); if (c.getArg2() != null) { buffer.append(" "); queryEvaluableToString(buffer, c.getArg2(), q, state); } }
/** * Converts a SimpleConstraint object into a String suitable for putting in an SQL query. * * @param state the current SqlGenerator state * @param buffer the StringBuffer to place text into * @param c the SimpleConstraint object * @param q the Query * @throws ObjectStoreException if something goes wrong */ protected static void simpleConstraintToString(State state, StringBuffer buffer, SimpleConstraint c, Query q) throws ObjectStoreException { queryEvaluableToString(buffer, c.getArg1(), q, state); buffer.append(" " + c.getOp().toString()); if (c.getArg2() != null) { buffer.append(" "); queryEvaluableToString(buffer, c.getArg2(), q, state); } }
Set<QueryField> qFields = getQueryFields(sc.getArg1()); qFields.addAll(getQueryFields(sc.getArg2())); for (QueryField qf : qFields) {
Set<QueryField> qFields = getQueryFields(sc.getArg1()); qFields.addAll(getQueryFields(sc.getArg2())); for (QueryField qf : qFields) {
} else if (constraint instanceof SimpleConstraint && constraint.getOp() == ConstraintOp.EQUALS && ((SimpleConstraint) constraint).getArg1() instanceof QueryField && ((SimpleConstraint) constraint).getArg2() instanceof QueryValue && ((QueryField) ((SimpleConstraint) constraint).getArg1()) .getFromElement() == qn && "id".equals(((QueryField) ((SimpleConstraint) constraint).getArg1()) .getFieldName())) { SimpleConstraint sc =
} else if (constraint instanceof SimpleConstraint && constraint.getOp() == ConstraintOp.EQUALS && ((SimpleConstraint) constraint).getArg1() instanceof QueryField && ((SimpleConstraint) constraint).getArg2() instanceof QueryValue && ((QueryField) ((SimpleConstraint) constraint).getArg1()) .getFromElement() == qn && "id".equals(((QueryField) ((SimpleConstraint) constraint).getArg1()) .getFieldName())) { SimpleConstraint sc =
SimpleConstraint c = (SimpleConstraint) cc; if (c.getArg2() == null) { return nodeToString(q, c.getArg1(), parameters, null) + " " + c.getOp().toString(); } else { return nodeToString(q, c.getArg1(), parameters, null) + " " + c.getOp().toString() + " " + nodeToString(q, c.getArg2(), parameters, null);
if ((origC.getOp() == ConstraintOp.IS_NULL) || (origC.getOp() == ConstraintOp.IS_NOT_NULL)) { return new SimpleConstraint((QueryEvaluable) cloneThing(origC.getArg1(), fromElementMap, qopeMap), origC.getOp()); } else { return new SimpleConstraint((QueryEvaluable) cloneThing(origC.getArg1(), fromElementMap, qopeMap), origC.getOp(), (QueryEvaluable) cloneThing(origC.getArg2(), fromElementMap, qopeMap));
SimpleConstraint c = (SimpleConstraint) cc; if (c.getArg2() == null) { return nodeToString(q, c.getArg1(), parameters, null) + " " + c.getOp().toString(); } else { return nodeToString(q, c.getArg1(), parameters, null) + " " + c.getOp().toString() + " " + nodeToString(q, c.getArg2(), parameters, null);
if ((origC.getOp() == ConstraintOp.IS_NULL) || (origC.getOp() == ConstraintOp.IS_NOT_NULL)) { return new SimpleConstraint((QueryEvaluable) cloneThing(origC.getArg1(), fromElementMap, qopeMap), origC.getOp()); } else { return new SimpleConstraint((QueryEvaluable) cloneThing(origC.getArg1(), fromElementMap, qopeMap), origC.getOp(), (QueryEvaluable) cloneThing(origC.getArg2(), fromElementMap, qopeMap));
QueryEvaluable arg1 = c.getArg1(); QueryEvaluable arg2 = c.getArg2(); if (arg2 == null) {
SimpleConstraint sc1 = (SimpleConstraint) c1; SimpleConstraint sc2 = (SimpleConstraint) c2; checkQueryNodes(msg + ": first QueryEvaluables are not equal", sc1.getArg1(), sc2.getArg1(), q1, q2); checkQueryNodes(msg + ": first QueryEvaluables are not equal", sc1.getArg2(), sc2.getArg2(), q1, q2); } else if (c1 instanceof ClassConstraint) {