private void assertConstraintValue(final SingleFieldConstraint sfc) { if (DataType.TYPE_STRING.equals(sfc.getFieldType())) { if (sfc.getValue() == null) { sfc.setValue(""); } } }
private String getFactType(FactPattern fp, SingleFieldConstraint sfc) { String factType; if (sfc == null) { factType = fp.getFactType(); } else { factType = sfc.getFieldType(); //If field name is "this" use parent FactPattern type otherwise we can use the Constraint's field type String fieldName = sfc.getFieldName(); if (DataType.TYPE_THIS.equals(fieldName)) { factType = fp.getFactType(); } } return factType; }
private String getFactType(FactPattern fp, SingleFieldConstraint sfc) { String factType; if (sfc == null) { factType = fp.getFactType(); } else { factType = sfc.getFieldType(); //If field name is "this" use parent FactPattern type otherwise we can use the Constraint's field type String fieldName = sfc.getFieldName(); if (DataType.TYPE_THIS.equals(fieldName)) { factType = fp.getFactType(); } } return factType; }
private boolean isConstraintComplete(final SingleFieldConstraint constr) { if (constr.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_EXPR_BUILDER_VALUE) { return true; } else if (constr instanceof SingleFieldConstraintEBLeftSide) { return true; } else if (constr.getFieldBinding() != null) { return true; } final String operator = constr.getOperator(); final String fieldType = constr.getFieldType(); final String fieldValue = constr.getValue(); if (operator == null) { return false; } if (operator.equals("== null") || operator.equals("!= null")) { return true; } if (DataType.TYPE_STRING.equals(fieldType)) { return true; } return !(fieldValue == null || fieldValue.isEmpty()); }
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 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(); }
connectiveConstraints[i].setFactType(factPattern.getFactType()); connectiveConstraints[i].setFieldName(con.getFieldName()); connectiveConstraints[i].setFieldType(con.getFieldType()); setValueOnConstraint(m, operator,
private void fixConnectiveConstraints(SingleFieldConstraint sfc) { if (sfc.getConnectives() == null) { return; } for (ConnectiveConstraint cc : sfc.getConnectives()) { if (cc.getFieldName() == null) { cc.setFieldName(sfc.getFieldName()); cc.setFieldType(sfc.getFieldType()); } } }
private void visitSingleFieldConstraint(SingleFieldConstraint sfc) { InterpolationVariable var = new InterpolationVariable(sfc.getValue(), sfc.getFieldType(), (factPattern == null ? "" : factPattern.getFactType()), sfc.getFieldName(), sfc.getOperator()); if (BaseSingleFieldConstraint.TYPE_TEMPLATE == sfc.getConstraintValueType() && !vars.containsKey(var)) { vars.put(var, vars.size()); } //Visit Connection constraints if (sfc.getConnectives() != null) { for (int i = 0; i < sfc.getConnectives().length; i++) { final ConnectiveConstraint cc = sfc.getConnectives()[i]; InterpolationVariable ccVar = new InterpolationVariable(cc.getValue(), cc.getFieldType(), (factPattern == null ? "" : factPattern.getFactType()), cc.getFieldName()); if (BaseSingleFieldConstraint.TYPE_TEMPLATE == cc.getConstraintValueType() && !vars.containsKey(ccVar)) { vars.put(ccVar, vars.size()); } } } }
public String getFieldBinding(FieldConstraint fc, String var) { String fieldType = null; if (fc instanceof SingleFieldConstraint) { SingleFieldConstraint s = (SingleFieldConstraint) fc; if (s.isBound() && var.equals(s.getFieldBinding())) { fieldType = s.getFieldType(); } } if (fc instanceof SingleFieldConstraintEBLeftSide) { SingleFieldConstraintEBLeftSide s = (SingleFieldConstraintEBLeftSide) fc; if (s.isBound() && var.equals(s.getFieldBinding())) { fieldType = s.getExpressionLeftSide().getGenericType(); } } if (fc instanceof CompositeFieldConstraint) { CompositeFieldConstraint s = (CompositeFieldConstraint) fc; if (s.getConstraints() != null) { for (FieldConstraint ss : s.getConstraints()) { fieldType = getFieldBinding(ss, var); } } } return fieldType; }
private void visitSingleFieldConstraint(final SingleFieldConstraint sfc) { final InterpolationVariable var = new InterpolationVariable(sfc.getValue(), sfc.getFieldType(), (factPattern == null ? "" : factPattern.getFactType()), sfc.getFieldName()); if (BaseSingleFieldConstraint.TYPE_TEMPLATE == sfc.getConstraintValueType() && !vars.contains(var)) { vars.add(var); } else { hasNonTemplateOutput = true; } //Visit Connection constraints if (sfc.getConnectives() != null) { for (int i = 0; i < sfc.getConnectives().length; i++) { final ConnectiveConstraint cc = sfc.getConnectives()[i]; InterpolationVariable ccVar = new InterpolationVariable(cc.getValue(), cc.getFieldType(), (factPattern == null ? "" : factPattern.getFactType()), cc.getFieldName()); if (BaseSingleFieldConstraint.TYPE_TEMPLATE == cc.getConstraintValueType() && !vars.contains(ccVar)) { vars.add(ccVar); } else { hasNonTemplateOutput = true; } } } }
public void onClick(final ClickEvent event) { //If field name is "this" use parent FactPattern type otherwise we can use the Constraint's field type String fieldName = con.getFieldName(); if (DataType.TYPE_THIS.equals(fieldName)) { getConnectives().getDataModelOracle().getFieldCompletions(pattern.getFactType(), new Callback<ModelField[]>() { @Override public void callback(final ModelField[] fields) { popupCreator.showBindFieldPopup(pattern, con, fields, popupCreator); } }); } else { getConnectives().getDataModelOracle().getFieldCompletions(con.getFieldType(), new Callback<ModelField[]>() { @Override public void callback(final ModelField[] fields) { popupCreator.showBindFieldPopup(pattern, con, fields, popupCreator); } }); } } };
public void onClick(final ClickEvent event) { //If field name is "this" use parent FactPattern type otherwise we can use the Constraint's field type String fieldName = con.getFieldName(); if (DataType.TYPE_THIS.equals(fieldName)) { getConnectives().getDataModelOracle().getFieldCompletions(pattern.getFactType(), new Callback<ModelField[]>() { @Override public void callback(final ModelField[] fields) { popupCreator.showBindFieldPopup(pattern, con, fields, popupCreator); } }); } else { getConnectives().getDataModelOracle().getFieldCompletions(con.getFieldType(), new Callback<ModelField[]>() { @Override public void callback(final ModelField[] fields) { popupCreator.showBindFieldPopup(pattern, con, fields, popupCreator); } }); } } };
private void visitSingleFieldConstraint(final SingleFieldConstraint sfc) { ResourceReference resRef = addResourceReference(getFullyQualifiedClassName(sfc.getFactType()), ResourceType.JAVA); resRef.addPartReference(sfc.getFieldName(), PartType.FIELD); addResourceReference(getFullyQualifiedClassName(sfc.getFieldType()), ResourceType.JAVA); if (sfc.getConnectives() != null) { for (int i = 0; i < sfc.getConnectives().length; i++) { visit(sfc.getConnectives()[i]); } } }
private void visitSingleFieldConstraint(final SingleFieldConstraint sfc) { ResourceReference resRef = addResourceReference(getFullyQualifiedClassName(sfc.getFactType()), ResourceType.JAVA); resRef.addPartReference(sfc.getFieldName(), PartType.FIELD); addResourceReference(getFullyQualifiedClassName(sfc.getFieldType()), ResourceType.JAVA); if (sfc.getConnectives() != null) { for (int i = 0; i < sfc.getConnectives().length; i++) { visit(sfc.getConnectives()[i]); } } }
private void fixConstraints(FactPattern fp, SingleFieldConstraint sfc) { final FieldConstraint parent = sfc.getParent(); if (parent == null) { sfc.setFactType(fp.getFactType()); } else if (parent instanceof SingleFieldConstraint) { sfc.setFactType(((SingleFieldConstraint) parent).getFieldType()); } sfc.setFieldName(fixFieldName(sfc.getFieldName())); if (sfc.getConnectives() == null) { return; } for (ConnectiveConstraint cc : sfc.getConnectives()) { cc.setFactType(fp.getFactType()); cc.setFieldName(fixFieldName(cc.getFieldName())); } }
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; }
fcr1sfc.getFieldName()); assertEquals(DataType.TYPE_STRING, fcr1sfc.getFieldType());