@Override public SingleFieldConstraint getLHSBoundField(String var) { return model.getLHSBoundField(var); }
@Override public SingleFieldConstraint getLHSBoundField(String var) { return model.getLHSBoundField(var); }
/** * This will return the FieldConstraint that a variable is bound to. * * @param var The bound field variable (NOT bound fact). * @return null or the FieldConstraint found. */ public SingleFieldConstraint getLHSBoundField(final String var) { if (this.lhs == null) { return null; } for (int i = 0; i < this.lhs.length; i++) { IPattern pat = this.lhs[i]; SingleFieldConstraint fieldConstraint = getLHSBoundField(pat, var); if (fieldConstraint != null) { return fieldConstraint; } } return null; }
@Override public SingleFieldConstraint getLHSBoundField(final String var) { for (CompositeColumn<? extends BaseColumn> col : dtable.getConditions()) { if (col instanceof Pattern52) { final Pattern52 p = (Pattern52) col; for (ConditionCol52 cc : p.getChildColumns()) { if (cc.isBound() && cc.getBinding().equals(var)) { final ConditionCol52FieldConstraintAdaptor sfcAdaptor = new ConditionCol52FieldConstraintAdaptor(cc); sfcAdaptor.setFactType(p.getFactType()); return sfcAdaptor; } } } else if (col instanceof BRLConditionColumn) { //Delegate to super class's implementation final RuleModel rm = new RuleModel(); final BRLConditionColumn brl = (BRLConditionColumn) col; rm.lhs = brl.getDefinition().toArray(new IPattern[brl.getDefinition().size()]); final SingleFieldConstraint sfc = rm.getLHSBoundField(var); if (sfc != null) { return sfc; } } } return super.getLHSBoundField(var); }
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 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 List<String> getApplicableBindings() { List<String> bindings = new ArrayList<String>(); //Examine LHS Fact and Field bindings and RHS (new) Fact bindings for (String v : modeller.getModel().getAllVariables()) { //LHS FactPattern FactPattern fp = modeller.getModel().getLHSBoundFact(v); if (fp != null) { if (isLHSFactTypeEquivalent(v)) { bindings.add(v); } } //LHS FieldConstraint FieldConstraint fc = modeller.getModel().getLHSBoundField(v); if (fc != null) { if (isLHSFieldTypeEquivalent(v)) { bindings.add(v); } } //RHS ActionInsertFact ActionInsertFact aif = modeller.getModel().getRHSBoundFact(v); if (aif != null) { if (isRHSFieldTypeEquivalent(v)) { bindings.add(v); } } } return bindings; }
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 List<String> getApplicableBindings() { List<String> bindings = new ArrayList<String>(); //Examine LHS Fact and Field bindings and RHS (new) Fact bindings for (String v : modeller.getModel().getAllVariables()) { //LHS FactPattern FactPattern fp = modeller.getModel().getLHSBoundFact(v); if (fp != null) { if (isLHSFactTypeEquivalent(v)) { bindings.add(v); } } //LHS FieldConstraint FieldConstraint fc = modeller.getModel().getLHSBoundField(v); if (fc != null) { if (isLHSFieldTypeEquivalent(v)) { bindings.add(v); } } //RHS ActionInsertFact ActionInsertFact aif = modeller.getModel().getRHSBoundFact(v); if (aif != null) { if (isRHSFieldTypeEquivalent(v)) { bindings.add(v); } } } return bindings; }
private SingleFieldConstraint getLHSBoundField(IPattern pat, String var) { if (pat instanceof FromCompositeFactPattern) { pat = ((FromCompositeFactPattern) pat).getFactPattern(); } if (pat instanceof CompositeFactPattern) { for (IPattern iPattern : ((CompositeFactPattern) pat).getPatterns()) { SingleFieldConstraint fieldConstraint = getLHSBoundField(iPattern, var); if (fieldConstraint != null) { return fieldConstraint; } } } if (pat instanceof FactPattern) { final FactPattern p = (FactPattern) pat; for (int j = 0; j < p.getFieldConstraints().length; j++) { if (p.getFieldConstraints()[j] instanceof SingleFieldConstraint) { SingleFieldConstraint fc = (SingleFieldConstraint) p.getFieldConstraints()[j]; List<String> fieldBindings = getFieldBinding(fc); if (fieldBindings.contains(var)) { return fc; } } } } return null; }
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 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); } } } });