10-11-2010 11:20 AM
10-12-2010 05:18 AM
10-12-2010 05:29 AM
10-12-2010 06:23 AM
public class ForEachSubProcessActivity extends AbstractBpmnActivity implements CompositeActivityBehavior
{
//
// Fields
private String collectionVariableName;
private String indexVariableName;
private String itemVariableName;
//
// Initialization
public ForEachSubProcessActivity(String collectionVariableName, String indexVariableName, String itemVariableName)
{
this.collectionVariableName = collectionVariableName;
this.indexVariableName = indexVariableName;
this.itemVariableName = itemVariableName;
}
//
// Behavior implementation
@Override
public void execute(ActivityExecution execution) throws Exception
{
if (collectionVariableName == null)
leave(execution);
List collection = (List) execution.getVariable(collectionVariableName);
if (collection == null)
{
leave(execution);
return;
}
int currentIndex = 0;
if (collection.size() < currentIndex + 1)
{
leave(execution);
return;
}
Object currentItem = collection.get(currentIndex);
execution.setVariable(indexVariableName, currentIndex);
execution.setVariable(itemVariableName, currentItem);
PvmActivity activity = execution.getActivity();
ActivityImpl initialActivity = (ActivityImpl) activity.getProperty(BpmnParse.PROPERTYNAME_INITIAL);
execution.executeActivity(initialActivity);
}
@Override
public void lastExecutionEnded(ActivityExecution execution)
{
int currentIndex = (Integer)execution.getVariable(indexVariableName);
List collection = (List) execution.getVariable(collectionVariableName);
currentIndex++;
if (collection.size() < currentIndex + 1)
{
// TODO: Remove the variables
// the following lines wouldn't work. It causes an exception.
// execution.setVariable(indexVariableName, null);
// execution.setVariable(itemVariableName, null);
List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions();
execution.takeAll(outgoingTransitions, new ArrayList<ActivityExecution>());
return;
}
Object currentItem = collection.get(currentIndex);
execution.setVariable(indexVariableName, currentIndex);
execution.setVariable(itemVariableName, currentItem);
PvmActivity activity = execution.getActivity();
ActivityImpl initialActivity = (ActivityImpl) activity.getProperty(BpmnParse.PROPERTYNAME_INITIAL);
execution.executeActivity(initialActivity);
}
}
10-12-2010 07:05 AM
10-12-2010 08:28 AM
public ExecutionQueryImpl processInstanceId(String processInstanceId) {
if (processInstanceId == null) {
throw new ActivitiException("Process instance id is null");
}
this.processInstanceId = processInstanceId;
return this;
}
10-12-2010 08:36 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.