Changeset 2175
- Timestamp:
- 08/30/12 12:16:14 (12 years ago)
- Location:
- SRUAggregator/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUAggregator/trunk/src/java/clarind/fcs/Aggregator.java
r2171 r2175 33 33 import org.zkoss.zul.Column; 34 34 import org.zkoss.zul.Vbox; 35 import org.zkoss.zul.Iframe; 36 import org.zkoss.zul.Window; 35 37 36 38 public class Aggregator extends SelectorComposer<Component> { 37 39 38 40 @Wire 39 41 private Grid anzeigeGrid; … … 56 58 @Wire 57 59 private Button deselectAll; 58 60 @Wire 61 private Window mainWindow; 62 63 59 64 @Override 60 65 public void doAfterCompose(Component comp) throws Exception { … … 63 68 64 69 languageSelect.setSelectedItem(german); 65 70 66 71 Harvester harv = new Harvester(); 67 72 ArrayList<Endpoint> ep = harv.getEndpoints(); 68 73 69 74 int i, i2; 70 75 71 76 for (i = 0; i < ep.size(); i++) { 72 77 73 78 System.out.println("Calling corpora ...: " + ep.get(i).getUrl()); 74 79 ArrayList<Corpus> corpora = harv.getCorporaOfAnEndpoint(ep.get(i).getUrl()); 75 80 76 81 if (corpora.size() == 0) { 77 82 Checkbox cb = new Checkbox(); … … 80 85 //"?operation=searchRetrieve&version=1.2" 81 86 cb.setLabel(ep.get(i).getUrl()); 82 87 83 88 allCorpora.getChildren().add(cb); 84 89 allCorpora.getChildren().add(new Separator()); 85 90 86 91 System.out.println("CHECKBOX: " + cb.getId()); 87 92 } else { 88 93 Label l = new Label(ep.get(i).getUrl() + ":"); 89 94 90 95 l.setStyle("font-weight:bold"); 91 96 92 97 allCorpora.getChildren().add(l); 93 98 allCorpora.getChildren().add(new Separator()); 94 99 for (i2 = 0; i2 < corpora.size(); i2++) { 95 100 Checkbox cb = new Checkbox(); 96 101 97 102 cb.setId(ep.get(i).getUrl() + "\t" + corpora.get(i2).getValue()); 98 103 cb.setLabel(corpora.get(i2).getDisplayTerm()); 99 104 100 105 allCorpora.getChildren().add(cb); 101 106 allCorpora.getChildren().add(new Separator()); 102 107 103 108 System.out.println("CHECKBOX: " + cb.getId()); 104 109 } // for i2 ... … … 106 111 107 112 Separator sep = new Separator(); 108 113 109 114 sep.setBar(true); 110 115 allCorpora.getChildren().add(sep); 111 116 112 117 } // for i ... 113 118 114 119 } 115 120 116 121 @Listen("onClick = #selectAll") 117 122 public void onSelectAll(Event ev) { 118 123 int i; 119 124 120 125 for (i = 0; i < allCorpora.getChildren().size(); i++) { 121 126 if (allCorpora.getChildren().get(i) instanceof Checkbox) { … … 129 134 public void onDeselectAll(Event ev) { 130 135 int i; 131 136 132 137 for (i = 0; i < allCorpora.getChildren().size(); i++) { 133 138 if (allCorpora.getChildren().get(i) instanceof Checkbox) { … … 145 150 } 146 151 } 147 152 148 153 @Listen("onClick=#clearResults") 149 154 public void onClearResults(Event ev) { 150 155 resultsVbox.getChildren().clear(); 151 156 } 152 153 @Listen("onClick=#exportResults") 154 public void onExportResults(Event ev) { 155 157 158 @Listen("onClick=#showHelp") 159 public void onShowHelp(Event ev) { 160 resultsVbox.getChildren().clear(); 161 Iframe help = new Iframe(); 162 help.setWidth("100%"); 163 help.setHeight("100%"); 164 help.setSrc("help.html"); 165 resultsVbox.appendChild(help); 166 } 167 168 @Listen("onClick=#exportResultsCSV") 169 public void onExportResultsCSV(Event ev) { 170 156 171 int i, i2, i3; 157 172 String temp = ""; 158 173 boolean somethingToExport = false; 174 159 175 for (i = 0; i < resultsVbox.getChildren().size(); i++) { 160 176 if (resultsVbox.getChildren().get(i) instanceof Grid) { 177 somethingToExport = true; 161 178 Grid aGrid = (Grid) resultsVbox.getChildren().get(i); 162 179 Rows rows = aGrid.getRows(); 163 180 164 181 for (i2 = 0; i2 < rows.getChildren().size(); i2++) { 165 182 Row r = (Row) rows.getChildren().get(i2); 166 183 167 184 for (i3 = 0; i3 < r.getChildren().size(); i3++) { 168 185 Label l = (Label) r.getChildren().get(i3); … … 177 194 178 195 } // for i ... 179 Filedownload.save(temp, "text/plain", "table.csv"); 180 } 181 196 197 if (somethingToExport) { 198 199 Filedownload.save(temp, "text/plain", "ClarinDFederatedContentSearch.csv"); 200 } else { 201 Messagebox.show("Nothing to export!"); 202 } 203 } 204 205 206 @Listen("onClick=#exportResultsTCF") 207 public void onExportResultsTCF(Event ev) { 208 209 int i, i2, i3; 210 String temp = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><D-Spin xmlns=\"http://www.dspin.de/data\" version=\"0.4\">\n<MetaData xmlns=\"http://www.dspin.de/data/metadata\">\n"; 211 temp = temp + "<source>CLARIN-D Federated Content Search</source>\n</MetaData>\n <TextCorpus xmlns=\"http://www.dspin.de/data/textcorpus\">\n<text>"; 212 213 214 boolean somethingToExport = false; 215 216 for (i = 0; i < resultsVbox.getChildren().size(); i++) { 217 if (resultsVbox.getChildren().get(i) instanceof Grid) { 218 somethingToExport = true; 219 Grid aGrid = (Grid) resultsVbox.getChildren().get(i); 220 Rows rows = aGrid.getRows(); 221 222 for (i2 = 0; i2 < rows.getChildren().size(); i2++) { 223 Row r = (Row) rows.getChildren().get(i2); 224 225 for (i3 = 0; i3 < r.getChildren().size(); i3++) { 226 Label l = (Label) r.getChildren().get(i3); 227 temp = temp + l.getValue() + " "; 228 } //for i3 229 temp = temp + "\n"; 230 } // for i2 231 } // if grid 232 233 } // for i ... 234 235 if (somethingToExport) { 236 temp = temp + "</text>\n</TextCorpus>\n</D-Spin>"; 237 Filedownload.save(temp, "text/tcf+xml", "ClarinDFederatedContentSearch.xml"); 238 } else { 239 Messagebox.show("Nothing to export!"); 240 } 241 } 242 243 244 182 245 @Listen("onClick = #searchButton") 183 246 public void onExecuteSearch(Event ev) { 184 247 185 248 try { 186 249 187 250 if (languageSelect.getText().trim().equals("")) { 188 251 Messagebox.show("Please select a language."); 189 252 return; 190 253 } 191 254 192 255 int i, i2; 193 194 256 257 195 258 resultsVbox.getChildren().clear(); 196 197 198 199 259 260 261 boolean isACorpusSelected = false; 262 200 263 for (i = 0; i < allCorpora.getChildren().size(); i++) { 201 264 if (allCorpora.getChildren().get(i) instanceof Checkbox) { … … 203 266 if (cb.isChecked()) { 204 267 // now execute the search: 205 268 269 isACorpusSelected = true; 270 206 271 System.out.println("---- THE SEARCH ----"); 207 272 208 273 String endpointURL = null; 209 274 String corpus = null; 210 275 211 276 if (cb.getId().contains("\t")) { 212 277 endpointURL = cb.getId().split("\t")[0]; … … 215 280 endpointURL = cb.getId(); 216 281 } 217 282 218 283 System.out.println("enddpointURL: " + endpointURL); 219 284 System.out.println("corpus: " + corpus); 220 285 SRUSearch srusearch = new SRUSearch(); 221 286 System.out.println("Calling the client "); 222 287 223 288 resultsVbox.appendChild(new Label("Query: " + searchString.getText())); 224 289 resultsVbox.appendChild(new Label("Endpoint: " + endpointURL)); 225 290 resultsVbox.appendChild(new Label("Corpus: " + corpus)); 226 227 291 292 228 293 ArrayList<Row> zeilen = srusearch.execute(searchString.getText(), endpointURL, corpus, 10); 229 294 230 295 if (zeilen.size() > 0) { 231 296 232 297 Grid g = new Grid(); 233 298 234 299 g.setMold("paging"); 235 300 g.setPageSize(10); 236 301 237 302 Columns columns = new Columns(); 238 303 239 304 Column c = new Column(); 240 305 c.setLabel("Left"); 241 306 242 307 columns.appendChild(c); 243 308 244 309 c = new Column(); 245 310 c.setLabel("Hit"); 246 311 c.setHflex("min"); 247 312 columns.appendChild(c); 248 313 249 314 c = new Column(); 250 315 c.setLabel("Right"); 251 316 columns.appendChild(c); 252 317 253 318 g.appendChild(columns); 254 319 255 320 Rows rows = new Rows(); 256 321 257 322 for (i2 = 0; i2 < zeilen.size(); i2++) { 258 323 System.out.println("Adding row " + i2); … … 262 327 263 328 g.appendChild(rows); 264 329 265 330 resultsVbox.appendChild(g); 266 331 } else { 267 332 resultsVbox.appendChild(new Label("Sorry there were no results!")); 268 333 269 334 } // if zeilen > 0 270 335 … … 275 340 } 276 341 } // for i ... 277 System.out.println("Done"); 278 342 343 if (!isACorpusSelected) { 344 345 Messagebox.show("Please select at least one corpus!", "CLARIN-D FCS Aggregator", 0, Messagebox.EXCLAMATION); 346 } 347 348 349 System.out.println("Search is done."); 350 279 351 } catch (Exception ex) { 280 352 System.out.println(ex.getMessage()); 281 353 } 282 354 283 355 } 284 356 } -
SRUAggregator/trunk/web/index.zul
r2171 r2175 1 1 2 2 <zk> 3 <!--title="CLARIN-D Federated Content Search"--> 3 4 <window id="mainWindow" contentStyle="background:white;" height="100%" apply="clarind.fcs.Aggregator"> 4 5 <borderlayout sclass="complex-layout" > … … 19 20 <textbox id="searchString" value="Elefant" /> 20 21 <button id="searchButton" label="Search" image="buttonSearch.png"/> 21 <!-- forward ="onExecuteSearch"--> 22 22 23 <separator /> 23 24 … … 27 28 <label>Select by Language:</label> 28 29 <combobox id="languageSelect" width="150px" value="German"> 29 <!--<template name="model"> -->30 30 <comboitem label="German" id="german"/> 31 31 <comboitem label="English" id="english"/> 32 32 <comboitem label="Dutch" id="dutch" /> 33 33 <comboitem label="-More to come-" /> 34 <!-- </template> -->35 34 </combobox> 36 35 37 36 <separator /> 38 37 39 <button id="selectAll" label="Select All" image="buttonSelectAll.png"/> 40 41 <button id="deselectAll" label="Deselect All" image="buttonDeselectAll.png"/> 42 38 <button id="selectAll" label="Select All" image="buttonSelectAll.png"/> 39 <button id="deselectAll" label="Deselect All" image="buttonDeselectAll.png"/> 40 43 41 <separator /> 44 45 46 42 47 43 </groupbox> 48 44 </panelchildren> … … 54 50 <panel> 55 51 <panelchildren id="resultsPanel" style="overflow: auto"> 56 <toolbar id="resultsToolbar" height="20px"> 57 <toolbarbutton id="clearResults" label="Clear Results" image="buttonDelete.png"/> 52 <menubar id="menubar" width="100%"> 53 <menu label="Actions" image="buttonActions.png"> 54 <menupopup> 55 <menuitem label="Clear Results" id="clearResults" image="buttonDelete.png" /> 56 <menuitem label="Export Results to CSV" id="exportResultsCSV" image="buttonExport.png" /> 57 <menuitem label="Export Results to TCF" id="exportResultsTCF" image="buttonExport.png" /> 58 </menupopup> 59 </menu> 60 <menu label="Help" image="buttonHelp.png"> 61 <menupopup> 62 <menuitem label="Show Help" id="showHelp" image="buttonHelp.png" /> 63 </menupopup> 64 </menu> 65 66 </menubar> 67 <!-- <toolbar id="resultsToolbar" height="20px"> 68 <toolbarbutton id="clearResults" label="Clear Results" image="buttonDelete.png"/> 58 69 <toolbarbutton id="exportResults" label="Export Results" image="buttonExport.png"/> 70 <toolbarbutton id="showHelp" label="Show Help" image="buttonHelp.png"/> 59 71 60 72 </toolbar> 73 --> 61 74 <vbox id="resultsVbox"> 62 <grid id="anzeigeGrid"> 63 <columns> 64 <column></column> 65 <column></column> 66 <column></column> 67 </columns> 68 <rows></rows> 69 </grid> 70 <html id="anzeigeResults" /> 75 <iframe src="help.html" width="100%" height="100%"/> 76 <grid id="anzeigeGrid"> 77 <columns> 78 <column></column> 79 <column></column> 80 <column></column> 81 </columns> 82 <rows></rows> 83 </grid> 84 <html id="anzeigeResults" /> 71 85 </vbox> 72 86 </panelchildren> 73 87 74 88 </panel> 75 76 77 89 </center> 78 90
Note: See TracChangeset
for help on using the changeset viewer.