同步自定义工作流事件
本主题提供了这样一个示例,即“同步”自动机节点暂停进程,直到激发了另一进程中特定的用户定义事件为止。
参考工作流
SynchronizationOfUserDefinedEvents.xml
UserEventsWorkflow.xml
说明
您可以定义自动机暂停进程,直到激发了另一进程中用户定义的事件时为止。在下面的表达式中,自动机监听活动的 ACTIVITY_STATE_CHANGED 事件,并检查是否激发了三个用户定义事件 (thermal analysis、fatigue analysis 或 stress analysis) 中的任一事件。对于其中每个事件,其自身都有一个添加到 vector: tempResult 且必须被激发的相应事件。最后,它将结果设置为矢量 tempResult。自动机会激发结果矢量包含的所有事件。
指示
复制下列代码:
Vector tempResult = new Vector ();
//Get activity that caused the event
WfAssignedActivity activity = (WfAssignedActivity) (( wt.events.KeyedEvent) event).getEventTarget();
//Check if the activity and process are the one's we're looking for
if (activity.getName().equals(activityName)){
//Check if the Parent process of the activity is the one we are interested in.
if (activity.getParentProcess().getName().equals(processName)){
//Check if the list of events for the activity contains the event "thermal analysis".
//If so, add to the Vector tempResult, the appropriate event to fire for the robot.
if (activity.getAllEvents().contains("thermal analysis")){
tempResult.addElement("thermal analysis");
}
//Check if the list of events for the activity contains the event "fatigue analysis".
//If so, add to the Vector tempResult, appropriate event for the robot.
if (activity.getAllEvents().contains("fatigue analysis")){
tempResult.addElement("fatigue analysis");
}
//Check if the list of events for the activity contains the event "stress analysis".
//If so, add to the Vector tempResult, appropriate event for the robot.
if (activity.getAllEvents().contains("stress analysis")){
tempResult.addElement("stress analysis");
}
}
}
//Set result to the Vector tempResult.
//Note that in the previous steps, all the events that the robot must fire were added to tempResult.
result = tempResult;
这对您有帮助吗?