private ActionUpdateField visitActionFieldList(ActionUpdateField auf) { ActionUpdateField clone = new ActionUpdateField(); clone.setVariable(auf.getVariable()); for (ActionFieldValue afv : auf.getFieldValues()) { clone.addFieldValue(cloneActionFieldValue(afv)); } 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; } } }
public void visitActionUpdateField(final ActionUpdateField action) { final RHSGeneratorContext gctx = generatorContextFactory.newChildGeneratorContext(rootContext, action); preGenerateAction(gctx); buf.append(indentation); if (isDSLEnhanced) { buf.append(">"); } buf.append("modify( ").append(action.getVariable()).append(" ) {\n"); this.generateModifyMethodCalls(action.getFieldValues(), gctx); buf.append("\n").append(indentation); if (isDSLEnhanced) { buf.append(">"); } buf.append("}\n"); postGenerateAction(gctx); }
ActionUpdateField auf1 = new ActionUpdateField("x"); auf1.addFieldValue(new ActionFieldValue("f1", "$f1", DataType.TYPE_STRING)); auf1.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE); "Context", "f1")); ActionUpdateField auf2 = new ActionUpdateField("x"); auf2.addFieldValue(new ActionFieldValue("f2", "$f2", DataType.TYPE_STRING)); auf2.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE); "f2")); ActionUpdateField auf3 = new ActionUpdateField("x"); auf3.addFieldValue(new ActionFieldValue("f3", "$f3", DataType.TYPE_STRING)); auf3.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
m.addLhsItem(fp); ActionUpdateField auf1 = new ActionUpdateField("$p"); ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_TEMPLATE); afv0.setField("field1"); afv0.setValue("$f1"); auf1.addFieldValue(afv0); afv1.setField("field2"); afv1.setValue("$f2"); auf1.addFieldValue(afv1); afv2.setField("field3"); afv2.setValue("$f3"); auf1.addFieldValue(afv2);
private TemplateModel getComplexModel() { final TemplateModel m = new TemplateModel(); m.addAttribute(new RuleAttribute("no-loop", "true")); final FactPattern pat = new FactPattern("Person"); pat.setBoundName("p1"); final SingleFieldConstraint con = new SingleFieldConstraint(); con.setFactType("Person"); con.setFieldBinding("f1"); con.setFieldName("age"); con.setOperator("<"); con.setValue("42"); pat.addConstraint(con); m.addLhsItem(pat); final CompositeFactPattern comp = new CompositeFactPattern("not"); comp.addFactPattern(new FactPattern("Cancel")); m.addLhsItem(comp); final ActionUpdateField set = new ActionUpdateField(); set.setVariable("p1"); set.addFieldValue(new ActionFieldValue("status", "rejected", DataType.TYPE_STRING)); m.addRhsItem(set); final ActionRetractFact ret = new ActionRetractFact("p1"); m.addRhsItem(ret); final DSLSentence sen = new DSLSentence(); sen.setDefinition("Send an email to {administrator}"); m.addRhsItem(sen); return m; }
private void addModify(String itemText, int position) { this.model.addRhsItem(new ActionUpdateField(itemText), position); } }
ActionUpdateField action = new ActionUpdateField(); action.setVariable(modifiedVariable); m.addRhsItem(action); addModifiersToAction(modifiers, ActionUpdateField action = new ActionUpdateField(); action.setVariable(variable); m.addRhsItem(action); addSettersToAction(setStatements, String variable = line.substring(line.indexOf('(') + 1, line.indexOf(')')).trim(); ActionUpdateField action = new ActionUpdateField(); action.setVariable(variable); m.addRhsItem(action); addModifiersToAction(line.substring(line.indexOf('{') + 1,
a.action = new ActionSetField(sf.getBoundName()); } else { a.action = new ActionUpdateField(sf.getBoundName()); ActionUpdateField update = new ActionUpdateField(sf.getBoundName()); update.setFieldValues(old.getFieldValues()); a.action = update;
ActionUpdateField auf1 = new ActionUpdateField("x"); auf1.addFieldValue(new ActionFieldValue("f1", "$f1", DataType.TYPE_STRING)); auf1.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE); "Context", "f1")); ActionUpdateField auf2 = new ActionUpdateField("x"); auf2.addFieldValue(new ActionFieldValue("f2", "$f2", DataType.TYPE_STRING)); auf2.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE); "f2")); ActionUpdateField auf3 = new ActionUpdateField("x"); auf3.addFieldValue(new ActionFieldValue("f3", "$f3", DataType.TYPE_STRING)); auf3.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
m.addLhsItem(fp); ActionUpdateField auf1 = new ActionUpdateField("$p"); ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_LITERAL); afv0.setField("field1"); afv0.setValue("foo"); auf1.addFieldValue(afv0); ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_TEMPLATE); afv1.setField("field2"); afv1.setValue("$f2"); auf1.addFieldValue(afv1);
model.addRhsItem( aif ); ActionUpdateField auf = new ActionUpdateField(); auf.setVariable( "$var" ); auf.addFieldValue( buildActionFieldValue() ); auf.addFieldValue( buildActionFieldValue() ); model.addRhsItem( auf );
private void addModify(String itemText, int position) { this.model.addRhsItem(new ActionUpdateField(itemText), position); } }
private void visitActionFieldList(ActionUpdateField 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()); } } }
private void doAction(List<LabelledAction> actions, ActionSetFieldCol52 sf, String cell) { LabelledAction a = findByLabelledAction(actions, sf.getBoundName(), sf.isUpdate()); if (a == null) { a = new LabelledAction(); a.boundName = sf.getBoundName(); a.isUpdate = sf.isUpdate(); if (!sf.isUpdate()) { a.action = new ActionSetField(sf.getBoundName()); } else { a.action = new ActionUpdateField(sf.getBoundName()); } actions.add(a); } else if (sf.isUpdate() && !(a.action instanceof ActionUpdateField)) { // lets swap it out for an update as the user has asked for it. ActionSetField old = (ActionSetField) a.action; ActionUpdateField update = new ActionUpdateField(sf.getBoundName()); update.setFieldValues(old.getFieldValues()); a.action = update; } ActionSetField asf = (ActionSetField) a.action; ActionFieldValue val = new ActionFieldValue(sf.getFactField(), cell, sf.getType()); asf.addFieldValue(val); }
ActionUpdateField auf1 = new ActionUpdateField("x"); auf1.addFieldValue(new ActionFieldValue("f1", "$f1", DataType.TYPE_STRING)); auf1.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE); "Context", "f1")); ActionUpdateField auf2 = new ActionUpdateField("x"); auf2.addFieldValue(new ActionFieldValue("f2", "$f2", DataType.TYPE_STRING)); auf2.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE); "f2")); ActionUpdateField auf3 = new ActionUpdateField("x"); auf3.addFieldValue(new ActionFieldValue("f3", "$f3", DataType.TYPE_STRING)); auf3.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
m.addLhsItem(fp); ActionUpdateField auf1 = new ActionUpdateField("$p"); ActionFieldValue afv0 = new ActionFieldValue(); afv0.setNature(FieldNatureType.TYPE_TEMPLATE); afv0.setField("field1"); afv0.setValue("$f1"); auf1.addFieldValue(afv0); ActionFieldValue afv1 = new ActionFieldValue(); afv1.setNature(FieldNatureType.TYPE_LITERAL); afv1.setField("field2"); afv1.setValue("bar"); auf1.addFieldValue(afv1);
private ActionUpdateField visitActionFieldList(ActionUpdateField auf) { ActionUpdateField clone = new ActionUpdateField(); clone.setVariable(auf.getVariable()); for (ActionFieldValue afv : auf.getFieldValues()) { clone.addFieldValue(cloneActionFieldValue(afv)); } return clone; }
DataType.TYPE_NUMERIC_INTEGER)); final ActionUpdateField auf = new ActionUpdateField(); asf.setVariable("$m"); asf.addFieldValue(new ActionFieldValue("amount",
private void visitActionFieldList(final ActionUpdateField 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; } } }