1 package org.enhydra.shark.swingclient; 2 3 import org.enhydra.shark.api.client.wfmodel.WfActivityIterator; 4 import org.enhydra.shark.api.client.wfmodel.WfProcessIterator; 5 import org.enhydra.shark.api.client.wfservice.ExecutionAdministration; 6 import org.enhydra.shark.api.client.wfservice.ExpressionBuilderManager; 7 import org.enhydra.shark.api.client.wfservice.WfProcessMgrIterator; 8 import org.enhydra.shark.api.common.ActivityIteratorExpressionBuilder; 9 import org.enhydra.shark.api.common.ProcessIteratorExpressionBuilder; 10 import org.enhydra.shark.api.common.ProcessMgrIteratorExpressionBuilder; 11 import org.enhydra.shark.api.common.SharkConstants; 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 78 public WfActivityIterator getOpenActivities (String procId) throws Exception { 79 ActivityIteratorExpressionBuilder eb = ebm.getActivityIteratorExpressionBuilder(); 80 eb.addProcessIdEquals(procId) 81 .and() 82 .addStateStartsWith(SharkConstants.STATEPREFIX_OPEN); 83 eb.setOrderByActivatedTime(false); 84 WfActivityIterator it = ea.get_iterator_activity(); 85 it.set_query_expression(eb.toExpression()); 86 return it; 87 } 88 89 public WfActivityIterator getActivitiesForDefinitionAndState (String procId,String definitionId,String stateOrStatePrefix,boolean stateEquality) throws Exception { 90 ActivityIteratorExpressionBuilder eb = ebm.getActivityIteratorExpressionBuilder(); 91 eb.addProcessIdEquals(procId).and().addDefinitionId(definitionId); 92 if (stateOrStatePrefix!=null && !stateOrStatePrefix.equals("")) { 93 eb.and(); 94 if (stateEquality) { 95 eb.addStateEquals(stateOrStatePrefix); 96 } else { 97 eb.addStateStartsWith(stateOrStatePrefix); 98 } 99 } 100 eb.setOrderByActivatedTime(false); 101 WfActivityIterator it = ea.get_iterator_activity(); 102 it.set_query_expression(eb.toExpression()); 103 return it; 104 } 105 106 } 107 | Popular Tags |