1 7 8 package org.enhydra.snapper.presentation; 9 10 11 12 import org.w3c.dom.html.*; 13 import org.w3c.dom.*; 14 15 import org.enhydra.snapper.spec.*; 17 18 import org.enhydra.snapper.presentation.html.*; 19 import org.enhydra.xml.xmlc.XMLObject; 20 21 22 public class SiteListPresentation extends BasePO { 23 24 25 protected XMLObject getDOM() throws Exception { 26 27 SiteListHTML siteList; 28 Site[] list; 29 String id; 30 31 siteList = (SiteListHTML)comms.xmlcFactory.create(SiteListHTML.class); 32 id = comms.request.getParameter("id"); 33 34 if (comms.request.getParameter("i") != null) { 35 siteList.getElementInfo2().setValue("Indexing site: " + comms.request.getParameter("i")); 37 } 38 39 if (comms.request.getParameter("u") != null) { 40 siteList.getElementInfo2().setValue("Updating site: " + comms.request.getParameter("u")); 42 } 43 44 if (comms.request.getParameter("l") != null) { 45 siteList.getElementInfo2().setValue("SITE LOCKED! Site is already being indexed/updated: " + comms.request.getParameter("l")); 47 } 48 49 50 51 try { 52 SiteList sl = SiteListFactory.getSiteList("org.enhydra.snapper.business.SiteListImpl"); 53 54 list = sl.getList(dbTransaction); 55 56 }catch (Exception ex){ 57 System.out.println("Exception: "+ex); 58 list = null; 59 } 60 61 HTMLTableRowElement templateRow = siteList.getElementTemplateRow(); 62 63 HTMLElement nameCellTemplate = siteList.getElementName(); 64 HTMLElement documentsCellTemplate = siteList.getElementDocuments(); 65 HTMLElement queriesCellTemplate = siteList.getElementQueries(); 66 HTMLElement updatedCellTemplate = siteList.getElementUpdated(); 67 68 templateRow.removeAttribute("id"); 69 nameCellTemplate.removeAttribute("id"); 70 documentsCellTemplate.removeAttribute("id"); 71 queriesCellTemplate.removeAttribute("id"); 72 updatedCellTemplate.removeAttribute("id"); 73 74 Node sitesTable = templateRow.getParentNode(); 75 String link; 76 77 for (int numSites = 0; numSites < list.length; numSites++) { 78 try{ 79 Site currentSite = list[numSites]; 80 siteList.setTextName(currentSite.getName()); 82 siteList.setTextDocuments(String.valueOf(currentSite.getFILENR())); 83 siteList.setTextQueries(String.valueOf(currentSite.getQUERYNR())); 84 if (currentSite.getLASTUPDATE() == null) { 85 siteList.setTextUpdated("never"); 86 } 87 else 88 siteList.setTextUpdated(currentSite.getLASTUPDATE().toLocaleString()); 89 90 link = "javascript:indexLock('" + currentSite.getID() + "');"; siteList.getElementIndexLink().setHref(link); 92 93 link = "javascript:checkLock('DeleteSite.po?id=" + currentSite.getID() + "');"; 94 siteList.getElementDeleteLink().setHref(link); 95 96 link = "javascript:updateLock('" + currentSite.getID() + "');"; 97 siteList.getElementUpdateLink().setHref(link); 98 99 link = "UpdateSitePresentation.po?id=" + currentSite.getID(); 100 siteList.getElementUpdateSiteLink().setHref(link); 101 102 sitesTable.appendChild(templateRow.cloneNode(true)); 104 } 105 106 catch (Exception ex) {ex.printStackTrace();} 107 } 108 templateRow.getParentNode().removeChild(templateRow); 109 return siteList; 111 } 112 113 } 114 | Popular Tags |