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.*; 15 import hero.interfaces.ProjectSessionHome; 16 import hero.interfaces.ProjectSession; 17 18 19 23 public class BonitaProjectAdapter { 24 25 26 27 28 31 public BonitaProjectAdapter(){}; 32 33 34 35 36 37 42 private HashMap getHBonitaData(String theProjectName){ 43 44 HashMap hMap = new HashMap (); 46 47 ProjectSessionHome projecth = null; 49 50 ProjectSession project = null; 52 53 try{ 54 projecth = ProjectSessionUtil.getHome(); 56 57 project = projecth.create(); 59 60 project.initProject(theProjectName); 62 63 Collection collectionProperties = project.getProperties(); 65 66 68 BnProjectPropertyValue pv = null; 70 71 String currentKey = ""; 73 74 String currentValue = ""; 76 String possibleValue = ""; 77 78 Iterator it = collectionProperties.iterator(); 80 81 while (it.hasNext()) 82 { 83 pv = (BnProjectPropertyValue)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(); 103 } 104 } 105 106 hMap.put(currentKey, 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 130 private Document generateBonitaDataDocument(HashMap theHashMap, String theProjectName) throws IOException { 131 132 Document document = null; 134 135 DocumentParser parser = new DocumentParser(); 137 138 DataProject data = new DataProject(theProjectName, theHashMap); 140 141 if( data != null ) 143 document = parser.createDocument(data); 144 145 return document; 146 } 147 148 149 150 151 158 public Document getProjectData(String theProjectName) throws IOException { 159 160 HashMap bonitaMap = new HashMap (); 162 163 bonitaMap = this.getHBonitaData(theProjectName); 165 166 return this.generateBonitaDataDocument(bonitaMap, theProjectName); 168 } 169 } 170 171 172 | Popular Tags |