WorkflowWork dispWork,
List trueTransitions,
List falseTransitions)
throws SQLException, WorkflowException
{
WorkflowActivity dispActivity = dispWork.getWorkflowActivity();
SplitType splitType = dispActivity.getSplitType();
if (!SplitType.SPLIT_OR.equals(splitType))
{
return;
}
if (trueTransitions.size() == 0)
{
throw new WorkflowException("signalOrJoinActivity trueTransitions.size()==0 ");
}
log.debug(
"\n"
+ "dispActivity==>"
+ dispActivity
+ "\ntrueTransitions==>"
+ trueTransitions
+ "\nfalseTransitions==>"
+ falseTransitions
+ "\n\n");
WorkflowProcess workflowProcess = dispWork.getWorkflowCase().getWorkflowProcess();
WorkflowActivity trueJoinActivity = null;
WorkflowActivity falseJoinActivity = null;
WorkflowActivity orJoinActivity = null;
List swap_trueTransitions = null;
List swap_falseTransitions = null;
//-------------------------------------------------------------------
// 1.���� TRUE ·��ѡ�� ����TRUE TOKEN ����·��
//-------------------------------------------------------------------
trueJoinActivity = ((WorkflowTransition) trueTransitions.get(0)).getToWorkflowActivity();
swap_trueTransitions = trueTransitions;
boolean forceLoopTrueJoinActivity = false;
boolean forceLoopFalseJoinActivity = false;
LoopTrueJoinActivity : while (
forceLoopTrueJoinActivity
|| (trueJoinActivity != null && !JoinType.JOIN_OR.equals(trueJoinActivity.getJoinType())))
{
forceLoopTrueJoinActivity = false;
orJoinActivity = null;
//---------------------------------------------------------------------------
// 1.1 ���� TRUE ·��ѡ��, ����next Activity û�� �ݵ�OR Join Activity
// [����XPDL End Activity]
//---------------------------------------------------------------------------
swap_trueTransitions = trueJoinActivity.getOutgoingTransitions();
if (swap_trueTransitions == null || swap_trueTransitions.size() == 0)
{
throw new WorkflowException("signalOrJoinActivity : outgoingTransitions.size()==0," + trueJoinActivity);
}
//---------------------------------------------------------------------------
// 1.2 ���� TRUE ·��ѡ��, ����next Activity û�� �ݵ�OR Join Activity
// [��������XPDL ������]
//---------------------------------------------------------------------------
trueJoinActivity = nextPossibleActivityFinder(trueJoinActivity, swap_trueTransitions);
if (trueJoinActivity == null)
{
throw new WorkflowException("nextPossibleActivityFinder : nextOrJoinActivity is null");
}
//---------------------------------------------------------------------------
// 1.3 ���� TRUE ·��ѡ��, ѡ���next Acitivity ���� OR Join Activity
//---------------------------------------------------------------------------
if (!JoinType.JOIN_OR.equals(trueJoinActivity.getJoinType()))
{
//find next possible trueJoinActivity
continue LoopTrueJoinActivity;
}
//---------------------------------------------------------------------------
// 1.4 ���� TRUE ·��ѡ��, ������ OR Join Activity
//---------------------------------------------------------------------------
log.debug("FOUND TRUE OR-JOIN-ACTIVITY : " + trueJoinActivity.getInfo());
//-------------------------------------------------------------------
// 2.���� FALSE ·��ѡ�� ����FALSE TOKEN ����·��
//-------------------------------------------------------------------
//---------------------------------------------------------------------------
// 2.1 ���� FALSE ·��ѡ��, �ַ�Activity next ·��ȫ����ѡ��
//---------------------------------------------------------------------------
swap_falseTransitions = falseTransitions;
if (swap_falseTransitions == null || swap_falseTransitions.size() == 0)
{
//----------------------------------------
// [����] �������Ϸ��� OR Join Activity
//----------------------------------------
//or-split's all outTransitions are selected to process
orJoinActivity = trueJoinActivity;
break LoopTrueJoinActivity;
}
falseJoinActivity = ((WorkflowTransition) swap_falseTransitions.get(0)).getToWorkflowActivity();
if(JoinType.JOIN_OR.equals(falseJoinActivity.getJoinType()))
{
//һ��OR Split Activity ֱ�Ӻ�� Activity �� JoinType ��Ӧ��Ϊ OR
throw new WorkflowException("Bad Format XPDL Data : OR Split Activity's next direct Activity's JoinType should not be 'OR' ");
}
LoopFalseJoinActivity : while (
forceLoopFalseJoinActivity
|| (falseJoinActivity != null && !JoinType.JOIN_OR.equals(falseJoinActivity.getJoinType())))
{
forceLoopFalseJoinActivity =false;
swap_falseTransitions = falseJoinActivity.getOutgoingTransitions();
//---------------------------------------------------------------------------
// 2.2 ���� FLASE ·��ѡ��, ���� next Activity û�� �ݵ� OR Join Activity
// [����XPDL End Activity]
//---------------------------------------------------------------------------
if (swap_falseTransitions == null || swap_falseTransitions.size() == 0)
{
break LoopFalseJoinActivity;
}
falseJoinActivity = nextPossibleActivityFinder(falseJoinActivity, swap_falseTransitions);
//---------------------------------------------------------------------------
// 2.3 ���� FLASE ·��ѡ��, ����next Activity û�� �ݵ� OR Join Activity
// [��������XPDL ������]
//---------------------------------------------------------------------------
if (falseJoinActivity == null)
{
break LoopFalseJoinActivity;
}
//---------------------------------------------------------------------------
// 2.4 ���� FALSE ·��ѡ��, ѡ���next Acitivity ���� OR Join Activity
// [����] �ƶ� FALSE TOKEN ��ѡ����һ�� OR Join Activity ���в���
//---------------------------------------------------------------------------
if (!JoinType.JOIN_OR.equals(falseJoinActivity.getJoinType()))
{
//find next possible falseJoinActivity
continue LoopFalseJoinActivity;
}
//---------------------------------------------------------------------------
// 2.5 ���� FALSE ·��ѡ��, ������ OR Join Activity
//---------------------------------------------------------------------------
log.debug("FOUND FALSE OR-JOIN-ACTIVITY : " + falseJoinActivity.getInfo());
if (falseJoinActivity.getUUID().equals(trueJoinActivity.getUUID()))
{
//---------------------------------------------------------------------------
// 2.6.1 ���� TRUE/FALSE ·��ѡ��, ������ �Ϸ��� OR Join Activity
// [����] �������Ϸ��� OR Join Activity
//---------------------------------------------------------------------------
//OR-JOIN Activity found
orJoinActivity = falseJoinActivity;
break LoopTrueJoinActivity;
}
else
{
//---------------------------------------------------------------------------
// 2.6.2 ���� TRUE/FALSE ·��ѡ��, û�м����� �Ϸ��� OR Join Activity
// [����] �ƶ� FALSE TOKEN ��ѡ����һ�� OR Join Activity ���в���
//---------------------------------------------------------------------------
forceLoopFalseJoinActivity=true;
continue LoopFalseJoinActivity;
}
} //~end while (falseJoinActivity != null && !JoinType.JOIN_OR.equals(falseJoinActivity.getJoinType()))
//---------------------------------------------------------------------------
// 1.5 ���� TRUE/FALSE ·��ѡ��, û�м����� OR Join Activity
// [����] �ƶ� TRUE TOKEN ��ѡ����һ�� OR Join Activity ���в���
//---------------------------------------------------------------------------
//find next possible orJoinActivity
forceLoopTrueJoinActivity = true;
continue LoopTrueJoinActivity;
//------------------------------------------------------------------------------
} //~end while (trueJoinActivity != null && !JoinType.JOIN_OR.equals(trueJoinActivity.getJoinType()))
if (orJoinActivity == null)
{
throw new WorkflowException("signalOrJoinActivity : orJoinActivity not found");
}
log.debug("orJoinActivity : " + orJoinActivity.getInfo());
Connection conn = (Connection) userTransaction.getStoreConnection().get();
String packageId = workflowProcess.getWorkflowPackage().getUUID();
String processId = workflowProcess.getUUID();
String caseId = dispWork.getWorkflowCase().getUUID();
int size = falseTransitions.size();
for (int i = 0; i < size; ++i)
{
WorkflowTransition falseTransition = (WorkflowTransition) falseTransitions.get(i);
WorkflowActivity falseActivity = falseTransition.getToWorkflowActivity();
WorkflowTransition falseJoinTransition = null;
while (falseActivity != null)
{
if (falseActivity.getUUID().equals(orJoinActivity.getUUID()))
{
falseJoinTransition = falseTransition;
break;
}
swap_falseTransitions = falseActivity.getOutgoingTransitions();
if (swap_falseTransitions == null || swap_falseTransitions.size() == 0)
{
break;
}
else
{
falseTransition = ((WorkflowTransition) swap_falseTransitions.get(0));
falseActivity = nextPossibleActivityFinder(falseActivity, swap_falseTransitions);
}
} //while (falseActivity != null)
log.debug("falseJoinTransition : " + falseJoinTransition.getInfo());
if (falseJoinTransition != null)
{
//OR-JOIN Activity found,set false falseJoinActivity#vc_disp_flag
//insert into database table(rt_p_activity_dispatch)
//@see database table(rt_p_activity_dispatch)
WorkflowActivity ins_falseActivity = falseJoinTransition.getFromWorkflowActivity();
String ins_falseActivityId = ins_falseActivity.getUUID();
String ins_owner_processid = ins_falseActivity.getWorkflowProcess().getUUID();
PreparedStatement pstmt = null;
String strSQL = null;
strSQL =