private void setUpSingleFieldConstraint(SingleFieldConstraint sfc) { this.factType = sfc.getFactType(); this.fieldName = sfc.getFieldName(); this.fieldType = oracle.getFieldType(factType, fieldName); }
private void visitSingleFieldConstraint( final SingleFieldConstraint sfc ) { if ( sfc.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_TEMPLATE ) { this.peerVariables.add( new ValueHolder( sfc.getFieldName(), sfc.getValue(), ValueHolder.Type.TEMPLATE_KEY ) ); } else { this.peerVariables.add( new ValueHolder( sfc.getFieldName(), sfc.getValue(), ValueHolder.Type.VALUE ) ); } }
private void setUpSingleFieldConstraint(SingleFieldConstraint sfc) { this.factType = sfc.getFactType(); this.fieldName = sfc.getFieldName(); this.fieldType = oracle.getFieldType(factType, fieldName); }
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; }
static String extractFieldName(final BaseSingleFieldConstraint con) { if (con instanceof SingleFieldConstraintEBLeftSide) { return ((SingleFieldConstraintEBLeftSide) con).getExpressionLeftSide().getFieldName(); } else if (con instanceof SingleFieldConstraint) { return ((SingleFieldConstraint) con).getFieldName(); } else if (con instanceof ConnectiveConstraint) { return ((ConnectiveConstraint) con).getFieldName(); } return null; }
void initDropDownData() { //Set applicable flags and reference data depending upon type if (DataType.TYPE_BOOLEAN.equals(this.fieldType)) { this.isDropDownDataEnum = false; this.dropDownData = DropDownData.create(new String[]{"true", "false"}); } else { this.isDropDownDataEnum = true; final Map<String, String> currentValueMap = new HashMap<String, String>(); if (constraintList != null && constraintList.getConstraints() != null) { for (FieldConstraint con : constraintList.getConstraints()) { if (con instanceof SingleFieldConstraint) { SingleFieldConstraint sfc = (SingleFieldConstraint) con; String fieldName = sfc.getFieldName(); currentValueMap.put(fieldName, sfc.getValue()); } } } this.dropDownData = oracle.getEnums(this.factType, fieldName, currentValueMap); } }
private String getFactTypeFromLHSField() { SingleFieldConstraint lhsBoundField = modeller.getModel().getLHSBoundField(model.getVariable()); if (lhsBoundField != null) { return oracle.getFieldClassName(lhsBoundField.getFactType(), lhsBoundField.getFieldName()); } else { return null; } }
private String getFactTypeFromLHSField() { SingleFieldConstraint lhsBoundField = modeller.getModel().getLHSBoundField(model.getVariable()); if (lhsBoundField != null) { return oracle.getFieldClassName(lhsBoundField.getFactType(), lhsBoundField.getFieldName()); } else { return null; } }
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 boolean isLHSFieldTypeEquivalent(String boundVariable) { String boundFieldType = modeller.getModel().getLHSBindingType(boundVariable); //If the fieldTypes are SuggestionCompletionEngine.TYPE_COMPARABLE check the enums are equivalent if (boundFieldType.equals(DataType.TYPE_COMPARABLE)) { if (!this.variableType.equals(DataType.TYPE_COMPARABLE)) { return false; } SingleFieldConstraint fc = this.modeller.getModel().getLHSBoundField(boundVariable); String fieldName = fc.getFieldName(); String parentFactTypeForBinding = this.modeller.getModel().getLHSParentFactPatternForBinding(boundVariable).getFactType(); String[] dd = this.modeller.getDataModelOracle().getEnumValues(parentFactTypeForBinding, fieldName); return isEnumEquivalent(dd); } //If the fieldTypes are identical (and not SuggestionCompletionEngine.TYPE_COMPARABLE) then return true if (boundFieldType.equals(this.variableType)) { return true; } return false; }
private boolean isLHSFieldTypeEquivalent(String boundVariable) { String boundFieldType = modeller.getModel().getLHSBindingType(boundVariable); //If the fieldTypes are SuggestionCompletionEngine.TYPE_COMPARABLE check the enums are equivalent if (boundFieldType.equals(DataType.TYPE_COMPARABLE)) { if (!this.variableType.equals(DataType.TYPE_COMPARABLE)) { return false; } SingleFieldConstraint fc = this.modeller.getModel().getLHSBoundField(boundVariable); String fieldName = fc.getFieldName(); String parentFactTypeForBinding = this.modeller.getModel().getLHSParentFactPatternForBinding(boundVariable).getFactType(); String[] dd = this.modeller.getDataModelOracle().getEnumValues(parentFactTypeForBinding, fieldName); return isEnumEquivalent(dd); } //If the fieldTypes are identical (and not SuggestionCompletionEngine.TYPE_COMPARABLE) then return true if (boundFieldType.equals(this.variableType)) { return true; } return false; }
private void validateFactPattern(final FactPattern factPattern) { if (factPattern == null || factPattern.getConstraintList() == null || factPattern.getConstraintList().getConstraints() == null) { return; } for (FieldConstraint constraint : factPattern.getConstraintList().getConstraints()) { if (constraint instanceof SingleFieldConstraint) { SingleFieldConstraint singleFieldConstraint = (SingleFieldConstraint) constraint; if (areOperatorAndValueInvalid(singleFieldConstraint)) { errors.add(constants.FactType0HasAField1ThatHasAnOperatorSetButNoValuePleaseAddAValueOrRemoveTheOperator( factPattern.getFactType(), singleFieldConstraint.getFieldName())); } } } }
private void validateFactPattern(final FactPattern factPattern) { if (factPattern == null || factPattern.getConstraintList() == null || factPattern.getConstraintList().getConstraints() == null) { return; } for (FieldConstraint constraint : factPattern.getConstraintList().getConstraints()) { if (constraint instanceof SingleFieldConstraint) { SingleFieldConstraint singleFieldConstraint = (SingleFieldConstraint) constraint; if (areOperatorAndValueInvalid(singleFieldConstraint)) { errors.add(constants.FactType0HasAField1ThatHasAnOperatorSetButNoValuePleaseAddAValueOrRemoveTheOperator( factPattern.getFactType(), singleFieldConstraint.getFieldName())); } } } }
private void isLHSFieldTypeEquivalent(final String boundVariable, final Callback<Boolean> callback) { String boundFieldType = this.model.getLHSBindingType(boundVariable); //If the fieldTypes are SuggestionCompletionEngine.TYPE_COMPARABLE check the enums are equivalent if (Objects.equals(boundFieldType, DataType.TYPE_COMPARABLE)) { if (!Objects.equals(fieldType, DataType.TYPE_COMPARABLE)) { callback.callback(false); return; } SingleFieldConstraint fc = this.model.getLHSBoundField(boundVariable); String fieldName = fc.getFieldName(); String parentFactTypeForBinding = this.model.getLHSParentFactPatternForBinding(boundVariable).getFactType(); String[] dd = this.oracle.getEnumValues(parentFactTypeForBinding, fieldName); callback.callback(isEnumEquivalent(dd, dropDownData)); return; } isBoundVariableApplicableByFieldType(boundFieldType, callback); }
private void isLHSFieldTypeEquivalent(final String boundVariable, final Callback<Boolean> callback) { String boundFieldType = this.model.getLHSBindingType(boundVariable); //If the fieldTypes are SuggestionCompletionEngine.TYPE_COMPARABLE check the enums are equivalent if (Objects.equals(boundFieldType, DataType.TYPE_COMPARABLE)) { if (!Objects.equals(fieldType, DataType.TYPE_COMPARABLE)) { callback.callback(false); return; } SingleFieldConstraint fc = this.model.getLHSBoundField(boundVariable); String fieldName = fc.getFieldName(); String parentFactTypeForBinding = this.model.getLHSParentFactPatternForBinding(boundVariable).getFactType(); String[] dd = this.oracle.getEnumValues(parentFactTypeForBinding, fieldName); callback.callback(isEnumEquivalent(dd, dropDownData)); return; } isBoundVariableApplicableByFieldType(boundFieldType, callback); }
@Override public void callback(Boolean result) { if (result) { callback.callback(true); } else { SingleFieldConstraint lhsBoundField = model.getLHSBoundField(boundVariable); if (lhsBoundField != null) { final String boundClassName = oracle.getFieldClassName(lhsBoundField.getFactType(), lhsBoundField.getFieldName()); if (Objects.equals(getFieldTypeClazz(), boundClassName)) { callback.callback(true); return; } oracle.getSuperTypes(boundClassName, new Callback<List<String>>() { @Override public void callback(List<String> superTypes) { callback.callback(checkSuperTypes(superTypes)); return; } }); } else { callback.callback(false); } } } });
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())); } }