기본 관리 > 공동 작업 지원 > 워크플로 관리 > 워크플로 도구 > 워크플로 템플릿 관리 > 워크플로 코드 예 > 투표 집계 > 두 개 이상의 집계 호출을 가진 집계 표현식 예
  
두 개 이상의 집계 호출을 가진 집계 표현식 예
이 항목에서는 표현식에서 두 개 이상의 집계 호출을 사용하는 예제와 동일한 이벤트가 두 번 발생하지 않도록 방지하는 방법을 제공합니다.
참조된 워크플로
TallyExpressionWithTwoTallyCalls.xml
설명
같은 표현식 안에 둘 이상의 집계 호출이 있을 수 있습니다. 이런 경우 동일한 라우팅 이벤트를 이벤트 목록에 두 번 이상 추가할 위험이 있습니다. 이를 방지하려면 예제에서처럼 setEvents( ) 메소드를 사용하십시오. 이 메소드는 중복되지 않은 라우팅 이벤트를 수집하므로 목록의 각 라우팅 이벤트가 한 번씩만 발생합니다. 아래 표현식은 선택된 "Test" 횟수에 대한 폴링을 수행하고 결과를 tallyResults 벡터에 저장합니다. 그런 다음 나머지 두 개가 아닌 "Modify,"를 선택하는 임무 책임자의 비율을 폴링합니다. 이 폴링의 결과는 이제 벡터 tallyResults에 추가됩니다. setEvents 메소드를 사용하면 두 집계 호출에 모두 표시되는 "Modify" 이벤트가 발생할 이벤트 목록에서 두 번 표시되지 않습니다. 결과는 벡터 tallyResults에 설정됩니다.
지침
이 활동에 대한 라우팅 이벤트 개수에는 제한이 없습니다. 워크플로 정의에 필요한 것으로 선택된 임무 책임자의 투표만 폴링에 사용됩니다.
다음 코드를 복사합니다.
//Create a vector that will hold all the non-duplicated UserEvents chosen for this activity.
Vector tallyResults = new Vector( );
//Get the object representing this activity.
wt.workflow.work.WfAssignedActivity mySelf = (( wt.workflow.work.WfAssignedActivity ) self.getObject( ));
//Get all the UserEvents for this activity. The resulting Vector may hold duplicate values of some events.
Vector userEvents = (Vector) mySelf.getUserEventList( );
//If "Test" receives 2 or more of the required votes, get "Test", else get "Modify".
//Collect the non-duplicated events into the Vector tallyResults ( i.e add only those events that do not already exist in the vector.
WfTally.setEvents(tallyResults , wt.workflow.work.WfTally.number(self , WfTally.GTE, 2, "Test", "Modify"));
//If "Modify" receives more than 35% of the required votes, get "Modify" else get "Approve and Release".
//Collect the non-duplicated events into the Vector tallyResults ( i.e add only those events that do not already exist in the vector.
WfTally.setEvents(tallyResults , wt.workflow.work.WfTally.percent(self , WfTally.GT, 35, "Modify", "Approve and Release"));
//set result to the tallyResults Vector.
result= tallyResults