private Set<String> getActionFactTypesFromRuleModel(final List<IAction> definition) { final RuleModel rm = new RuleModel(); rm.setPackageName(model.getPackageName()); rm.setImports(model.getImports()); for (IAction a : definition) { rm.addRhsItem(a); } final GuidedRuleModelVisitor visitor = new GuidedRuleModelVisitor(rm); return visitor.getConsumedModelClasses(); } }
public void addLhsItem(final IPattern pat, boolean append) { this.addLhsItem(pat, append ? this.lhs.length : 0); }
@Override protected void handleAttributeAddition(final String attributeName) { if (attributeName.equals(RuleAttributeWidget.LOCK_LHS) || attributeName.equals(RuleAttributeWidget.LOCK_RHS)) { model.addMetadata(new RuleMetadata(attributeName, "true")); } else { model.addAttribute(new RuleAttribute(attributeName, "")); } refresh.execute(); }
/** * This will get a list of all bound variables (LHS and RHS), including bound fields.. */ public List<String> getAllVariables() { List<String> result = new ArrayList<String>(); result.addAll(this.getAllLHSVariables()); result.addAll(this.getAllRHSVariables()); return result; }
public GuidedRuleModelVisitor(final RuleModel model) { this.model = PortablePreconditions.checkNotNull("model", model); this.packageName = model.getPackageName(); this.imports = model.getImports(); }
private Set<String> getPatternBindings(final BRLConditionColumn column) { final Set<String> bindings = new HashSet<>(); final List<IPattern> definition = column.getDefinition(); final RuleModel rm = new RuleModel(); rm.lhs = definition.toArray(new IPattern[definition.size()]); bindings.addAll(rm.getLHSVariables(true, true)); return bindings; } }
public void addRhsItem(final IAction action, boolean append) { this.addRhsItem(action, append ? this.rhs.length : 0); }
private boolean hasVariables(BRLActionColumn column) { Map<InterpolationVariable, Integer> ivs = new HashMap<InterpolationVariable, Integer>(); RuleModel rm = new RuleModel(); for (IAction action : column.getDefinition()) { rm.addRhsItem(action); } RuleModelVisitor rmv = new RuleModelVisitor(ivs); rmv.visit(rm); return ivs.size() > 0; }
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 boolean hasTemplateKeys(final BRLActionColumn column) { final Map<InterpolationVariable, Integer> ivs = new HashMap<>(); final RuleModel rm = new RuleModel(); column.getDefinition().forEach(rm::addRhsItem); final RuleModelVisitor rmv = new RuleModelVisitor(ivs); rmv.visit(rm); return ivs.size() > 0; }
private boolean hasVariables(BRLConditionColumn column) { Map<InterpolationVariable, Integer> ivs = new HashMap<InterpolationVariable, Integer>(); RuleModel rm = new RuleModel(); for (IPattern pattern : column.getDefinition()) { rm.addLhsItem(pattern); } RuleModelVisitor rmv = new RuleModelVisitor(ivs); rmv.visit(rm); return ivs.size() > 0; }
private String getFactType(String variable) { if (modeller.getModel().getRHSBoundFacts().contains(variable) == false) { return modeller.getModel().getLHSBindingType(variable); } else { return modeller.getModel().getRHSBoundFact(variable).getFactType(); } }
@Override protected void handleMetadataAddition(final String metadataName) { model.addMetadata(new RuleMetadata(metadataName, "")); refresh.execute(); }
@Override public List<String> getAllRHSVariables() { final Set<String> variables = new HashSet<>(); for (ActionCol52 col : dtable.getActionCols()) { if (col instanceof ActionInsertFactCol52) { final ActionInsertFactCol52 action = (ActionInsertFactCol52) col; variables.add(action.getBoundName()); } else if (col instanceof BRLActionColumn) { //Delegate to super class's implementation final RuleModel rm = new RuleModel(); final BRLActionColumn brl = (BRLActionColumn) col; rm.rhs = brl.getDefinition().toArray(new IAction[brl.getDefinition().size()]); variables.addAll(rm.getAllRHSVariables()); } } variables.addAll(super.getAllRHSVariables()); return new ArrayList<>(variables); }
@Test public void testTimerAttribute() { ruleModel.addAttribute(new RuleAttribute(RuleAttributeWidget.TIMER_ATTR, "")); ruleAttributeWidget = new RuleAttributeWidget(ruleModeller, ruleModel, isReadOnly); verify(layout).addAttribute(eq(RuleAttributeWidget.TIMER_ATTR), eq(dirtyableHorizontalPane)); verify(dirtyableHorizontalPane).add(isA(LiteralTextBox.class)); }
private void getLHSFacTypes() { for (String variable : model.getModel().getAllLHSVariables()) { factTypesByVariables.put(variable, model.getModel().getLHSBindingType(variable)); } }
@Override public String getLHSBindingType(String var) { return model.getLHSBindingType(var); }
private String getVariableType() { String type; if (oracle.isGlobalVariable(this.model.getVariable())) { type = oracle.getGlobalVariable(this.model.getVariable()); } else { type = this.getModeller().getModel().getLHSBindingType(this.model.getVariable()); if (type == null) { type = this.getModeller().getModel().getRHSBoundFact(this.model.getVariable()).getFactType(); } } return type; }
@Test public void checkAddCallMethodOnGetsAllBindings() { popup.addCallMethodOn(); verify(model).getAllLHSVariables(); verify(model).getRHSBoundFacts(); }
private void getRHSFacTypes() { for (String variable : model.getModel().getAllRHSVariables()) { factTypesByVariables.put(variable, model.getModel().getRHSBoundFact(variable).getFactType()); } }