1 package org.enhydra.shark.corbaclient; 2 3 import org.enhydra.shark.api.common.SharkConstants; 4 import org.enhydra.shark.corba.ExpressionBuilders.ActivityIteratorExpressionBuilder; 5 import org.enhydra.shark.corba.ExpressionBuilders.ProcessIteratorExpressionBuilder; 6 import org.enhydra.shark.corba.ExpressionBuilders.ProcessMgrIteratorExpressionBuilder; 7 import org.enhydra.shark.corba.WorkflowService.ExecutionAdministration; 8 import org.enhydra.shark.corba.WorkflowService.ExpressionBuilderManager; 9 import org.enhydra.shark.corba.WorkflowService.WfProcessMgrIterator; 10 import org.omg.WorkflowModel.WfActivityIterator; 11 import org.omg.WorkflowModel.WfProcessIterator; 12 13 16 public class CommonExpressionBuilder { 17 protected ExecutionAdministration ea = null; 18 protected ExpressionBuilderManager ebm = null; 19 20 public CommonExpressionBuilder (ExecutionAdministration ea,ExpressionBuilderManager ebm) { 21 this.ea=ea; 22 this.ebm=ebm; 23 } 24 25 public WfProcessMgrIterator getManagersForPackage (String pkgId) throws Exception { 26 ProcessMgrIteratorExpressionBuilder eb = ebm.getProcessMgrIteratorExpressionBuilder(); 27 eb.addPackageIdEquals(pkgId); 28 eb.setOrderByCreatedTime(true); 29 WfProcessMgrIterator it = ea.get_iterator_processmgr(); 30 it.set_query_expression(eb.toExpression()); 31 return it; 32 } 33 34 public WfProcessMgrIterator getEnabledOrDisabledManagersForPackage (String pkgId,boolean enabled) throws Exception { 35 ProcessMgrIteratorExpressionBuilder eb = ebm.getProcessMgrIteratorExpressionBuilder(); 36 eb.addPackageIdEquals(pkgId).and(); 37 eb.setOrderByCreatedTime(true); 38 if (!enabled) { 39 eb.not(); 40 } 41 eb.addIsEnabled(); 42 WfProcessMgrIterator it = ea.get_iterator_processmgr(); 43 it.set_query_expression(eb.toExpression()); 44 return it; 45 } 46 47 public WfProcessIterator getOpenProcessesForManager (String mgrName) throws Exception { 48 ProcessIteratorExpressionBuilder eb = ebm.getProcessIteratorExpressionBuilder(); 49 eb.addMgrNameEquals(mgrName) 50 .and() 51 .addStateStartsWith(SharkConstants.STATEPREFIX_OPEN); 52 eb.setOrderByCreatedTime(false); 53 WfProcessIterator it = ea.get_iterator_process(); 54 it.set_query_expression(eb.toExpression()); 55 return it; 56 } 57 58 public WfProcessIterator getClosedProcessesForManager (String mgrName) throws Exception { 59 ProcessIteratorExpressionBuilder eb = ebm.getProcessIteratorExpressionBuilder(); 60 eb.addMgrNameEquals(mgrName) 61 .and() 62 .addStateStartsWith(SharkConstants.STATEPREFIX_CLOSED); 63 eb.setOrderByCreatedTime(false); 64 WfProcessIterator it = ea.get_iterator_process(); 65 it.set_query_expression(eb.toExpression()); 66 return it; 67 } 68 69 public WfProcessIterator getAllProcessesForManager (String mgrName) throws Exception { 70 ProcessIteratorExpressionBuilder eb = ebm.getProcessIteratorExpressionBuilder(); 71 eb.addMgrNameEquals(mgrName); 72 eb.setOrderByCreatedTime(false); 73 WfProcessIterator it = ea.get_iterator_process(); 74 it.set_query_expression(eb.toExpression()); 75 return it; 76 } 77 public WfActivityIterator getOpenActivities (String procId) throws Exception { 78 ActivityIteratorExpressionBuilder eb = ebm.getActivityIteratorExpressionBuilder(); 79 eb.addProcessIdEquals(procId) 80 .and() 81 .addStateStartsWith(SharkConstants.STATEPREFIX_OPEN); 82 eb.setOrderByActivatedTime(false); 83 WfActivityIterator it = ea.get_iterator_activity(); 84 it.set_query_expression(eb.toExpression()); 85 return it; 86 } 87 88 public WfActivityIterator getActivitiesForDefinitionAndState (String procId,String definitionId,String stateOrStatePrefix,boolean stateEquality) throws Exception { 89 ActivityIteratorExpressionBuilder eb = ebm.getActivityIteratorExpressionBuilder(); 90 eb.addProcessIdEquals(procId).and().addDefinitionId(definitionId).and(); 91 if (stateOrStatePrefix!=null && !stateOrStatePrefix.equals("")) { 92 eb.and(); 93 if (stateEquality) { 94 eb.addStateEquals(stateOrStatePrefix); 95 } else { 96 eb.addStateStartsWith(stateOrStatePrefix); 97 } 98 } 99 eb.setOrderByActivatedTime(false); 100 WfActivityIterator it = ea.get_iterator_activity(); 101 it.set_query_expression(eb.toExpression()); 102 return it; 103 } 104 105 } 106 | Popular Tags |