1 5 package mc.formgenerator.bonita; 6 7 import java.io.IOException ; 8 import java.util.Collection ; 9 import java.util.HashMap ; 10 import java.util.Iterator ; 11 12 import org.w3c.dom.Document ; 13 14 import hero.interfaces.*; 16 import hero.interfaces.ProjectSessionHome; 17 import hero.interfaces.ProjectSession; 18 19 20 24 public class BonitaActivityAdapter { 25 26 27 28 29 32 public BonitaActivityAdapter(){}; 33 34 35 36 37 38 44 private HashMap getHBonitaData(String theProjectName, String theActivityName){ 45 46 HashMap hMap = new HashMap (); 48 49 ProjectSessionHome projecth = null; 51 52 ProjectSession project = null; 54 55 try{ 56 projecth = ProjectSessionUtil.getHome(); 58 59 project = projecth.create(); 61 62 project.initProject(theProjectName); 64 65 Collection collectionActivityProperties = project.getNodeProperties(theActivityName); 67 68 70 BnNodePropertyValue pv = null; 72 73 String currentKey = ""; 75 76 String currentValue = ""; 78 79 Iterator it = collectionActivityProperties.iterator(); 81 82 while (it.hasNext()){ 83 pv = (BnNodePropertyValue)it.next(); 85 86 currentKey = pv.getTheKey(); 88 currentValue = pv.getTheValue(); 89 if (currentValue==null) currentValue = ""; 90 Collection possibleValues = pv.getPossibleValues(); 92 if (possibleValues != null) 93 { 94 if (currentValue.equals("")) currentValue=" "; 96 Iterator itValues = possibleValues.iterator(); 98 while (itValues.hasNext()) 100 { 101 currentValue = currentValue + "|" + (String )itValues.next(); 102 } 103 } 104 105 hMap.put(currentKey, currentValue); 107 currentValue = ""; 108 } 109 110 return hMap; 112 } 113 catch(Exception e){ 114 System.out.println(e + " " + e.getMessage()); 115 return null; 116 } 117 } 118 119 120 121 122 123 131 private Document generateBonitaDataDocument(HashMap theHashMap, String theProjectName, String theActivityName) 132 throws IOException { 133 134 Document document = null; 136 137 DocumentParser parser = new DocumentParser(); 139 140 DataActivity data = new DataActivity(theProjectName, theActivityName, theHashMap); 142 143 if( data != null ) 145 document = parser.createDocument(data); 146 147 return document; 148 } 149 150 151 152 153 161 public Document getActivityData(String theProjectName, String theActivityName) 162 throws IOException { 163 164 HashMap bonitaMap = new HashMap (); 166 167 bonitaMap = this.getHBonitaData(theProjectName, theActivityName); 169 170 return this.generateBonitaDataDocument(bonitaMap, theProjectName, theActivityName); 172 } 173 } 174 175 176 | Popular Tags |