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; }
/** * 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; }
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); } } } }
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); }
ActionInsertFact aif1 = new ActionInsertFact("Person"); aif1.setBoundName("$aif"); aif1.addFieldValue(new ActionFieldValue("rating", null, DataType.TYPE_STRING)); aif1.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_LITERAL); ActionInsertFact aif2 = new ActionInsertFact("Person"); aif2.setBoundName("$aif"); aif2.addFieldValue(new ActionFieldValue("rating", null, DataType.TYPE_STRING)); aif2.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_LITERAL); model.addRhsItem(aif2); ActionInsertFact raif2 = (ActionInsertFact) r2; assertEquals("Person", raif2.getFactType()); assertEquals("rating", raif2.getFieldValues()[0].getField()); assertEquals(DataType.TYPE_STRING, raif2.getFieldValues()[0].getType()); assertNull(raif2.getFieldValues()[0].getValue()); assertEquals(BaseSingleFieldConstraint.TYPE_LITERAL, raif2.getFieldValues()[0].getNature());
private void setupBRLActionColumn() { final BRLActionColumn brl = new BRLActionColumn(); final ActionInsertFact ifc1 = new ActionInsertFact(); ifc1.setFactType("Person"); ifc1.setBoundName("$a"); final ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_TEMPLATE); afv1.setField("name"); afv1.setValue("f1"); ifc1.addFieldValue(afv1); final ActionFieldValue afv2 = new ActionFieldValue(); afv2.setNature(FieldNatureType.TYPE_TEMPLATE); afv2.setField("age"); afv2.setValue("f2"); ifc1.addFieldValue(afv2); brl.getDefinition().add(ifc1); brl.getChildColumns().add(new BRLActionVariableColumn("f1", DataType.TYPE_STRING)); brl.getChildColumns().add(new BRLActionVariableColumn("f2", DataType.TYPE_NUMERIC_INTEGER)); model.getActionCols().add(brl); when(dmo.getFieldType(eq("Person"), eq("name"))).thenReturn(DataType.TYPE_STRING); when(dmo.getFieldType(eq("Person"), eq("age"))).thenReturn(DataType.TYPE_NUMERIC_INTEGER); } }
private void doAction(List<LabelledAction> actions, ActionInsertFactCol52 ac, String cell) { LabelledAction a = findByLabelledAction(actions, ac.getBoundName()); if (a == null) { a = new LabelledAction(); a.boundName = ac.getBoundName(); if (!ac.isInsertLogical()) { ActionInsertFact ins = new ActionInsertFact(ac.getFactType()); ins.setBoundName(ac.getBoundName()); a.action = ins; } else { ActionInsertLogicalFact ins = new ActionInsertLogicalFact(ac.getFactType()); ins.setBoundName(ac.getBoundName()); a.action = ins; } actions.add(a); } ActionInsertFact ins = (ActionInsertFact) a.action; ActionFieldValue val = new ActionFieldValue(ac.getFactField(), cell, ac.getType()); ins.addFieldValue(val); }
private Set<String> visitActionInsertFact(ActionInsertFact afl) { final Set<String> factTypes = new HashSet<String>(); factTypes.add(afl.getFactType()); return factTypes; }
private void addBrlInsertActionToModel(final GuidedDecisionTable52 model, final String factType, final String field) { final BRLActionColumn brlAction = new BRLActionColumn(); final ActionInsertFact aif = new ActionInsertFact(factType); final ActionFieldValue afv = new ActionFieldValue(field, "$var", DataType.TYPE_STRING); afv.setNature(FieldNatureType.TYPE_VARIABLE); aif.addFieldValue(afv); brlAction.setDefinition(Collections.singletonList(aif)); BRLActionVariableColumn variableColumn = new BRLActionVariableColumn("$var", DataType.TYPE_STRING, factType, field); brlAction.getChildColumns().add(variableColumn); model.getActionCols().add(brlAction); }
final ActionInsertFact aif = new ActionInsertFact(); aif.setFactType("Fact"); aif.addFieldValue(new ActionFieldValue() {{ setField("field"); setValue("10");
buf.append(">"); final String binding = action.getBoundName(); if (action.getFieldValues().length == 0 && binding == null) { buf.append((isLogic) ? "insertLogical( new " : "insert( new "); buf.append(action.getFactType()); buf.append("() );\n"); } else { buf.append(action.getFactType()); buf.append(" " + binding); buf.append(" = new "); buf.append(action.getFactType()); buf.append("();\n"); generateSetMethodCalls(binding, action.getFieldValues());
private void visitActionFieldList(ActionInsertFact afl) { String factType = afl.getFactType(); for (ActionFieldValue afv : afl.getFieldValues()) { InterpolationVariable var = new InterpolationVariable(afv.getValue(), afv.getType(), factType, afv.getField()); if (afv.getNature() == FieldNatureType.TYPE_TEMPLATE && !vars.containsKey(var)) { vars.put(var, vars.size()); } } }
public void execute() { model.addRhsItem(new ActionInsertFact(item), Integer.parseInt(positionCbo.getValue(positionCbo.getSelectedIndex()))); hide(); } });
public void onChange(ChangeEvent event) { String fieldName = box.getItemText(box.getSelectedIndex()); String fieldType = oracle.getFieldType(model.getFactType(), fieldName); model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType)); 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(); } });
boundParams.put(fact, type); ActionInsertFact action = new ActionInsertFact(type); m.addRhsItem(action); if (factsType.containsKey(fact)) { action.setBoundName(fact); addSettersToAction(setStatements, fact,
assertEquals(aif.getBoundName(), "$r"); assertEquals(1, aif.getFieldValues().length); ActionFieldValue fv1 = aif.getFieldValues()[0]; assertNotNull(fv1); assertTrue(fv1 instanceof ActionWorkItemFieldValue);
ActionValueEditor valueEditor(final ActionFieldValue actionFieldValue) { final ActionValueEditor actionValueEditor = actionValueEditor(factType, actionFieldValue, model.getFieldValues(), readOnly); actionValueEditor.setOnChangeCommand(new Command() { public void execute() { RefreshUtil.refreshActionValueEditorsDropDownData(actionValueEditors, actionFieldValue); setModified(true); } }); //Keep a reference to the value editors so they can be refreshed for dependent enums actionValueEditors.put(actionFieldValue, actionValueEditor); return actionValueEditor; }
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; }
public ActionInsertFactCol52ActionInsertFactAdaptor(final ActionInsertFactCol52 action) { PortablePreconditions.checkNotNull("action", action); this.action = action; this.setFactType(action.getFactType()); final ActionFieldValue afv = new ActionFieldValue(); afv.setField(action.getFactField()); afv.setNature(BaseSingleFieldConstraint.TYPE_LITERAL); afv.setType(action.getType()); super.addFieldValue(afv); }