Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
issue #327
  • Loading branch information
rsoika committed Oct 31, 2017
1 parent d399bc2 commit a4ec28c
Show file tree
Hide file tree
Showing 13 changed files with 369 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,53 @@ public ItemCollection process(final ItemCollection workitem) throws PluginExcept
return documentResult;
}

/**
* This method computes the next task based on a Model Event element. If the
* event did not point to a new task, the current task will be returned.
*
* The method supports the 'conditional-events' and 'split-events'.
*
* A conditional-event contains the attribute 'keyExclusiveConditions' defining
* conditional targets (tasks) or adds conditional follow up events
*
* A split-event contains the attribute 'keySplitConditions' defining the target
* for the current master version (condition evaluates to 'true')
*
* @return Task entity
* @throws ModelException
* @throws PluginException
*/
public ItemCollection findNextTask(ItemCollection documentContext, ItemCollection event)
throws ModelException, PluginException {

ItemCollection itemColNextTask = null;

int iNewProcessID = event.getItemValueInteger("numnextprocessid");
logger.fine("next $processid=" + iNewProcessID + "");

// test if we have an conditional exclusive Task exits...
itemColNextTask = findConditionalExclusiveTask(event, documentContext);
if (itemColNextTask != null) {
return itemColNextTask;
}

itemColNextTask = findConditionalSplitTask(event, documentContext);
if (itemColNextTask != null) {
return itemColNextTask;
}

// default behavior
if (iNewProcessID > 0) {
itemColNextTask = this.ctx.getModelManager().getModel(documentContext.getModelVersion())
.getTask(iNewProcessID);
} else {
// get current task...
itemColNextTask = this.ctx.getModelManager().getModel(documentContext.getItemValueString(MODELVERSION))
.getTask(documentContext.getProcessID());
}
return itemColNextTask;
}

/**
* This method controls the Evnet-Chain. If the attribute $activityidlist has
* more valid ActivityIDs the next activiytID will be loaded into $activity.
Expand Down Expand Up @@ -424,53 +471,6 @@ private ItemCollection processEvent(final ItemCollection documentContext, final
return documentResult;
}

/**
* This method computes the next task based on a Model Event element. If the
* event did not point to a new task, the current task will be returned.
*
* The method supports the 'conditional-events' and 'split-events'.
*
* A conditional-event contains the attribute 'keyExclusiveConditions' defining
* conditional targets (tasks) or adds conditional follow up events
*
* A split-event contains the attribute 'keySplitConditions' defining the target
* for the current master version (condition evaluates to 'true')
*
* @return Task entity
* @throws ModelException
* @throws PluginException
*/
private ItemCollection findNextTask(ItemCollection documentContext, ItemCollection event)
throws ModelException, PluginException {

ItemCollection itemColNextTask = null;

int iNewProcessID = event.getItemValueInteger("numnextprocessid");
logger.fine("next $processid=" + iNewProcessID + "");

// test if we have an conditional exclusive Task exits...
itemColNextTask = findConditionalExclusiveTask(event, documentContext);
if (itemColNextTask != null) {
return itemColNextTask;
}

itemColNextTask = findConditionalSplitTask(event, documentContext);
if (itemColNextTask != null) {
return itemColNextTask;
}

// default behavior
if (iNewProcessID > 0) {
itemColNextTask = this.ctx.getModelManager().getModel(documentContext.getModelVersion())
.getTask(iNewProcessID);
} else {
// get current task...
itemColNextTask = this.ctx.getModelManager().getModel(documentContext.getItemValueString(MODELVERSION))
.getTask(documentContext.getProcessID());
}
return itemColNextTask;
}

/**
* This method returns the first conditional Task or Event of a given Event
* object. The method evaluates conditional expressions to 'true'. If no
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,28 @@ public ItemCollection evalWorkflowResult(ItemCollection activityEntity, ItemColl
throws PluginException {
return evalWorkflowResult(activityEntity, documentContext, true);
}

/**
* This method evaluates the next task based on a Model Event element. If the
* event did not point to a new task, the current task will be returned.
*
* The method supports the 'conditional-events' and 'split-events'.
*
* A conditional-event contains the attribute 'keyExclusiveConditions' defining
* conditional targets (tasks) or adds conditional follow up events
*
* A split-event contains the attribute 'keySplitConditions' defining the target
* for the current master version (condition evaluates to 'true')
*
* @return Task entity
* @throws PluginException
* @throws ModelException
*/
public ItemCollection evalNextTask(ItemCollection documentContext, ItemCollection event)
throws PluginException, ModelException {
WorkflowKernel workflowkernel = new WorkflowKernel(this);
return workflowkernel.findNextTask(documentContext, event);
}

/**
* This method returns a n injected Plugin by name or null if not plugin with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.imixs.workflow.Plugin;
import org.imixs.workflow.WorkflowContext;
import org.imixs.workflow.engine.WorkflowService;
import org.imixs.workflow.exceptions.ModelException;
import org.imixs.workflow.exceptions.PluginException;

/**
Expand Down Expand Up @@ -188,30 +187,5 @@ public List<?> uniqueList(List<Object> valueList) {
return valueList;
}

/**
* This method returns the next Task of the current processing call based on the
* BPMN model.
*
* @return
* @throws ModelException
*/
public ItemCollection getNextTask(ItemCollection adocumentContext, ItemCollection adocumentActivity)
throws ModelException {

ItemCollection itemColNextProcess = null;
String aModelVersion = adocumentActivity.getItemValueString("$modelVersion");
int iNextProcessID = adocumentActivity.getItemValueInteger("numNextProcessID");
if (iNextProcessID > 0) {
// now get the next task
itemColNextProcess = getCtx().getModelManager().getModel(aModelVersion)
.getTask(adocumentActivity.getItemValueInteger("numNextProcessID"));

} else {
// return the current task
itemColNextProcess = getCtx().getModelManager().getModel(aModelVersion)
.getTask(adocumentActivity.getItemValueInteger("numProcessID"));
}

return itemColNextProcess;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,28 @@

/**
* This plug-in implements a generic access management control (ACL) by
* evaluating the configuration of a BPMN Event or BPMN Task. The plug-in updates the
* WorkItem attributes $ReadAccess and $WriteAccess depending on the provided
* information.
* evaluating the configuration of a BPMN Event or BPMN Task. The plug-in
* updates the WorkItem attributes $ReadAccess and $WriteAccess depending on the
* provided information.
*
* <p>
* The following attributes defined in the model element are evaluated by the plugin:
* The following attributes defined in the model element are evaluated by the
* plugin:
* <ul>
* <li>keyupdateacl (Boolean): if false the ACL will not be changed
* <li>keyaddreadfields (Vector): a list of items of the current WorkItem to be applied to the read access
* <li>keyaddwritefields (Vector): a list of items of the current WorkItem to be applied to the write access
* <li>namaddreadaccess (Vector): Names & Groups to be applied to the read access
* <li>namaddwriteaccess (Vector): Names & Groups to be applied to the write access
* <li>keyaddreadfields (Vector): a list of items of the current WorkItem to be
* applied to the read access
* <li>keyaddwritefields (Vector): a list of items of the current WorkItem to be
* applied to the write access
* <li>namaddreadaccess (Vector): Names & Groups to be applied to the read
* access
* <li>namaddwriteaccess (Vector): Names & Groups to be applied to the write
* access
* </ul>
*
* The AccessPlugin evaluates the ACL settings of the current Event element as also the
* ACL settings of the next Task element. If the current Event Element provides a ACL setting,
* the next Task element will be ignored.
* The AccessPlugin evaluates the ACL settings of the current Event element as
* also the ACL settings of the next Task element. If the current Event Element
* provides a ACL setting, the next Task element will be ignored.
*
*
* <p>
Expand Down Expand Up @@ -85,32 +90,31 @@
public class AccessPlugin extends AbstractPlugin {
ItemCollection documentContext;
ItemCollection documentActivity, documentNextProcessEntity;

private static Logger logger = Logger.getLogger(AccessPlugin.class.getName());

/**
* This method updates the $readAccess and $writeAccess attributes of a
* WorkItem depending to the configuration of a Activity Entity.
* This method updates the $readAccess and $writeAccess attributes of a WorkItem
* depending to the configuration of a Activity Entity.
*
* The method evaluates the new model flag keyupdateacl. If 'false' then acl
* will not be updated.
*
*
*/
@SuppressWarnings({ "rawtypes" })
public ItemCollection run(ItemCollection adocumentContext, ItemCollection adocumentActivity) throws PluginException {
public ItemCollection run(ItemCollection adocumentContext, ItemCollection adocumentActivity)
throws PluginException {
documentContext = adocumentContext;
documentActivity = adocumentActivity;

// get next process entity
int iNextProcessID = adocumentActivity.getItemValueInteger("numNextProcessID");
String aModelVersion = adocumentActivity.getItemValueString("$modelVersion");
try {
documentNextProcessEntity = getCtx().getModelManager().getModel(aModelVersion).getTask(iNextProcessID);
documentNextProcessEntity = this.getWorkflowService().evalNextTask(adocumentContext, adocumentActivity);
} catch (ModelException e) {
// no next task defined (follow up)
return documentContext;
throw new PluginException(AccessPlugin.class.getSimpleName(), e.getErrorCode(), e.getMessage());
}

// in case the activity is connected to a followup activity the
// nextProcess can be null!

Expand All @@ -137,16 +141,14 @@ public ItemCollection run(ItemCollection adocumentContext, ItemCollection adocum
}

/**
* This method updates the read/write access of a workitem depending on a
* given model entity The model entity should provide the following
* attributes:
* This method updates the read/write access of a workitem depending on a given
* model entity The model entity should provide the following attributes:
*
* keyupdateacl,
* namaddreadaccess,keyaddreadfields,keyaddwritefields,namaddwriteaccess
*
*
* The method did not clear the exiting values of $writeAccess and
* $readAccess
* The method did not clear the exiting values of $writeAccess and $readAccess
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateACLByItemCollection(ItemCollection modelEntity) {
Expand Down Expand Up @@ -192,6 +194,4 @@ private void updateACLByItemCollection(ItemCollection modelEntity) {

}



}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
* so other plugins can access the new properties for further operations
* http://java.net/jira/browse/IMIXS_WORKFLOW-81
*
* Version 1.3: type, workflowgroup and workfowstatus are handled by the WorkflowKernel
* Version 1.3: type, workflowgroup and workfowstatus are handled by the
* WorkflowKernel
*
* @author Ralph Soika
* @version 1.3
Expand All @@ -78,29 +79,27 @@ public class ApplicationPlugin extends AbstractPlugin {
private String sImageURL;
private String sAbstract;
private String sSummary;
@SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(ApplicationPlugin.class.getName());

public ItemCollection run(ItemCollection adocumentContext, ItemCollection adocumentActivity) throws PluginException {
public ItemCollection run(ItemCollection adocumentContext, ItemCollection adocumentActivity)
throws PluginException {

documentContext = adocumentContext;

sEditorID = null;
sImageURL = null;
sAbstract = null;
sSummary = null;
ItemCollection itemColNextProcess = null;

// try to get next ProcessEntity
ItemCollection itemColNextProcess =null;
// get next process entity
try {
// now get the next ProcessEntity from ctx
itemColNextProcess = this.getNextTask(adocumentContext, adocumentActivity);
itemColNextProcess = this.getWorkflowService().evalNextTask(adocumentContext, adocumentActivity);
} catch (ModelException e) {
logger.warning(
"Warning - unable to fetch next Task for current model '" + adocumentContext.getModelVersion() + "' : "+e.getMessage());
return documentContext;
throw new PluginException(AccessPlugin.class.getSimpleName(), e.getErrorCode(), e.getMessage());
}


// fetch Editor and Image
sEditorID = itemColNextProcess.getItemValueString("txtEditorID");
sImageURL = itemColNextProcess.getItemValueString("txtImageURL");
Expand All @@ -116,7 +115,7 @@ public ItemCollection run(ItemCollection adocumentContext, ItemCollection adocum
sSummary = getWorkflowService().adaptText(sSummary, documentContext);

// submit data now into documentcontext

// set Editor if value is defined
if (sEditorID != null && !"".equals(sEditorID))
documentContext.replaceItemValue("txtWorkflowEditorID", sEditorID);
Expand All @@ -125,9 +124,9 @@ public ItemCollection run(ItemCollection adocumentContext, ItemCollection adocum
if (sImageURL != null && !"".equals(sImageURL))
documentContext.replaceItemValue("txtWorkflowImageURL", sImageURL);


/* We still support the deprecated fields here - see issue #265
* can be removed with version 4.3.0
/*
* We still support the deprecated fields here - see issue #265 can be removed
* with version 4.3.0
*/
// set Abstract
if (sAbstract != null) {
Expand All @@ -142,6 +141,4 @@ public ItemCollection run(ItemCollection adocumentContext, ItemCollection adocum
return documentContext;
}



}
Loading

0 comments on commit a4ec28c

Please sign in to comment.