1 7 8 package org.enhydra.snapper.presentation; 9 10 11 import java.util.HashMap ; 12 import java.util.Iterator ; 13 import java.util.Map ; 14 15 import org.w3c.dom.html.*; 16 import org.w3c.dom.*; 17 18 import org.enhydra.snapper.SnapperManager; 20 import org.enhydra.snapper.spec.*; 21 22 import org.enhydra.snapper.presentation.html.*; 23 import org.enhydra.xml.xmlc.XMLObject; 24 25 26 public class StatusPresentation extends BasePO { 27 28 29 protected XMLObject getDOM() throws Exception { 30 31 StatusListHTML status; 32 Site site = null; 33 String id; 34 35 status = (StatusListHTML)comms.xmlcFactory.create(StatusListHTML.class); 36 id = comms.request.getParameter("id"); 37 38 if (id != null) { 39 Map threads = SnapperManager.getInstance().getThreads(); 40 if (threads.get(id) instanceof Update) { 41 Update ii = (Update)threads.get(id); 42 ii.setDoStop(true); 43 } 44 else { 45 Index ii = (Index)threads.get(id); 46 ii.setDoStop(true); 47 } 48 49 SnapperManager.getInstance().removeThread(id); 50 } 51 52 HTMLTableRowElement templateRow = status.getElementTemplateRow(); 53 HTMLElement nameCellTemplate = status.getElementName(); 54 55 templateRow.removeAttribute("id"); 56 nameCellTemplate.removeAttribute("id"); 57 58 Node sitesTable = templateRow.getParentNode(); 59 String link; 60 Map threads = new HashMap (); 61 threads = SnapperManager.getInstance().getThreads(); 62 63 for (Iterator iterator = threads.entrySet().iterator(); iterator.hasNext();) { 64 Map.Entry entry = (Map.Entry ) iterator.next(); 65 String key = (String )entry.getKey(); 66 try{ 67 try { 68 Site si = SiteFactory.getSite("org.enhydra.snapper.business.SiteImpl"); 69 70 site = si.findSiteByID(key, dbTransaction); 71 72 }catch (Exception ex){ 73 System.out.println("Exception: "+ex); 74 site = null; 75 } 76 status.setTextName(site.getName()); 78 79 link = "StatusPresentation.po?id=" + site.getID(); 80 status.getElementDeleteLink().setHref(link); 81 82 sitesTable.appendChild(templateRow.cloneNode(true)); 83 } 84 85 catch (Exception ex) {ex.printStackTrace();} 86 } 87 templateRow.getParentNode().removeChild(templateRow); 88 return status; 90 } 91 92 } 93 | Popular Tags |