1 package org.enhydra.shark; 2 3 import java.util.Iterator ; 4 import java.util.List ; 5 6 import org.enhydra.shark.api.SharkTransaction; 7 import org.enhydra.shark.api.client.wfbase.BaseException; 8 import org.enhydra.shark.api.common.SharkConstants; 9 import org.enhydra.shark.api.internal.working.WfActivityInternal; 10 import org.enhydra.shark.xpdl.XMLCollectionElement; 11 import org.enhydra.shark.xpdl.XMLUtil; 12 import org.enhydra.shark.xpdl.elements.Activities; 13 import org.enhydra.shark.xpdl.elements.Activity; 14 import org.enhydra.shark.xpdl.elements.ActivitySet; 15 import org.enhydra.shark.xpdl.elements.WorkflowProcess; 16 17 18 19 28 public class UpdateChecker { 29 private org.enhydra.shark.xpdl.elements.Package oldPackage; 30 private org.enhydra.shark.xpdl.elements.Package newPackage; 31 private List processesToRestore; 32 private List activitiesToRestore; 33 34 public UpdateChecker (org.enhydra.shark.xpdl.elements.Package oldPackage, 35 org.enhydra.shark.xpdl.elements.Package newPackage, 36 List processesToRestore,List activitiesToRestore) { 37 this.oldPackage=oldPackage; 38 this.newPackage=newPackage; 39 this.processesToRestore=processesToRestore; 40 this.activitiesToRestore=activitiesToRestore; 41 } 42 43 public boolean isUpdatePossible (SharkTransaction t) throws BaseException { 44 Iterator it=activitiesToRestore.iterator(); 45 while (it.hasNext()) { 46 WfActivityInternal act=(WfActivityInternal)it.next(); 47 try { 49 if (act.state(t).startsWith(SharkConstants.STATEPREFIX_CLOSED)) continue; 50 } catch (Exception ex) {} 51 52 Activity actDef=SharkUtilities.getActivityDefinition(t,act, 53 SharkUtilities.getWorkflowProcess(act.container(t).package_id(t), 54 act.container(t).manager_version(t), 55 act.container(t).process_definition_id(t)), 56 act.block_activity(t)); 57 58 String processId=null; 60 String activitySetId=null; 61 XMLCollectionElement owner=(XMLCollectionElement)actDef.getParent().getParent(); 64 if (owner instanceof WorkflowProcess) { 65 processId=owner.getId(); 66 } else { 67 activitySetId=owner.getId(); 68 processId=XMLUtil.getWorkflowProcess(actDef).getId(); 69 } 70 WorkflowProcess wp=newPackage.getWorkflowProcess(processId); 71 if (wp==null) { 73 return false; 74 } 75 Activities acts=null; 77 if (activitySetId!=null) { 78 ActivitySet as=wp.getActivitySet(activitySetId); 79 if (as==null) { 81 return false; 82 } 83 acts=as.getActivities(); 84 } else { 85 acts=wp.getActivities(); 86 } 87 if (acts.getActivity(actDef.getId())==null) { 89 return false; 90 } 91 } 92 return true; 93 } 94 95 96 } 97 | Popular Tags |