/** * Returns the count of attributes (field) the workitem has. * fieldCount() and attributeCount() are identical functions. */ public static String fieldCount (final FlowExpression fe, final InFlowWorkItem wi, final String[] args) { return ""+wi.getAttributes().size(); }
private String lookupFieldValue (final String key) { if (this.workitem == null) return null; final Attribute a = CollectionAttribute .lookupAttribute(key, this.workitem.getAttributes()); if (a == null) return null; return a.toString(); }
/** * Returns the count of attributes (field) the workitem has. * fieldCount() and attributeCount() are identical functions. */ public static String attributeCount (final FlowExpression fe, final InFlowWorkItem wi, final String[] args) { return ""+wi.getAttributes().size(); }
/** * removes any boolean result variable in this expression * (used by CondExpression) */ public static void cleanResult (final InFlowWorkItem wi) { wi.getAttributes().remove(F_RESULT); }
private boolean shouldBounceDirectly (final InFlowWorkItem wi) { final String sBounce = wi.getAttributes().sget(CORRELATION_BOUNCE); if (sBounce == null) return false; return (sBounce.equalsIgnoreCase("true")); }
/** * Returns the result held in the field '__result__'. */ public static Attribute getResult (final InFlowWorkItem wi) { return wi.getAttributes().aget(F_RESULT); }
private void addFieldsFromRegex (final String regex, final InFlowWorkItem parentWi, final InFlowWorkItem newWi) { final java.util.Iterator it = parentWi.getAttributes().keyNamesMatching(regex).iterator(); while (it.hasNext()) { final String fieldName = ((String)it.next()).trim(); if (log.isDebugEnabled()) log.debug("prepareFields() adding field '"+fieldName+"'"); final Attribute a = parentWi.getAttribute(fieldName); newWi.getAttributes().put(new StringAttribute(fieldName), a); } }
private void addFieldWithValue (final String assignation, //final InFlowWorkItem parentWi, final InFlowWorkItem newWi) { final String[] ss = assignation.split(" *= *"); final String fieldName = ss[0].trim(); final String value = ss[1].trim(); if (log.isDebugEnabled()) { log.debug ("addFieldWithValue() newWi['"+fieldName+"'] = '"+value+"'"); } newWi.getAttributes().put (new StringAttribute(fieldName), new StringAttribute(value)); }
public void reply (final InFlowWorkItem wi) throws ReplyException { wi.getAttributes().remove(F_NEXT_PARTICIPANT); super.reply(wi); }
/** * Sets the field '__result__' in the workitem. */ public static void setResult (final InFlowWorkItem wi, final Object result) { wi.getAttributes().put(F_RESULT, AttributeUtils.java2owfe(result)); // the method java2owfe leaves the result untouched if // it's already an Attribute }
/** * Sets the field '__boolean_result__' in the workitem. */ public static void setBooleanResult (final InFlowWorkItem wi, final boolean result) { //log.debug // ("setBooleanResult() '"+result+"' for "+wi.getLastExpressionId()); wi.getAttributes().put(F_RESULT, new BooleanAttribute(result)); }
protected org.jdom.Content handleField (final InFlowWorkItem wi, final String key) { final Attribute a = CollectionAttribute .lookupAttribute(key, wi.getAttributes()); return XemeUtils.toXemeResult(this, a); }
private InFlowWorkItem doInsert (final InFlowWorkItem wi, final Object workitemSource, final String fieldName) { // // fetch workitem to restore final InFlowWorkItem restoredWorkitem = fetchWorkitemToRestore(workitemSource); if (restoredWorkitem == null) return wi; // // do insert wi.getAttributes().put (new StringAttribute(fieldName), restoredWorkitem.getAttributes()); return wi; }
private void addFieldAlias (final String aliasing, final InFlowWorkItem parentWi, final InFlowWorkItem newWi) { final String[] ss = aliasing.split(" *as *"); final String newFieldName = ss[0].trim(); final String parentFieldName = ss[1].trim(); final Attribute parentValue = parentWi.getAttribute(parentFieldName); if (parentValue != null) { newWi.getAttributes() .put(new StringAttribute(newFieldName), parentValue); } }
/** * Returns the size of the given attribute, the attribute may be referenced * by a 'path' like "customers.1.address"; the size of an attribute is -1 * for an undefined attribute, 1 for an attribute and 0+ for a * MapAttribute or a ListAttribute. * The attribute's name (or path) is the first argument of the function. * If no argument is given, this method will return -2; */ public static String attsize (final FlowExpression fe, final InFlowWorkItem wi, final String[] args) { if (args.length < 1) return "-2"; final Attribute a = wi.getAttributes().getField(args[0]); if (a == null) return "-1"; if (a instanceof CollectionAttribute) return ""+((CollectionAttribute)a).size(); return "1"; }
private org.jdom.Content extractXmlFromField (final InFlowWorkItem wi, final String fieldName) throws Exception { final Attribute a = wi.getAttributes().aget(fieldName); if (a != null) { if (a instanceof StringAttribute) return XmlUtils.extractXmlElement(a.toString()); else if (a instanceof XmlAttribute) return ((XmlAttribute)a).getContent(); } return null; }
/** * Simply replies to the parent expression and sets the * appropriate value for the '__cursor_command__' field. */ public void reply (final InFlowWorkItem wi) throws ReplyException { if (shouldBreak(ValueUtils.lookupBooleanResult(wi))) { if (log.isDebugEnabled()) { log.debug ("reply() '"+this.getId().getExpressionName()+ "' should break : true"); } wi.getAttributes().puts (CursorExpression.F_COMMAND, CursorExpression.C_BREAK); } this.replyToParent(wi); }
public void apply (final InFlowWorkItem wi) throws ApplyException { String sCommand = this.getId().getExpressionName(); final String aStep = this.lookupAttribute(A_STEP, wi); if (aStep != null) sCommand = sCommand + " " + aStep; wi.getAttributes().puts(CursorExpression.F_COMMAND, sCommand); applyToParent(wi); }
/** * Applies this expression, ie dispatches the workitem to the * participant according to the participant map * (etc-engine/participants.xml) */ public void apply (final InFlowWorkItem wi) throws ApplyException { String nextParticipant = ""; ParticipantExpression peNext = fetchNext(this, wi); if (peNext != null) { nextParticipant = peNext.getParticipantName(wi); if (nextParticipant == null) nextParticipant = ""; } wi.getAttributes().puts(F_NEXT_PARTICIPANT, nextParticipant); super.apply(wi); }
/** * Produces an exact replica of this InFlowWorkItem */ public Object clone () { InFlowWorkItem clone = new InFlowWorkItem (); clone.setAttributes((StringMapAttribute)getAttributes().clone()); if (getId() != null) clone.setId(getId().copy()); clone.setParticipantName(Utils.copyString(getParticipantName())); clone.setDispatchTime(Utils.copyString(getDispatchTime())); clone.setLastModified(Time.toIsoDate()); clone.setFilter(getFilter()); clone.setHistory(HistoryItem.copyHistoryList(this.history)); return clone; }