public static void writeWorkItem(MarshallerWriteContext context, WorkItem workItem) throws IOException { ObjectOutputStream stream = context.stream; stream.writeLong(workItem.getId()); stream.writeLong(workItem.getProcessInstanceId()); stream.writeUTF(workItem.getName()); stream.writeInt(workItem.getState()); // Work Item Parameters Map<String, Object> parameters = workItem.getParameters(); Collection<Object> notNullValues = new ArrayList<Object>(); for (Object value : parameters.values()) { if (value != null) { notNullValues.add(value); } } stream.writeInt(notNullValues.size()); for (String key : parameters.keySet()) { Object object = parameters.get(key); if (object != null) { stream.writeUTF(key); ObjectMarshallingStrategy strategy = context.objectMarshallingStrategyStore.getStrategyObject(object); String strategyClassName = strategy.getClass().getName(); stream.writeInt(-2); // backwards compatibility stream.writeUTF(strategyClassName); if (strategy.accept(object)) { strategy.write(stream, object); } } } }
public WorkItemInfo(WorkItem workItem) { this.workItem = workItem; this.name = workItem.getName(); this.creationDate = new Date(); this.processInstanceId = workItem.getProcessInstanceId(); }