1 5 package mc.formgenerator.bonita; 6 7 import hero.interfaces.ProjectSession; 8 import hero.interfaces.ProjectSessionHome; 9 import hero.interfaces.ProjectSessionUtil; 10 import hero.interfaces.UserSession; 11 import hero.interfaces.UserSessionHome; 12 import hero.interfaces.UserSessionUtil; 13 14 import java.util.*; 15 16 import org.w3c.dom.Document ; 17 18 21 public class BonitaActivityExecutor { 22 23 24 25 28 public BonitaActivityExecutor() { 29 30 } 31 32 33 34 40 public void actOnActivity(Document document, String mode){ 41 42 DocumentParser parse = new DocumentParser(); 44 45 DataActivity data = parse.parseActivity(document); 46 47 48 String projectName = data.getProcessName(); 50 51 52 String activityName = data.getActivityName(); 54 55 56 HashMap table = data.getProcessProperties(); 58 59 this.startActivity(activityName, projectName, table, mode); 61 } 62 63 64 65 66 67 76 private void startActivity(String activityName, String projectName, HashMap table, String mode) { 77 78 ProjectSessionHome projecth = null; 80 81 ProjectSession project = null; 83 84 try { 85 projecth = ProjectSessionUtil.getHome(); 87 88 project = projecth.create(); 90 91 project.initProject(projectName); 92 93 94 98 Set collec = table.keySet(); 100 101 if (collec.size() > 0) { 103 104 Iterator it = collec.iterator(); 106 107 String cle=""; 109 110 while (it.hasNext()) { 111 112 cle = (String ) it.next(); 114 115 project.setNodeProperty(activityName, cle, (String ) table.get(cle)); 117 } 118 } 119 120 124 UserSessionHome userh = UserSessionUtil.getHome(); 126 127 UserSession user = userh.create(); 129 user.startActivity(projectName, activityName); 131 132 user.terminateActivity(projectName, activityName); 134 135 boolean isTerminated = project.isTerminated(); 137 if (isTerminated) 138 { 139 user.terminate(projectName); 140 } 141 145 148 } catch (Exception e) { 149 System.out.println(e.getMessage()); 150 } 151 } 152 153 154 155 156 157 public void endActivity (String activityName, String projectName) { 158 try { 159 160 UserSessionHome userh = UserSessionUtil.getHome(); 162 163 UserSession user = userh.create(); 165 166 167 user.terminateActivity( projectName, activityName); 169 170 } catch (Exception e) { 171 System.out.println(e.getMessage()); 172 } 173 } 174 175 } 176 | Popular Tags |