1 8 package mc.formgenerator.bonita; 9 10 import java.io.File ; 11 import java.io.IOException ; 12 import java.net.MalformedURLException ; 13 import java.util.HashMap ; 14 import java.util.Iterator ; 15 import java.util.Collection ; 16 import java.util.Set ; 17 18 import org.apache.xerces.parsers.DOMParser; 19 import org.w3c.dom.Document ; 20 import org.xml.sax.SAXException ; 21 22 import hero.interfaces.*; 23 24 27 public class BonitaProjectExecutor { 28 29 30 31 35 public BonitaProjectExecutor() { 36 } 37 38 39 40 48 public void startBonitaProject(File fichier) 49 throws MalformedURLException , SAXException , IOException { 50 51 52 56 DOMParser parser = new DOMParser(); 58 59 parser.parse(fichier.toURL().toString()); 61 62 Document document = parser.getDocument(); 64 65 66 67 DocumentParser parse = new DocumentParser(); 69 70 DataProject data = parse.parseProject(document); 71 72 String name = data.getProcessName(); 74 75 HashMap table = data.getProcessProperties(); 77 78 instanciateProject(name, table); 80 81 } 82 83 84 85 86 87 88 96 public void startBonitaProject(Document document) 97 throws MalformedURLException , SAXException , IOException { 98 99 100 DocumentParser parse = new DocumentParser(); 102 103 DataProject data = parse.parseProject(document); 104 105 String name = data.getProcessName(); 107 108 HashMap table = data.getProcessProperties(); 110 111 112 instanciateProject(name, table); 114 115 } 116 117 118 119 120 121 127 private void instanciateProject(String processName, HashMap table) { 128 129 ProjectSessionHome projecth = null; 131 132 ProjectSession project = null; 134 135 try { 136 137 141 projecth = ProjectSessionUtil.getHome(); 143 144 project = projecth.create(); 146 147 project.initProject(processName); 149 150 151 155 Set collec = table.keySet(); 157 158 if (collec.size() > 0) { 160 161 Iterator it = collec.iterator(); 163 164 String cle=""; 166 167 while (it.hasNext()) { 168 169 cle = (String ) it.next(); 171 172 project.setProperty(cle, (String ) table.get(cle)); 174 } 175 } 176 177 178 } catch (Exception e) { 179 System.out.println(e.getMessage()); 180 } 181 } 182 183 184 185 } 186 | Popular Tags |