/** * An alias for puts(). */ public void sput (final String key, final String value) { this.puts(key, value); }
public void consume (WorkItem wi) throws Exception { System.out.println("~~~ a"); wi.getAttributes().puts("value", "CHF 10.-"); replyToEngine((InFlowWorkItem)wi); } });
public void consume (WorkItem wi) throws Exception { System.out.println("~~~ a"); wi.getAttributes().puts("value", "CHF 10.-"); replyToEngine((InFlowWorkItem)wi); }
private void flatten (final InFlowWorkItem wi, final String fieldName, final String toFieldName, final ListAttribute la, final String separator, final boolean trim) { StringBuffer sb = new StringBuffer(); final java.util.Iterator it = la.iterator(); while (it.hasNext()) { final Attribute a = (Attribute)it.next(); if (sb.length() > 0) sb.append(separator); sb.append(a.toString()); } String fn = fieldName; if (toFieldName != null) fn = toFieldName; wi.getAttributes().puts(fn, sb.toString()); if (log.isDebugEnabled()) log.debug("flatten() '"+fn+"' -> '"+sb.toString()+"'"); }
/** * Turns a java bean into a StringMapAttribute. */ public static StringMapAttribute bean2owfe (final Object o) { final StringMapAttribute sma = new StringMapAttribute(); // // class name sma.puts(A_BEAN_CLASSNAME, o.getClass().getName()); // // fields final java.util.Iterator it = ReflectionUtils.listReadWriteFields(o).iterator(); while (it.hasNext()) resolveGet(sma, o, (Method[])it.next()); return sma; }
private void expand (final InFlowWorkItem wi, final String fieldName, final String value, String separator) { if (separator.equals("|")) separator = "\\|"; // // there may be other special cases, but for now, it's sufficient // // do the job wi.getAttributes().remove(fieldName); final String[] ss = value.split(separator); for (int i=0; i<ss.length; i++) { final String fn = fieldName + UU + i; wi.getAttributes().puts(fn, ss[i]); if (log.isDebugEnabled()) log.debug("expand() '"+fn+"' -> '"+ss[i]+"'"); } final String fn = fieldName + UU + "count"; wi.getAttributes().puts(fn, ""+ss.length); if (log.isDebugEnabled()) log.debug("expand() '"+fn+"' -> '"+ss.length+"'."); }
private void flatten (final InFlowWorkItem wi, final String fieldName, final String separator) { StringBuffer sb = new StringBuffer(); int i = 0; while (true) { final String fn = fieldName + UU + i; final String s = wi.getAttributes().sget(fn); if (i == 0 && s == null) { log.info("flatten() nothing to do (no field '"+fn+"')"); return; } if (s == null) break; if (sb.length() > 0) sb.append(separator); sb.append(s); wi.getAttributes().remove(fn); i++; } wi.getAttributes().puts(fieldName, sb.toString()); if (log.isDebugEnabled()) log.debug("flatten() '"+fieldName+"' -> '"+sb.toString()+"'"); }
result.getAttributes().puts(field, value);
public static void main (String[] args) throws Exception { // // encoding InFlowWorkItem wi = new InFlowWorkItem(); wi.setId(new FlowExpressionId()); wi.getAttributes().puts("mf_fields", "color, size, quantity"); wi.getAttributes().puts("mf_header", "This is our offer"); wi.getAttributes().puts("mf_footer", "Best regards,\n\nJohn"); wi.getAttributes().puts("color", "blue"); wi.getAttributes().puts("size", "XL"); WorkItemCoder coder = new MailFormCoder(); String s = new String ((byte[])coder.encode(wi, null, null), Utils.getEncoding()); System.out.println(s); // // decoding wi = (InFlowWorkItem)coder .decode(new java.io.StringReader(s), null, null); System.out.println(); System.out.println("color : "+wi.getAttributes().sget("color")); System.out.println("size : "+wi.getAttributes().sget("size")); System.out.println("quantity : "+wi.getAttributes().sget("quantity")); }
/** * Overrides AbstractFlowExpression.applyToParent(), to make sure the * children are removed as well from the expression pool (they are just * templates anyway). */ public void applyToParent (final InFlowWorkItem wi) throws ApplyException { wi.getAttributes().puts(this.cursorCommandField, ""); // reset the cursor command // // clean templates final java.util.Iterator it = getChildren().iterator(); while (it.hasNext()) { final FlowExpressionId childId = (FlowExpressionId)it.next(); getExpressionPool().removeExpression(childId); } // // reply to parent super.applyToParent(wi); }
wi.getAttributes().puts(F_FUNCTION_ERROR, t.toString());
launchItem.setWorkflowDefinitionUrl(WorkflowConstants.ATTRIBUTE_WORKFLOW_DEFINITION_URL); String flowDef = readDefinition(workflowName); launchItem.getAttributes().puts(WorkflowConstants.ATTRIBUTE_DEFINITION, flowDef);
/** * Set a date stored in the repository into the list of attributes of the launch item. Ignore past activation dates * <ul> * <li>get utc calendar from repository</li> * <li>convert utc to local calendar</li> * <li>get string time for open wfe from local calendar</li> * <li>set string attribute of the launch item</li> * </ul> */ private void updateDateAttribute(Content node, LaunchItem launchItem, String attributeName) { final SimpleDateFormat sdf = new SimpleDateFormat(WorkflowConstants.OPENWFE_DATE_FORMAT); try { if (node.hasNodeData(attributeName)) { Calendar cd = node.getNodeData(attributeName).getDate(); // utc calendar from repository Calendar now = DateUtil.getCurrentUTCCalendar(); if (cd.before(now) && isActivationDate(attributeName)) { log.info("Ignoring past activation date:" + attributeName + " from node:" + node.getHandle()); } else { String date = sdf.format(new Date(DateUtil.getLocalCalendarFromUTC(cd).getTimeInMillis())); launchItem.getAttributes().puts(attributeName, date); } } } catch (Exception e) { log.warn("cannot set date:" + attributeName + " for node" + node.getHandle(), e); } }
/** * 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 static void proceed(String id, String action, String comment) { InFlowWorkItem wi = getWorkItem(id); if (wi == null) { log.error("can't proceed workitem [{}]", id); return; } wi.touch(); // remove old exception if(wi.containsAttribute(Context.ATTRIBUTE_EXCEPTION)){ wi.removeAttribute(Context.ATTRIBUTE_EXCEPTION); } if(wi.containsAttribute(Context.ATTRIBUTE_MESSAGE)){ wi.removeAttribute(Context.ATTRIBUTE_MESSAGE); } wi.getAttributes().puts(WorkflowConstants.ATTRIBUTE_ACTION, action); wi.getAttributes().puts(WorkflowConstants.ATTRIBUTE_USERNAME, MgnlContext.getUser().getName()); if (StringUtils.isNotEmpty(comment)) { wi.getAttributes().puts(Context.ATTRIBUTE_COMMENT, comment); } proceed(wi); }
attributes.puts (Header.WF_INSTANCE_ID, wi.getLastExpressionId().getWorkflowInstanceId()); attributes.puts (Header.WF_DEFINITION_NAME, wi.getLastExpressionId().getWorkflowDefinitionName()); attributes.puts (Header.WF_DEFINITION_REVISION, wi.getLastExpressionId().getWorkflowDefinitionRevision()); attributes.puts (Header.WF_DEFINITION_URL, wi.getLastExpressionId().getWorkflowDefinitionUrl()); attributes.puts (Header.DISPATCH_TIME, wi.getDispatchTime()); attributes.puts (Header.PARTICIPANT_NAME, wi.getParticipantName()); attributes.puts(Header.LOCKER_NAME, lockerName); attributes.puts (ha.getName(), ha.getValue(this.scope, wi).trim());
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); }
attributes.puts (Header.WF_INSTANCE_ID, wi.getLastExpressionId().getWorkflowInstanceId()); attributes.puts (Header.WF_DEFINITION_NAME, wi.getLastExpressionId().getWorkflowDefinitionName()); attributes.puts (Header.WF_DEFINITION_REVISION, wi.getLastExpressionId().getWorkflowDefinitionRevision()); attributes.puts (Header.WF_DEFINITION_URL, wi.getLastExpressionId().getWorkflowDefinitionUrl()); attributes.puts (Header.DISPATCH_TIME, wi.getDispatchTime()); attributes.puts (Header.PARTICIPANT_NAME, wi.getParticipantName()); attributes.puts(Header.LOCKER_NAME, lockerName);
li.setWorkflowDefinitionUrl("field:__def__"); li.getAttributes().puts("__def__", sb.toString());