Skip to content

Commit

Permalink
introduced $EventID, refactoring WorkflowKernel
Browse files Browse the repository at this point in the history
issue #381
  • Loading branch information
rsoika committed Jun 5, 2018
1 parent a57c2b4 commit 597be22
Showing 1 changed file with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ public class WorkflowKernel {
public static final String UNIQUEIDVERSIONS = "$uniqueidversions";
public static final String WORKITEMID = "$workitemid";
public static final String MODELVERSION = "$modelversion";

public static final String PROCESSID = "$processid";
public static final String ACTIVITYID = "$activityid";
//public static final String ACTIVITYID = "$activityid";

public static final String TASKID = "$taskid";
public static final String EVENTID = "$eventid";

public static final String ACTIVITYIDLIST = "$activityidlist";
public static final String WORKFLOWGROUP = "$workflowgroup";
public static final String WORKFLOWSTATUS = "$workflowstatus";
Expand Down Expand Up @@ -252,19 +257,22 @@ public ItemCollection process(final ItemCollection workitem) throws PluginExcept
throw new ProcessingErrorException(WorkflowKernel.class.getSimpleName(), UNDEFINED_WORKITEM,
"processing error: workitem is null");

ItemCollection documentResult = new ItemCollection(workitem);
vectorEdgeHistory = new Vector<String>();

// check $processID
if (workitem.getItemValueInteger(PROCESSID) <= 0)
throw new ProcessingErrorException(WorkflowKernel.class.getSimpleName(), UNDEFINED_PROCESSID,
"processing error: $processid undefined (" + workitem.getItemValueInteger(PROCESSID) + ")");

// check $activityid
if (workitem.getItemValueInteger(ACTIVITYID) <= 0)

// check $eventId
if (workitem.getEventID() <= 0)
throw new ProcessingErrorException(WorkflowKernel.class.getSimpleName(), UNDEFINED_ACTIVITYID,
"processing error: $activityid undefined (" + workitem.getItemValueInteger(ACTIVITYID) + ")");
"processing error: $eventid undefined (" + workitem.getEventID() + ")");


ItemCollection documentResult = new ItemCollection(workitem);
vectorEdgeHistory = new Vector<String>();


// Check if $UniqueID is available
if ("".equals(workitem.getItemValueString(UNIQUEID))) {
// generating a new one
Expand All @@ -280,7 +288,7 @@ public ItemCollection process(final ItemCollection workitem) throws PluginExcept
}

// now process all events defined by the model
while (documentResult.getItemValueInteger(ACTIVITYID) > 0) {
while (documentResult.getEventID() > 0) {
// set $lastEventDate
documentResult.replaceItemValue("$lastEventDate", new Date());
// load event...
Expand Down Expand Up @@ -351,16 +359,16 @@ public List<ItemCollection> getSplitWorkitems() {
}

/**
* This method controls the Evnet-Chain. If the attribute $activityidlist has
* This method controls the Event-Chain. If the attribute $activityidlist has
* more valid ActivityIDs the next activiytID will be loaded into $activity.
*
**/
private ItemCollection updateEventList(final ItemCollection documentContext) {
ItemCollection documentResult = documentContext;

// is $activityid already provided?
if ((documentContext.getItemValueInteger(ACTIVITYID) <= 0)) {
// no $activityID provided, so we test for property $ActivityIDList
// is $eventid already provided?
if ((documentContext.getEventID() <= 0)) {
// no $eventID provided, so we test for property $ActivityIDList
List<?> vActivityList = documentContext.getItemValue(ACTIVITYIDLIST);

// remove 0 values if contained!
Expand All @@ -384,7 +392,7 @@ private ItemCollection updateEventList(final ItemCollection documentContext) {
+ " -> loading next activityID = " + iNextID);
vActivityList.remove(0);
// update document context
documentResult.replaceItemValue(ACTIVITYID, Integer.valueOf(iNextID));
documentResult.setEventID(Integer.valueOf(iNextID));
documentResult.replaceItemValue(ACTIVITYIDLIST, vActivityList);
}
}
Expand Down Expand Up @@ -412,8 +420,8 @@ private ItemCollection processEvent(final ItemCollection documentContext, final
// log the general processing message
String msg = "processing=" + documentContext.getItemValueString(UNIQUEID) + ", MODELVERSION="
+ documentContext.getItemValueString(MODELVERSION) + ", $processid="
+ documentContext.getItemValueInteger(PROCESSID) + ", $activityid="
+ documentContext.getItemValueInteger(ACTIVITYID);
+ documentContext.getItemValueInteger(PROCESSID) + ", $eventid="
+ documentContext.getEventID();

if (ctx == null) {
logger.warning("no WorkflowContext defined!");
Expand Down Expand Up @@ -467,7 +475,7 @@ private ItemCollection processEvent(final ItemCollection documentContext, final
documentResult.replaceItemValue("txtworkflowGroup", documentResult.getItemValueString(WORKFLOWGROUP));

// clear ActivityID
documentResult.replaceItemValue(ACTIVITYID, Integer.valueOf(0));
documentResult.setEventID(Integer.valueOf(0));

// test if a FollowUp event is defined...
String sFollowUp = event.getItemValueString("keyFollowUp");
Expand Down Expand Up @@ -692,7 +700,7 @@ private void evaluateSplitEvent(ItemCollection event, ItemCollection documentCon
cloned.replaceItemValue(PROCESSID,
Integer.valueOf(itemColNextTask.getItemValueInteger("numprocessid")));

cloned.replaceItemValue(ACTIVITYID, eventID);
cloned.setEventID(eventID);
// add temporary attribute $isversion...
cloned.replaceItemValue(ISVERSION, true);
cloned = this.process(cloned);
Expand Down Expand Up @@ -858,7 +866,7 @@ private ItemCollection logEvent(final ItemCollection documentContext, final Item
private ItemCollection loadEvent(final ItemCollection documentContext) {
ItemCollection event = null;
int aProcessID = documentContext.getItemValueInteger(PROCESSID);
int aActivityID = documentContext.getItemValueInteger(ACTIVITYID);
int aActivityID = documentContext.getEventID();

// determine model version
String version = documentContext.getItemValueString(MODELVERSION);
Expand Down

0 comments on commit 597be22

Please sign in to comment.