public ActionCallMethod get(String variable, String methodName, String[] parameters) { this.variable = variable; this.methodName = methodName; this.parameters = parameters; ActionCallMethod actionCallMethod = new ActionCallMethod(); actionCallMethod.setMethodName(methodName); actionCallMethod.setVariable(variable); actionCallMethod.setState(ActionCallMethod.TYPE_DEFINED); for (ActionFieldFunction parameter : getActionFieldFunctions()) { actionCallMethod.addFieldValue(parameter); } return actionCallMethod; }
private RuleModel updateMethodCall(RuleModel model) { for (int i = 0; i < model.rhs.length; i++) { if (model.rhs[i] instanceof ActionCallMethod) { ActionCallMethod action = (ActionCallMethod) model.rhs[i]; // Check if method name is filled, if not this was made with an older Guvnor version if (action.getMethodName() == null || "".equals(action.getMethodName())) { if (action.getFieldValues() != null && action.getFieldValues().length >= 1) { action.setMethodName(action.getFieldValues()[0].getField()); action.setFieldValues(new ActionFieldValue[0]); action.setState(ActionCallMethod.TYPE_DEFINED); } } } } return model; } }
private ActionCallMethod visitActionCallMethod(ActionCallMethod acm) { ActionCallMethod clone = new ActionCallMethod(); clone.setVariable(acm.getVariable()); clone.setState(acm.getState()); clone.setMethodName(acm.getMethodName()); for (ActionFieldValue aff : acm.getFieldValues()) { clone.addFieldValue(cloneActionFieldFunction((ActionFieldFunction) aff)); } return clone; }
private ActionCallMethod visitActionCallMethod(ActionCallMethod acm) { ActionCallMethod clone = new ActionCallMethod(); clone.setVariable(acm.getVariable()); clone.setState(acm.getState()); clone.setMethodName(acm.getMethodName()); for (ActionFieldValue aff : acm.getFieldValues()) { clone.addFieldValue(cloneActionFieldFunction((ActionFieldFunction) aff)); } return clone; }
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; } } }
callMethod1.setVariable( "var1" ); callMethod1.setMethodName( "testMethod1 " ); callMethod1.setState( ActionCallMethod.TYPE_DEFINED ); callMethod1.addFieldValue( new ActionFieldFunction( "field1", "value1", "type1" ) ); model.addRhsItem( callMethod1 ); callMethod2.setVariable( "var2" ); callMethod2.setMethodName( "testMethod2 " ); callMethod2.setState( ActionCallMethod.TYPE_UNDEFINED ); callMethod2.addFieldValue( new ActionFieldFunction( "field2", "value2", "type2" ) ); model.addRhsItem( callMethod2 );