EventMonitorThread eventMonitorThread = context.getEventMonitorThread(workflowProcess.getWorkflowPackage());
MonitorEvent monitorEvent =
new MonitorEvent(workflowService, workflowProcess, operator, userTransaction, workflowWork, workflowTransition);
eventMonitorThread.sendEvent(monitorEvent);
MonitorEventResult eventResult = monitorEvent.getResult();
if (eventResult.getException() != null)
{
eventResult.getException().printStackTrace();
throw new WorkflowException(eventResult.getException());
}
Connection conn = (Connection) userTransaction.getStoreConnection().get();
PreparedStatement pstmt = null;
String strSQL = null;
WorkflowCase workflowCase = workflowWork.getWorkflowCase();
WorkflowActivity dispActivity = workflowTransition.getFromWorkflowActivity();
String disp_owner_process_id = dispActivity.getWorkflowProcess().getUUID();
String disp_activity_id = dispActivity.getUUID();
String packageId = workflowProcess.getWorkflowPackage().getUUID();
String processId = workflowProcess.getUUID();
String caseId = workflowCase.getUUID();
log.debug("\norJoin monitorEvent == > "+monitorEvent);
try
{
if (eventResult.getBatchNo() == 0)
{
strSQL =
"INSERT INTO "
+ caseDatabase.getSchemaContext().getTableName(SchemaContext.SCHEMA_ACTIVITY_DISPATCH)
+ "(vc_packageid,vc_processid,vc_caseid,vc_owner_processid,vc_activityid,int_batchNo) "
+ " VALUES(?,?,?,?,?,?)";
pstmt = conn.prepareStatement(strSQL);
pstmt.setString(1, packageId);
pstmt.setString(2, processId);
pstmt.setString(3, caseId);
pstmt.setString(4, disp_owner_process_id);
pstmt.setString(5, disp_activity_id);
pstmt.setInt(6, eventResult.getBatchNo() + 1);
pstmt.execute();
ConnUtils.cleanupNoThrow(pstmt);
pstmt = null;
}
else
{
strSQL =
"UPDATE "
+ caseDatabase.getSchemaContext().getTableName(SchemaContext.SCHEMA_ACTIVITY_DISPATCH)
+ " "
+ "SET int_batchNo=?,vc_disp_flag=? "
+ "WHERE vc_packageid=? "
+ "AND vc_processid=? "
+ "AND vc_caseid=? "
+ "AND vc_owner_processid=? "
+ "AND vc_activityid=? ";
pstmt = conn.prepareStatement(strSQL);
pstmt.setInt(1, eventResult.getBatchNo() + 1);
pstmt.setString(2, "TRUE");
pstmt.setString(3, packageId);
pstmt.setString(4, processId);
pstmt.setString(5, caseId);
pstmt.setString(6, disp_owner_process_id);
pstmt.setString(7, disp_activity_id);
ConnUtils.cleanupNoThrow(pstmt);
pstmt = null;
}
}
catch (SQLException ex)
{
throw new WorkflowException(ex);
}
finally
{
ConnUtils.cleanupNoThrow(pstmt);
pstmt = null;
}
String orJoinWorkId = eventResult.getJoinWorkID();
if (orJoinWorkId == null)
{
//�������ز�һ��,throw InternalError()???
}
else
{
WorkflowWork orJoinWork =
caseDatabase.findWorkflowWork(
workflowProcess,
operator,
userTransaction,
workflowWork.getWorkflowCase(),
orJoinWorkId);
caseDatabase.createWorkflowPath(
workflowProcess,
operator,
userTransaction,
workflowWork.getWorkflowCase(),
workflowWork,
orJoinWork,
pathDispBatch,
WorkflowActivityEvent.WORK_DISPATCH);
if (eventResult.last())
{
return DispatchController.execute_dispatchIfNecessary(
workflowService,
workflowProcess,
operator,