private Set<String> extractExistingActionBindings(final IAction[] rhs) { final Set<String> bindings = new HashSet<String>(); for (IAction action : rhs) { if (action instanceof ActionInsertFact) { final ActionInsertFact aif = (ActionInsertFact) action; if (aif.getBoundName() != null) { bindings.add(aif.getBoundName()); } } } return bindings; }
/** * This will return the ActionInsertFact that a variable is bound to. * * @param var The bound fact variable (NOT bound field). * @return null or the ActionInsertFact found. */ public ActionInsertFact getRHSBoundFact(final String var) { if (this.rhs == null) { return null; } for (int i = 0; i < this.rhs.length; i++) { if (this.rhs[i] instanceof ActionInsertFact) { final ActionInsertFact p = (ActionInsertFact) this.rhs[i]; if (p.getBoundName() != null && var.equals(p.getBoundName())) { return p; } } } return null; }
/** * This will return a List<String> of all ActionInsertFact bindings * * @return The bindings or an empty list if no bindings are found. */ public List<String> getRHSBoundFacts() { if (this.rhs == null) { return null; } final List<String> list = new ArrayList<String>(); for (int i = 0; i < this.rhs.length; i++) { if (this.rhs[i] instanceof ActionInsertFact) { final ActionInsertFact p = (ActionInsertFact) this.rhs[i]; if (p.getBoundName() != null) { list.add(p.getBoundName()); } } } return list; }
/** * This will get a list of all RHS bound variables. */ public List<String> getAllRHSVariables() { List<String> result = new ArrayList<String>(); for (int i = 0; i < this.rhs.length; i++) { IAction pat = this.rhs[i]; if (pat instanceof ActionInsertFact) { ActionInsertFact fact = (ActionInsertFact) pat; if (fact.isBound()) { result.add(fact.getBoundName()); } } } return result; }
private void addAction(IAction action, List<LabelledAction> actions) { String binding = null; if (action instanceof ActionInsertFact) { final ActionInsertFact af = (ActionInsertFact) action; binding = af.getBoundName(); } else if (action instanceof ActionSetField) { final ActionSetField af = (ActionSetField) action; binding = af.getVariable(); } //Binding is used to group related field setters together. It is essential for //ActionInsertFactCol and ActionSetFieldCol52 columns as these represent single //fields and need to be grouped together it is not essential for IAction's as //these contain their own list of fields. If a BRL fragment does not set //the binding use a unique identifier, in this case the Object itself. if (binding == null) { binding = action.toString(); } final LabelledAction a = new LabelledAction(); a.boundName = binding; a.action = action; actions.add(a); }
protected void fixActionInsertFactBindings(final IAction[] rhs) { final Set<String> existingBindings = extractExistingActionBindings(rhs); for (IAction action : rhs) { if (action instanceof ActionInsertFact) { final ActionInsertFact aif = (ActionInsertFact) action; if (aif.getFieldValues().length > 0 && aif.getBoundName() == null) { int idx = 0; String binding = "fact" + idx; while (existingBindings.contains(binding)) { idx++; binding = "fact" + idx; } existingBindings.add(binding); aif.setBoundName(binding); } } } }
buf.append(">"); final String binding = action.getBoundName(); if (action.getFieldValues().length == 0 && binding == null) { buf.append((isLogic) ? "insertLogical( new " : "insert( new ");
public void onClick(ClickEvent event) { String var = varName.getText(); if (getModeller().isVariableNameUsed(var) && ((model.getBoundName() != null && model.getBoundName().equals(var) == false) || model.getBoundName() == null)) { Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var)); return; } model.setBoundName(var); setModified(true); getModeller().refreshWidget(); popup.hide(); } });
public void onClick(ClickEvent event) { String var = varName.getText(); if (getModeller().isVariableNameUsed(var) && ((model.getBoundName() != null && model.getBoundName().equals(var) == false) || model.getBoundName() == null)) { Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var)); return; } model.setBoundName(var); setModified(true); getModeller().refreshWidget(); popup.hide(); } });
private Widget getAssertLabel() { ClickHandler cl = new ClickHandler() { public void onClick(ClickEvent event) { Widget w = (Widget) event.getSource(); showAddFieldPopup(w); } }; String assertType = "assert"; //NON-NLS if (this.model instanceof ActionInsertLogicalFact) { assertType = "assertLogical"; //NON-NLS } String lbl = (model.isBound() == false) ? HumanReadable.getActionDisplayName(assertType) + " <b>" + this.model.getFactType() + "</b>" : HumanReadable.getActionDisplayName(assertType) + " <b>" + this.model.getFactType() + "</b>" + " <b>[" + model.getBoundName() + "]</b>"; if (this.model.getFieldValues() != null && model.getFieldValues().length > 0) { lbl = lbl + ":"; } return new ClickableLabel(lbl, cl, !this.readOnly); }
private Widget getAssertLabel() { ClickHandler cl = new ClickHandler() { public void onClick(ClickEvent event) { Widget w = (Widget) event.getSource(); showAddFieldPopup(w); } }; String assertType = "assert"; //NON-NLS if (this.model instanceof ActionInsertLogicalFact) { assertType = "assertLogical"; //NON-NLS } String lbl = (model.isBound() == false) ? HumanReadable.getActionDisplayName(assertType) + " <b>" + this.model.getFactType() + "</b>" : HumanReadable.getActionDisplayName(assertType) + " <b>" + this.model.getFactType() + "</b>" + " <b>[" + model.getBoundName() + "]</b>"; if (this.model.getFieldValues() != null && model.getFieldValues().length > 0) { lbl = lbl + ":"; } return new ClickableLabel(lbl, cl, !this.readOnly); }
private ActionInsertFact visitActionFieldList(ActionInsertFact afl) { ActionInsertFact clone = new ActionInsertFact(); clone.setFactType(afl.getFactType()); clone.setBoundName(afl.getBoundName()); for (ActionFieldValue afv : afl.getFieldValues()) { ActionFieldValue afvClone = new ActionFieldValue(); afvClone.setField(afv.getField()); afvClone.setNature(afv.getNature()); afvClone.setType(afv.getType()); afvClone.setValue(afv.getValue()); clone.addFieldValue(afvClone); } return clone; }
private ActionInsertFact visitActionFieldList(ActionInsertFact afl) { ActionInsertFact clone = new ActionInsertFact(); clone.setFactType(afl.getFactType()); clone.setBoundName(afl.getBoundName()); for (ActionFieldValue afv : afl.getFieldValues()) { ActionFieldValue afvClone = new ActionFieldValue(); afvClone.setField(afv.getField()); afvClone.setNature(afv.getNature()); afvClone.setType(afv.getType()); afvClone.setValue(afv.getValue()); clone.addFieldValue(afvClone); } return clone; }
if (this.model.getBoundName() != null) { varName.setText(this.model.getBoundName());
if (this.model.getBoundName() != null) { varName.setText(this.model.getBoundName());
actionCol1aif0.getBoundName()); assertEquals("Transaction", actionCol1aif0.getFactType());
actionCol1aif0.getBoundName()); assertEquals("Transaction", actionCol1aif0.getFactType());
assertEquals(aif.getBoundName(), "$r"); assertEquals(1,
assertEquals(aif.getBoundName(), "$r"); assertEquals(4,