1 package enhydraManager.presentation; 2 3 4 import enhydraManager.spec.*; 5 import java.util.Vector ; 7 import java.io.IOException ; 8 9 import com.lutris.appserver.server.httpPresentation.HttpPresentation; 11 import com.lutris.appserver.server.httpPresentation.HttpPresentationComms; 12 import com.lutris.appserver.server.httpPresentation.HttpPresentationException; 13 import org.w3c.dom.html.HTMLAnchorElement; 14 import org.w3c.dom.Node ; 15 16 public class AppDetailPresentation implements HttpPresentation { 17 18 private static AppDetailHTML appDetail; 19 20 public void run(HttpPresentationComms comms) throws HttpPresentationException, IOException { 21 22 try{ 23 try { 24 String colNum = comms.request.getParameter("colNum"); 25 OutputSortList(comms); 26 } catch (Exception e) { 27 OutputList(comms); 28 } 29 }catch(Exception e){ 30 e.printStackTrace(); 31 } 32 } 33 34 private static void setOutput(Vector [] sessionList, String service, String host, String id){ 35 36 Vector sessionIDValues = sessionList[0]; 37 Vector esuValues = sessionList[1]; 38 Vector sdValues = sessionList[2]; 39 Vector ctValues = sessionList[3]; 40 Vector latValues = sessionList[4]; 41 42 String sessionID = null; 43 String esu = null; 44 String sd = null; 45 String ct = null; 46 String lat = null; 47 48 Node sessionElementRow = appDetail.getElementSessions_row(); 49 Node no_entries_row = appDetail.getElementNo_entries_row(); 50 Node sessions_row = appDetail.getElementSessions_row(); 51 52 appDetail.setTextAppName(id.substring(1) + " Session List"); 53 54 HTMLAnchorElement anchorhead_id = appDetail.getElementHead_id(); 55 anchorhead_id.setHref("AppDetailPresentation.po?service=" + service + "&host=" + host + "&id=" + id + "&colNum=0"); 56 anchorhead_id.setTitle("Sort session list by Session ID value!"); 57 appDetail.setTextHead_id("Session ID"); 58 59 HTMLAnchorElement anchorhead_esu = appDetail.getElementHead_esu(); 60 anchorhead_esu.setHref("AppDetailPresentation.po?service=" + service + "&host=" + host + "&id=" + id + "&colNum=1"); 61 anchorhead_esu.setTitle("Sort session list by Enhydra Session User value!"); 62 appDetail.setTextHead_esu("Enhydra Session User"); 63 64 HTMLAnchorElement anchorhead_sd = appDetail.getElementHead_sd(); 65 anchorhead_sd.setHref("AppDetailPresentation.po?service=" + service + "&host=" + host + "&id=" + id + "&colNum=2"); 66 anchorhead_sd.setTitle("Sort session list by Session Data value!"); 67 appDetail.setTextHead_sd("Session Data"); 68 69 HTMLAnchorElement anchorhead_ct = appDetail.getElementHead_ct(); 70 anchorhead_ct.setHref("AppDetailPresentation.po?service=" + service + "&host=" + host + "&id=" + id + "&colNum=3"); 71 anchorhead_ct.setTitle("Sort session list by Session Creation Time value!"); 72 appDetail.setTextHead_ct("Session Creation Time"); 73 74 HTMLAnchorElement anchorhead_lat = appDetail.getElementHead_lat(); 75 anchorhead_lat.setHref("AppDetailPresentation.po?service=" + service + "&host=" + host + "&id=" + id + "&colNum=4"); 76 anchorhead_lat.setTitle("Sort session list by Session Last Accessed Time value!"); 77 appDetail.setTextHead_lat("Session Last Accessed Time"); 78 79 if (sessionIDValues.size() == 0) { 80 81 sessions_row.getParentNode().removeChild(sessions_row); 82 83 }else { 84 no_entries_row.getParentNode().removeChild(no_entries_row); 85 for (int i=0; i<sessionIDValues.size(); i++) { 86 87 sessionID = (String ) sessionIDValues.elementAt(i); 88 try { 89 appDetail.setTextSession_id(sessionID); 90 } catch (IllegalArgumentException ex){ 91 appDetail.setTextSession_id("Couldn't get SessionID!"); 92 } 93 94 esu = (String ) esuValues.elementAt(i); 95 try { 96 appDetail.setTextSession_esu(esu); 97 } catch (IllegalArgumentException ex){ 98 appDetail.setTextSession_esu("Couldn't get Enhydra Session User!"); 99 } 100 101 sd = (String ) sdValues.elementAt(i); 102 try { 103 appDetail.setTextSession_sd(sd); 104 } catch (IllegalArgumentException ex){ 105 appDetail.setTextSession_sd("Couldn't get SessionData!"); 106 } 107 108 ct = (String ) ctValues.elementAt(i); 109 try { 110 appDetail.setTextSession_ct(ct); 111 } catch (IllegalArgumentException ex){ 112 appDetail.setTextSession_ct("Couldn't get session creation time!"); 113 } 114 115 lat = (String ) latValues.elementAt(i); 116 try { 117 appDetail.setTextSession_lat(lat); 118 } catch (IllegalArgumentException ex){ 119 appDetail.setTextSession_lat("Couldn't get session last access time!"); 120 } 121 122 sessionElementRow.getParentNode().insertBefore(sessionElementRow.cloneNode(true), 123 sessionElementRow); 124 125 } 126 sessionElementRow.getParentNode().removeChild(sessionElementRow); 127 } 128 } 129 130 public static void OutputList(HttpPresentationComms comms) throws Exception { 131 132 String id = null; 133 String host=null; 134 String service=null; 135 try { 136 service=comms.request.getParameter("service"); 137 host=comms.request.getParameter("host"); 138 id = comms.request.getParameter("id"); 139 } catch (Exception e) {} 140 141 142 143 AppDetailSessionList appDetailSessionList=AppDetailSessionListFactory.getAppDetailSessionList("enhydraManager.business.AppDetailSessionListImpl"); 144 Vector [] sessionList=appDetailSessionList.getList(service,host,id); 145 146 147 148 appDetail = (AppDetailHTML)comms.xmlcFactory.create(AppDetailHTML.class); 149 150 setOutput(sessionList,service,host,id); 151 152 comms.response.writeDOM(appDetail); 153 } 154 155 public static void sort (Vector [] params, int col){ 156 String temp= null; 157 for (int i =0; i< params[col].size()-1; i++){ 158 for (int j =i+1; j< params[col].size(); j++){ 159 if ((((String )params[col].elementAt(i)).compareTo((String )params[col].elementAt(j)))>0){ 160 for (int k=0;k<params.length;k++){ 161 temp=(String )params[k].elementAt(i); 162 params[k].setElementAt(params[k].elementAt(j),i); 163 params[k].setElementAt(temp,j); 164 } 165 } 166 } 167 } 168 169 } 170 171 public static void OutputSortList(HttpPresentationComms comms) throws Exception { 172 String id = null; 173 String colNum = null; 174 String host = null; 175 String service = null; 176 try { 177 service = comms.request.getParameter("service"); 178 host = comms.request.getParameter("host"); 179 id = comms.request.getParameter("id"); 180 colNum = comms.request.getParameter("colNum"); 181 } catch (Exception e) {} 182 183 184 185 AppDetailSessionList appDetailSessionList=AppDetailSessionListFactory.getAppDetailSessionList("enhydraManager.business.AppDetailSessionListImpl"); 186 Vector [] sessionList=appDetailSessionList.getList(service,host,id); 187 188 189 sort(sessionList,Integer.parseInt(colNum)); 190 191 appDetail = (AppDetailHTML)comms.xmlcFactory.create(AppDetailHTML.class); 192 193 setOutput(sessionList,service,host,id); 194 195 comms.response.writeDOM(appDetail); 196 } 197 } 198 199 | Popular Tags |