private ActionSetFieldWrapper findExistingAction(final ActionSetField asf, final List<IAction> actions) { for (IAction action : actions) { if (action instanceof ActionSetFieldWrapper) { final ActionSetFieldWrapper afw = (ActionSetFieldWrapper) action; if (asf.getVariable().equals(afw.getAction().getVariable()) && (asf instanceof ActionUpdateField) == afw.isUpdate()) { return afw; } } } return null; }
private Optional<String> getType(final RuleModel ruleModel, final ActionFieldList actionFieldList) { if (actionFieldList instanceof ActionInsertFact) { return Optional.of(((ActionInsertFact) actionFieldList).getFactType()); } else if (actionFieldList instanceof ActionSetField) { final String var = ((ActionSetField) actionFieldList).getVariable(); return Optional.ofNullable(ruleModel.getLHSBindingType(var)); } return Optional.empty(); } }
private Optional<String> getType(final RuleModel ruleModel, final ActionFieldList actionFieldList) { if (actionFieldList instanceof ActionInsertFact) { return Optional.of(((ActionInsertFact) actionFieldList).getFactType()); } else if (actionFieldList instanceof ActionSetField) { final String var = ((ActionSetField) actionFieldList).getVariable(); return Optional.ofNullable(ruleModel.getLHSBindingType(var)); } return Optional.empty(); } }
/** * @param binding The name of the LHS fact binding. * @return Returns true if the specified binding is used on the RHS. */ public boolean isBoundFactUsed(final String binding) { if (this.rhs == null) { return false; } for (int i = 0; i < this.rhs.length; i++) { if (this.rhs[i] instanceof ActionSetField) { final ActionSetField set = (ActionSetField) this.rhs[i]; if (set.getVariable().equals(binding)) { return true; } } else if (this.rhs[i] instanceof ActionRetractFact) { final ActionRetractFact ret = (ActionRetractFact) this.rhs[i]; if (ret.getVariableName().equals(binding)) { return true; } } } return false; }
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); }
private Widget getSetterLabel() { ClickHandler clk = new ClickHandler() { public void onClick(ClickEvent event) { //Widget w = (Widget)event.getSource(); showAddFieldPopup(event); } }; String modifyType = "set"; if (this.model instanceof ActionUpdateField) { modifyType = "modify"; } String type = this.getModeller().getModel().getLHSBindingType(model.getVariable()); String descFact = (type != null) ? type + " <b>[" + model.getVariable() + "]</b>" : model.getVariable(); String sl = GuidedRuleEditorResources.CONSTANTS.setterLabel(HumanReadable.getActionDisplayName(modifyType), descFact); return new ClickableLabel(sl, clk, !this.readOnly);//HumanReadable.getActionDisplayName(modifyType) + " value of <b>[" + model.variable + "]</b>", clk); }
private Widget getSetterLabel() { ClickHandler clk = new ClickHandler() { public void onClick(ClickEvent event) { //Widget w = (Widget)event.getSource(); showAddFieldPopup(event); } }; String modifyType = "set"; if (this.model instanceof ActionUpdateField) { modifyType = "modify"; } String type = this.getModeller().getModel().getLHSBindingType(model.getVariable()); String descFact = (type != null) ? type + " <b>[" + model.getVariable() + "]</b>" : model.getVariable(); String sl = GuidedRuleEditorResources.CONSTANTS.setterLabel(HumanReadable.getActionDisplayName(modifyType), descFact); return new ClickableLabel(sl, clk, !this.readOnly);//HumanReadable.getActionDisplayName(modifyType) + " value of <b>[" + model.variable + "]</b>", clk); }
private void visitActionFieldList(ActionSetField afl) { String factType = model.getLHSBindingType(afl.getVariable()); 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()); } } }
static String inferDataTypeFromAction(final ActionFieldList action, final String field, final String value, final boolean isJavaDialect, final Map<String, String> boundParams, final PackageDataModelOracle dmo, final Imports imports) { String factType = null; if (action instanceof ActionInsertFact) { factType = ((ActionInsertFact) action).getFactType(); } else if (action instanceof ActionSetField) { String boundParam = ((ActionSetField) action).getVariable(); factType = boundParams.get(boundParam); } final String type = inferDataTypeFromModelFields(factType, field, dmo, imports); if (type != null) { return type; } return RuleModelPersistenceHelper.inferDataTypeFromActionValue(value, boundParams, isJavaDialect); }
public void visitActionSetField(final ActionSetField action) { if (action instanceof ActionCallMethod) { this.generateSetMethodCallsMethod((ActionCallMethod) action, action.getFieldValues()); } else { this.generateSetMethodCalls(action.getVariable(), action.getFieldValues()); } }
private void visitActionFieldList(final ActionSetField afl) { String factType = model.getLHSBindingType(afl.getVariable()); for (ActionFieldValue afv : afl.getFieldValues()) { InterpolationVariable var = new InterpolationVariable(afv.getValue(), afv.getType(), factType, afv.getField()); if (afv.getNature() == FieldNatureType.TYPE_TEMPLATE && !vars.contains(var)) { vars.add(var); } else { hasNonTemplateOutput = true; } } }
private ActionSetField visitActionFieldList(ActionSetField afl) { ActionSetField clone = new ActionSetField(); clone.setVariable(afl.getVariable()); for (ActionFieldValue afv : afl.getFieldValues()) { clone.addFieldValue(cloneActionFieldValue(afv)); } return clone; }
ActionValueEditor valueEditor(final ActionFieldValue actionFieldValue) { AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle(); String type = ""; if (oracle.isGlobalVariable(this.model.getVariable())) { type = oracle.getGlobalVariable(this.model.getVariable()); } else { type = this.getModeller().getModel().getLHSBindingType(this.model.getVariable()); /* * to take in account if the using a rhs bound variable */ if (type == null && !this.readOnly) { type = this.getModeller().getModel().getRHSBoundFact(this.model.getVariable()).getFactType(); } } ActionValueEditor actionValueEditor = actionValueEditor(type, 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 ActionSetField visitActionFieldList(ActionSetField afl) { ActionSetField clone = new ActionSetField(); clone.setVariable(afl.getVariable()); for (ActionFieldValue afv : afl.getFieldValues()) { clone.addFieldValue(cloneActionFieldValue(afv)); } return clone; }
ActionValueEditor valueEditor(final ActionFieldValue actionFieldValue) { AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle(); String type = ""; if (oracle.isGlobalVariable(this.model.getVariable())) { type = oracle.getGlobalVariable(this.model.getVariable()); } else { type = this.getModeller().getModel().getLHSBindingType(this.model.getVariable()); /* * to take in account if the using a rhs bound variable */ if (type == null && !this.readOnly) { type = this.getModeller().getModel().getRHSBoundFact(this.model.getVariable()).getFactType(); } } ActionValueEditor actionValueEditor = actionValueEditor(type, 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; }
if (oracle.isGlobalVariable(set.getVariable())) { oracle.getFieldCompletionsForGlobalVariable(set.getVariable(), new Callback<ModelField[]>() { @Override this.variableClass = oracle.getGlobalVariable(set.getVariable()); } else { String type = mod.getModel().getLHSBindingType(set.getVariable()); if (type != null) { oracle.getFieldCompletions(type, this.isBoundFact = true; } else { ActionInsertFact patternRhs = mod.getModel().getRHSBoundFact(set.getVariable()); if (patternRhs != null) { oracle.getFieldCompletions(patternRhs.getFactType(), ErrorPopup.showMessage(GuidedRuleEditorResources.CONSTANTS.CouldNotFindTheTypeForVariable0(set.getVariable()));
if (oracle.isGlobalVariable(set.getVariable())) { oracle.getFieldCompletionsForGlobalVariable(set.getVariable(), new Callback<ModelField[]>() { @Override this.variableClass = oracle.getGlobalVariable(set.getVariable()); } else { String type = mod.getModel().getLHSBindingType(set.getVariable()); if (type != null) { oracle.getFieldCompletions(type, this.isBoundFact = true; } else { ActionInsertFact patternRhs = mod.getModel().getRHSBoundFact(set.getVariable()); if (patternRhs != null) { oracle.getFieldCompletions(patternRhs.getFactType(), ErrorPopup.showMessage(GuidedRuleEditorResources.CONSTANTS.CouldNotFindTheTypeForVariable0(set.getVariable()));
if (action instanceof ActionSetField) { final ActionSetField asf = (ActionSetField) action; final String typeName = getTypeNameForBinding(asf.getVariable()); if (typeName != null) { final String fullyQualifiedClassName = getFullyQualifiedClassName(typeName);
if (action instanceof ActionSetField) { final ActionSetField asf = (ActionSetField) action; final String typeName = getTypeNameForBinding(asf.getVariable()); if (typeName != null) { final String fullyQualifiedClassName = getFullyQualifiedClassName(typeName);
private ActionSetField clone(final ActionSetField action) { if (action instanceof ActionUpdateField) { final ActionUpdateField auf = (ActionUpdateField) action; final ActionUpdateField clone = new ActionUpdateField(auf.getVariable()); clone.setFieldValues(auf.getFieldValues()); return clone; } else if (action instanceof ActionCallMethod) { final ActionCallMethod acm = (ActionCallMethod) action; final ActionCallMethod clone = new ActionCallMethod(acm.getVariable()); clone.setState(acm.getState()); clone.setMethodName(acm.getMethodName()); clone.setFieldValues(acm.getFieldValues()); return clone; } else if (action instanceof ActionSetField) { final ActionSetField clone = new ActionSetField(action.getVariable()); clone.setFieldValues(action.getFieldValues()); return clone; } else { return action; } } }