Skip to content

Commit

Permalink
implementation
Browse files Browse the repository at this point in the history
Issue #669
  • Loading branch information
rsoika committed May 18, 2020
1 parent 3a17758 commit 45660ec
Show file tree
Hide file tree
Showing 2 changed files with 461 additions and 429 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

package org.imixs.workflow;

import java.math.BigInteger;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -39,6 +41,7 @@
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.imixs.workflow.exceptions.AdapterException;
import org.imixs.workflow.exceptions.ModelException;
import org.imixs.workflow.exceptions.PluginException;
Expand Down Expand Up @@ -76,6 +79,7 @@ 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 TRANSACTIONID = "$transactionid";

@Deprecated
public static final String PROCESSID = "$processid";
Expand Down Expand Up @@ -134,13 +138,26 @@ public WorkflowKernel(final WorkflowContext actx) {
*
* @see https://docs.oracle.com/javase/8/docs/api/java/util/UUID.html
*
* @return
* @return UUID
*/
public static String generateUniqueID() {
String id = UUID.randomUUID().toString();
return id;
}

/**
* This method generates an secure 8 byte random secure id. The ID is returned
* as a hex decimal value.
*
* @return transactionID
*/
public static String generateTransactionID() {
SecureRandom random = new SecureRandom();
byte bytes[] = new byte[8];
random.nextBytes(bytes);
return new BigInteger(1, bytes).toString(16);
}

/**
* This method registers a new plugin class. The method throws a PluginException
* if the class can not be registered.
Expand Down Expand Up @@ -306,6 +323,9 @@ public ItemCollection process(final ItemCollection workitem) throws PluginExcept
// generating a new one
documentResult.replaceItemValue(UNIQUEID, generateUniqueID());
}

// Generate a $TransactionID
documentResult.replaceItemValue(TRANSACTIONID,generateTransactionID());

// store last $lastTask
documentResult.replaceItemValue("$lastTask", workitem.getTaskID());
Expand Down Expand Up @@ -521,16 +541,13 @@ private ItemCollection updateModelVersionByEvent(final ItemCollection documentCo
ItemCollection documentResult = documentContext;
// test if a <model> tag is defined
String eventResult = event.getItemValueString("txtActivityResult");

List<String> modelTags = XMLParser.findNoEmptyTags(eventResult, "model");
if (modelTags!=null && modelTags.size()>0) {
//if (eventResult.contains("<model")) {
if (modelTags != null && modelTags.size() > 0) {
// extract the model tag information - version and event are mandatory
ItemCollection modelData;
//modelData = XMLParser.parseTag(eventResult, "model");

modelData = XMLParser.parseTag(modelTags.get(0), "model");

String version = modelData.getItemValueString("version");
int iNextEvent = modelData.getItemValueInteger("event");
int iTask = modelData.getItemValueInteger("task");
Expand Down
Loading

0 comments on commit 45660ec

Please sign in to comment.