1 package sessionViewer.presentation; 2 3 4 import sessionViewer.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 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?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?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?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?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?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 134 try { 135 id = comms.request.getParameter("id"); 136 } catch (Exception e) {} 137 138 139 140 AppDetailSessionList appDetailSessionList=AppDetailSessionListFactory.getAppDetailSessionList("sessionViewer.business.AppDetailSessionListImpl"); 141 Vector [] sessionList=appDetailSessionList.getList(id); 142 143 144 145 appDetail = (AppDetailHTML)comms.xmlcFactory.create(AppDetailHTML.class); 146 147 setOutput(sessionList,id); 148 149 comms.response.writeDOM(appDetail); 150 } 151 152 public static void sort (Vector [] params, int col){ 153 String temp= null; 154 for (int i =0; i< params[col].size()-1; i++){ 155 for (int j =i+1; j< params[col].size(); j++){ 156 if ((((String )params[col].elementAt(i)).compareTo((String )params[col].elementAt(j)))>0){ 157 for (int k=0;k<params.length;k++){ 158 temp=(String )params[k].elementAt(i); 159 params[k].setElementAt(params[k].elementAt(j),i); 160 params[k].setElementAt(temp,j); 161 } 162 } 163 } 164 } 165 166 } 167 168 public static void OutputSortList(HttpPresentationComms comms) throws Exception { 169 String id = null; 170 String colNum = null; 171 172 try { 173 id = comms.request.getParameter("id"); 174 colNum = comms.request.getParameter("colNum"); 175 } catch (Exception e) {} 176 177 178 179 AppDetailSessionList appDetailSessionList=AppDetailSessionListFactory.getAppDetailSessionList("sessionViewer.business.AppDetailSessionListImpl"); 180 Vector [] sessionList=appDetailSessionList.getList(id); 181 182 183 sort(sessionList,Integer.parseInt(colNum)); 184 185 appDetail = (AppDetailHTML)comms.xmlcFactory.create(AppDetailHTML.class); 186 187 setOutput(sessionList,id); 188 189 comms.response.writeDOM(appDetail); 190 } 191 } 192 193 | Popular Tags |