기본 관리 > 공동 작업 지원 > 워크플로 관리 > 워크플로 도구 > 워크플로 템플릿 관리 > 워크플로 코드 예 > 동기화 로봇 샘플 > 상위 하위 프로세스의 동기화
  
상위 하위 프로세스의 동기화
이 항목에서는 상위 워크플로 프로세스를 만든 이벤트의 활동 상태 변경을 수신하는 동기화 로봇 노드의 예제를 제공합니다.
참조된 워크플로
SynchronizationOnParentChildProcess.xml
SynchronizeChildProcess.xml
설명
아래 표현식은 지정된 활동 노드에 의해 발생한 ACTIVITY_STATE_CHANGED 이벤트를 수신하는 로봇을 대상으로 합니다. 이 표현식은 이벤트를 발생한 활동이 로봇의 상위 프로세스를 만든 프로세스에 속하는지 확인합니다. 속할 경우 활동의 상태에 따라 적절한 라우팅 이벤트를 발생시킵니다.
지침
이런 경우 로봇은 ACTIVITY_STATE_CHANGED 이벤트를 수신하며, 주목해야 할 Windchill 클래스는 wt.workflow.work.WfAssignedActivity입니다.
이 예제에서는 로봇이 첫 번째 수준의 프로세스에 속한다고 가정합니다. 즉, 로봇은 중첩된 하위 프로세스에 존재하지 않습니다. 로봇은 워크플로 템플릿의 가장 바깥쪽 프로세스에 액세스하기 위해 중첩된 하위 프로세스의 구조에 대한 지식을 갖고 있어야 합니다.
다음 코드를 복사합니다.
//Get the Activity that triggered the State_change event.
wt.workflow.engine.WfActivity activity = (( wt.workflow.engine.WfActivity ) (((wt.events.KeyedEvent)event).getEventTarget()));
//get the process that the Activity belongs to
wt.workflow.engine.WfProcess activityParentProcess = activity.getParentProcess();
//Get the Parent of that sub process
wt.fc.ObjectReference activityParentRef = activity.getParentProcessRef( );
//Get the parent process for the Synch Robot
wt.workflow.engine.WfProcess mySubProcess = ( wt.workflow.engine.WfProcess ) self.getObject( );
/Get the parent process that spawns this sub process
wt.workflow.engine.WfActivity myRequestorActivity = (( wt.workflow.engine.WfActivity ) mySubProcess.getRequester( ));
wt.workflow.engine.WfProcess myParentProcess = myRequestorActivity.getParentProcess( );
//Check if the parent of the activity and the parent process of the subprocess that the Synch robot belongs to are the same.
if ( wt.fc.PersistenceHelper.isEquivalent(activityParentProcess , myParentProcess )){
//If the state of the Activity in the ParentProcess is executed, set result to "completed" and ifterminated, set result to "terminated". Else check again
if ( wt.workflow.engine.WfState.CLOSED_COMPLETED_EXECUTED.equals(activity.getState( ))){
result= "completed";
}
else if ( wt.workflow.engine.WfState.CLOSED_TERMINATED.equals(activity.getState( ))){
result= "terminated";
}
}