* @param value Type: DataValue (Input) (default in Forte: NIL)
*/
public void addConstraint(int attr, int operation, DataValue value) {
if (attr > this.getNumAttrs()) {
throw new Error(Error.BQ_ILLEGAL_ATTR, "AddConstraint", this, new IntegerData(attr), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM1).getException();
}
else if (this.operation == BusinessQuery.OP_INSERT) {
throw new Error(Error.BQ_ILLEGAL_ACTION_FOR_OP, "AddConstraint", this, new IntegerData(this.operation), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM1).getException();
}
else if (this.getConstraint() == null) {
this.setConstraint(new QueryConstraint());
}
if ((operation&ConstraintOperation.TYPE_MASK) == ConstraintOperation.TYPE_ORDERBY) {
//
// Check that this attr isn't already specified in an "order by" constraint
//
for (int i = this.getConstraint().getStack().size(); i >= 2; i--) {
if (this.getConstraint().getStack().get(i-1) instanceof ConstraintOperation && ((((ConstraintOperation)(this.getConstraint().getStack().get(i-1))).getOperation()&ConstraintOperation.TYPE_MASK) == ConstraintOperation.TYPE_ORDERBY) && ((ConstraintAttr)(this.getConstraint().getStack().get(i-1-1))).getAttr() == attr && ((ConstraintAttr)(this.getConstraint().getStack().get(i-1-1))).getEntity() == this) {
throw new Error(Error.BQ_CONS_DUP_ORDERBY_ATTR, "AddConstraint", this, new IntegerData(attr), Error.qq_Resolver.cERROR_METHODNAME_ORIGINATOR_PARAM1).getException();
}
}
if (value != null) {
this.getConstraint().addValue(value);
}
}
else if (operation == ConstraintOperation.OP_NULL || operation == ConstraintOperation.OP_NOTNULL) {
if (value != null) {
throw new Error(Error.BQ_CONS_OP_PROHIBITS_VALUE, "AddConstraint", this, new IntegerData(operation), new IntegerData(attr)).getException();
}
}
else if (value == null) {
throw new Error(Error.BQ_CONS_OP_NEEDS_VALUE, "AddConstraint", this, new IntegerData(operation), new IntegerData(attr)).getException();
}
else {
this.getConstraint().addValue(value);