private Set<String> visitSingleFieldConstraint(SingleFieldConstraint sfc) { final Set<String> factTypes = new HashSet<String>(); if (sfc.getFactType() != null) { factTypes.add(sfc.getFactType()); } factTypes.addAll(visit(sfc.getExpressionValue())); if (sfc.getConnectives() != null) { for (int i = 0; i < sfc.getConnectives().length; i++) { factTypes.addAll(visit(sfc.getConnectives()[i])); } } return factTypes; }
private boolean areOperatorAndValueInvalid(final SingleFieldConstraint singleFieldConstraint) { if (singleFieldConstraint.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_LITERAL) { if (DataType.TYPE_STRING.equals(singleFieldConstraint.getFieldType())) { return false; } } return singleFieldConstraint.getOperator() != null && !singleFieldConstraint.getOperator().equals("== null") && !singleFieldConstraint.getOperator().equals("!= null") && singleFieldConstraint.getValue() == null && singleFieldConstraint.getExpressionValue().isEmpty(); }
private Set<String> visitSingleFieldConstraint(SingleFieldConstraint sfc) { final Set<String> factTypes = new HashSet<String>(); if (sfc.getFactType() != null) { factTypes.add(sfc.getFactType()); } factTypes.addAll(visit(sfc.getExpressionValue())); if (sfc.getConnectives() != null) { for (int i = 0; i < sfc.getConnectives().length; i++) { factTypes.addAll(visit(sfc.getConnectives()[i])); } } return factTypes; }
private boolean areOperatorAndValueInvalid(final SingleFieldConstraint singleFieldConstraint) { if (singleFieldConstraint.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_LITERAL) { if (DataType.TYPE_STRING.equals(singleFieldConstraint.getFieldType())) { return false; } } return singleFieldConstraint.getOperator() != null && !singleFieldConstraint.getOperator().equals("== null") && !singleFieldConstraint.getOperator().equals("!= null") && singleFieldConstraint.getValue() == null && singleFieldConstraint.getExpressionValue().isEmpty(); }
public List<String> getFieldBinding(FieldConstraint f) { List<String> result = new ArrayList<String>(); if (f instanceof SingleFieldConstraint) { SingleFieldConstraint con = (SingleFieldConstraint) f; if (con.isBound()) { result.add(con.getFieldBinding()); } if (con.getExpressionValue() != null && con.getExpressionValue().isBound()) { result.add(con.getExpressionValue().getBinding()); } if (con instanceof SingleFieldConstraintEBLeftSide) { SingleFieldConstraintEBLeftSide exp = (SingleFieldConstraintEBLeftSide) con; if (exp.getExpressionLeftSide() != null && exp.getExpressionLeftSide().isBound()) { result.add(exp.getExpressionLeftSide().getBinding()); } } } else if (f instanceof CompositeFieldConstraint) { CompositeFieldConstraint cfc = (CompositeFieldConstraint) f; if (cfc.getConstraints() != null) { for (FieldConstraint ss : cfc.getConstraints()) { List<String> t = getFieldBinding(ss); result.addAll(t); } } } return result; }
result.add(con.getFieldBinding()); if (con.getExpressionValue() != null && con.getExpressionValue().isBound()) { result.add(con.getExpressionValue().getBinding());
private void generateNormalFieldRestriction(final SingleFieldConstraint constr, final Map<String, String> parameters) { if (constr instanceof SingleFieldConstraintEBLeftSide) { SingleFieldConstraintEBLeftSide sfexp = (SingleFieldConstraintEBLeftSide) constr; addFieldRestriction(buf, sfexp.getConstraintValueType(), sfexp.getExpressionLeftSide().getGenericType(), sfexp.getOperator(), parameters, sfexp.getValue(), sfexp.getExpressionValue(), true); } else { addFieldRestriction(buf, constr.getConstraintValueType(), constr.getFieldType(), constr.getOperator(), parameters, constr.getValue(), constr.getExpressionValue(), true); } }
private SingleFieldConstraint visitSingleFieldConstraint(SingleFieldConstraint sfc) { SingleFieldConstraint clone = new SingleFieldConstraint(); clone.setConstraintValueType(sfc.getConstraintValueType()); clone.setExpressionValue((ExpressionFormLine) visit(sfc.getExpressionValue())); clone.setFieldBinding(sfc.getFieldBinding()); clone.setFactType(sfc.getFactType()); clone.setFieldName(sfc.getFieldName()); clone.setFieldType(sfc.getFieldType()); clone.setId(sfc.getId()); clone.setOperator(sfc.getOperator()); clone.setParent((FieldConstraint) visit(sfc.getParent())); for (Map.Entry<String, String> entry : sfc.getParameters().entrySet()) { clone.setParameter(entry.getKey(), entry.getValue()); } clone.setValue(sfc.getValue()); if (sfc.getConnectives() != null) { clone.setConnectives(new ConnectiveConstraint[sfc.getConnectives().length]); for (int i = 0; i < sfc.getConnectives().length; i++) { clone.getConnectives()[i] = (ConnectiveConstraint) visit(sfc.getConnectives()[i]); } } return clone; }
private SingleFieldConstraint visitSingleFieldConstraint(SingleFieldConstraint sfc) { SingleFieldConstraint clone = new SingleFieldConstraint(); clone.setConstraintValueType(sfc.getConstraintValueType()); clone.setExpressionValue((ExpressionFormLine) visit(sfc.getExpressionValue())); clone.setFieldBinding(sfc.getFieldBinding()); clone.setFactType(sfc.getFactType()); clone.setFieldName(sfc.getFieldName()); clone.setFieldType(sfc.getFieldType()); clone.setId(sfc.getId()); clone.setOperator(sfc.getOperator()); clone.setParent((FieldConstraint) visit(sfc.getParent())); for (Map.Entry<String, String> entry : sfc.getParameters().entrySet()) { clone.setParameter(entry.getKey(), entry.getValue()); } clone.setValue(sfc.getValue()); if (sfc.getConnectives() != null) { clone.setConnectives(new ConnectiveConstraint[sfc.getConnectives().length]); for (int i = 0; i < sfc.getConnectives().length; i++) { clone.getConnectives()[i] = (ConnectiveConstraint) visit(sfc.getConnectives()[i]); } } return clone; }
@Test public void testComparingFieldToExpression() throws Exception { FactPattern f1 = new FactPattern(); f1.setBoundName("f1"); FactPattern f2 = new FactPattern(); SingleFieldConstraint constraint = new SingleFieldConstraint(); constraint.setOperator("=="); constraint.getExpressionValue().appendPart(new ExpressionVariable("field", "java.lang.Number", "Number")); f2.addConstraint(constraint); model.lhs = new IPattern[]{f1, f2}; assertTrue(validator.isValid()); }
@Test public void testComparingFieldToExpression() throws Exception { FactPattern f1 = new FactPattern(); f1.setBoundName("f1"); FactPattern f2 = new FactPattern(); SingleFieldConstraint constraint = new SingleFieldConstraint(); constraint.setOperator("=="); constraint.getExpressionValue().appendPart(new ExpressionVariable("field", "java.lang.Number", "Number")); f2.addConstraint(constraint); model.lhs = new IPattern[]{f1, f2}; assertTrue(validator.isValid()); }
parameters, constr.getValue(), constr.getExpressionValue(), cctx, true);