Changeset 2186
- Timestamp:
- 08/31/12 12:55:50 (12 years ago)
- Location:
- SRUAggregator/trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUAggregator/trunk/src/java/clarind/fcs/Aggregator.java
r2175 r2186 37 37 38 38 public class Aggregator extends SelectorComposer<Component> { 39 39 40 40 @Wire 41 41 private Grid anzeigeGrid; … … 60 60 @Wire 61 61 private Window mainWindow; 62 63 62 64 63 @Override 65 64 public void doAfterCompose(Component comp) throws Exception { … … 68 67 69 68 languageSelect.setSelectedItem(german); 70 69 71 70 Harvester harv = new Harvester(); 72 71 ArrayList<Endpoint> ep = harv.getEndpoints(); 73 72 74 73 int i, i2; 75 74 76 75 for (i = 0; i < ep.size(); i++) { 77 76 78 77 System.out.println("Calling corpora ...: " + ep.get(i).getUrl()); 79 78 ArrayList<Corpus> corpora = harv.getCorporaOfAnEndpoint(ep.get(i).getUrl()); 80 79 81 80 if (corpora.size() == 0) { 82 81 Checkbox cb = new Checkbox(); … … 85 84 //"?operation=searchRetrieve&version=1.2" 86 85 cb.setLabel(ep.get(i).getUrl()); 87 86 88 87 allCorpora.getChildren().add(cb); 89 88 allCorpora.getChildren().add(new Separator()); 90 89 91 90 System.out.println("CHECKBOX: " + cb.getId()); 92 91 } else { 93 92 Label l = new Label(ep.get(i).getUrl() + ":"); 94 93 95 94 l.setStyle("font-weight:bold"); 96 95 97 96 allCorpora.getChildren().add(l); 98 97 allCorpora.getChildren().add(new Separator()); 99 98 for (i2 = 0; i2 < corpora.size(); i2++) { 100 99 Checkbox cb = new Checkbox(); 101 100 102 101 cb.setId(ep.get(i).getUrl() + "\t" + corpora.get(i2).getValue()); 103 102 cb.setLabel(corpora.get(i2).getDisplayTerm()); 104 103 105 104 allCorpora.getChildren().add(cb); 106 105 allCorpora.getChildren().add(new Separator()); 107 106 108 107 System.out.println("CHECKBOX: " + cb.getId()); 109 108 } // for i2 ... … … 111 110 112 111 Separator sep = new Separator(); 113 112 114 113 sep.setBar(true); 115 114 allCorpora.getChildren().add(sep); 116 115 117 116 } // for i ... 118 117 119 118 } 120 119 121 120 @Listen("onClick = #selectAll") 122 121 public void onSelectAll(Event ev) { 123 122 int i; 124 123 125 124 for (i = 0; i < allCorpora.getChildren().size(); i++) { 126 125 if (allCorpora.getChildren().get(i) instanceof Checkbox) { … … 134 133 public void onDeselectAll(Event ev) { 135 134 int i; 136 135 137 136 for (i = 0; i < allCorpora.getChildren().size(); i++) { 138 137 if (allCorpora.getChildren().get(i) instanceof Checkbox) { … … 150 149 } 151 150 } 152 151 153 152 @Listen("onClick=#clearResults") 154 153 public void onClearResults(Event ev) { 155 154 resultsVbox.getChildren().clear(); 156 155 } 157 156 158 157 @Listen("onClick=#showHelp") 159 158 public void onShowHelp(Event ev) { … … 163 162 help.setHeight("100%"); 164 163 help.setSrc("help.html"); 165 resultsVbox.appendChild(help); 166 } 167 164 resultsVbox.appendChild(help); 165 } 166 167 @Listen("onClick=#showAbout") 168 public void onShowAbout(Event ev) { 169 Messagebox.show("CLARIN-D Federated Content Search Aggregator\n\nVersion 0.0.1", "FCS", 0, Messagebox.INFORMATION); 170 171 } 172 168 173 @Listen("onClick=#exportResultsCSV") 169 174 public void onExportResultsCSV(Event ev) { 170 175 171 176 int i, i2, i3; 172 177 String temp = ""; 173 178 boolean somethingToExport = false; 174 179 175 180 for (i = 0; i < resultsVbox.getChildren().size(); i++) { 176 181 if (resultsVbox.getChildren().get(i) instanceof Grid) { … … 178 183 Grid aGrid = (Grid) resultsVbox.getChildren().get(i); 179 184 Rows rows = aGrid.getRows(); 180 185 181 186 for (i2 = 0; i2 < rows.getChildren().size(); i2++) { 182 187 Row r = (Row) rows.getChildren().get(i2); 183 188 184 189 for (i3 = 0; i3 < r.getChildren().size(); i3++) { 185 190 Label l = (Label) r.getChildren().get(i3); … … 194 199 195 200 } // for i ... 196 201 197 202 if (somethingToExport) { 198 203 199 204 Filedownload.save(temp, "text/plain", "ClarinDFederatedContentSearch.csv"); 200 205 } else { … … 202 207 } 203 208 } 204 205 206 @Listen("onClick=#exportResultsTCF") 209 210 @Listen("onClick=#exportResultsTCF") 207 211 public void onExportResultsTCF(Event ev) { 208 212 209 213 int i, i2, i3; 210 214 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 212 213 215 temp = temp + "<source>CLARIN-D Federated Content Search</source>\n</MetaData>\n <TextCorpus xmlns=\"http://www.dspin.de/data/textcorpus\">\n<text>"; 216 217 214 218 boolean somethingToExport = false; 215 219 216 220 for (i = 0; i < resultsVbox.getChildren().size(); i++) { 217 221 if (resultsVbox.getChildren().get(i) instanceof Grid) { … … 219 223 Grid aGrid = (Grid) resultsVbox.getChildren().get(i); 220 224 Rows rows = aGrid.getRows(); 221 225 222 226 for (i2 = 0; i2 < rows.getChildren().size(); i2++) { 223 227 Row r = (Row) rows.getChildren().get(i2); 224 228 225 229 for (i3 = 0; i3 < r.getChildren().size(); i3++) { 226 230 Label l = (Label) r.getChildren().get(i3); … … 232 236 233 237 } // for i ... 234 238 235 239 if (somethingToExport) { 236 240 temp = temp + "</text>\n</TextCorpus>\n</D-Spin>"; … … 240 244 } 241 245 } 242 243 244 246 245 247 @Listen("onClick = #searchButton") 246 248 public void onExecuteSearch(Event ev) { 247 249 248 250 try { 249 251 250 252 if (languageSelect.getText().trim().equals("")) { 251 253 Messagebox.show("Please select a language."); 252 254 return; 253 255 } 254 256 255 257 int i, i2; 256 257 258 259 258 260 resultsVbox.getChildren().clear(); 259 260 261 262 261 263 boolean isACorpusSelected = false; 262 264 263 265 for (i = 0; i < allCorpora.getChildren().size(); i++) { 264 266 if (allCorpora.getChildren().get(i) instanceof Checkbox) { … … 266 268 if (cb.isChecked()) { 267 269 // now execute the search: 268 270 269 271 isACorpusSelected = true; 270 272 271 273 System.out.println("---- THE SEARCH ----"); 272 274 273 275 String endpointURL = null; 274 276 String corpus = null; 275 277 276 278 if (cb.getId().contains("\t")) { 277 279 endpointURL = cb.getId().split("\t")[0]; … … 280 282 endpointURL = cb.getId(); 281 283 } 282 284 283 285 System.out.println("enddpointURL: " + endpointURL); 284 286 System.out.println("corpus: " + corpus); 285 287 SRUSearch srusearch = new SRUSearch(); 286 288 System.out.println("Calling the client "); 287 289 288 290 resultsVbox.appendChild(new Label("Query: " + searchString.getText())); 289 291 resultsVbox.appendChild(new Label("Endpoint: " + endpointURL)); 290 resultsVbox.appendChild(new Label("Corpus: " + corpus)); 291 292 292 if (corpus != null) { 293 resultsVbox.appendChild(new Label("Corpus: " + corpus)); 294 } 295 296 297 293 298 ArrayList<Row> zeilen = srusearch.execute(searchString.getText(), endpointURL, corpus, 10); 294 299 295 300 if (zeilen.size() > 0) { 296 301 297 302 Grid g = new Grid(); 298 303 304 g.setWidth("100%"); 299 305 g.setMold("paging"); 300 306 g.setPageSize(10); 301 307 302 308 Columns columns = new Columns(); 303 309 304 310 Column c = new Column(); 305 311 c.setLabel("Left"); 306 312 307 313 columns.appendChild(c); 308 314 309 315 c = new Column(); 310 316 c.setLabel("Hit"); 311 317 c.setHflex("min"); 312 318 columns.appendChild(c); 313 319 314 320 c = new Column(); 315 321 c.setLabel("Right"); 316 322 columns.appendChild(c); 317 323 318 324 g.appendChild(columns); 319 325 320 326 Rows rows = new Rows(); 321 327 322 328 for (i2 = 0; i2 < zeilen.size(); i2++) { 323 System.out.println("Adding row " + i2);324 System.out.println("ROW: " + zeilen.get(i2));325 329 rows.appendChild(zeilen.get(i2)); 326 330 } // for i2 ... 327 331 328 332 g.appendChild(rows); 329 333 330 334 resultsVbox.appendChild(g); 331 335 } else { 332 336 resultsVbox.appendChild(new Label("Sorry there were no results!")); 333 337 334 338 } // if zeilen > 0 335 339 … … 340 344 } 341 345 } // for i ... 342 346 343 347 if (!isACorpusSelected) { 344 348 345 349 Messagebox.show("Please select at least one corpus!", "CLARIN-D FCS Aggregator", 0, Messagebox.EXCLAMATION); 346 350 } 347 348 351 352 349 353 System.out.println("Search is done."); 350 354 351 355 } catch (Exception ex) { 352 356 System.out.println(ex.getMessage()); 353 357 } 354 358 355 359 } 356 360 } -
SRUAggregator/trunk/src/java/clarind/fcs/SRUSearch.java
r2171 r2186 19 19 zeilen = new ArrayList<Row>(); 20 20 21 SRU Client client = new SRUClient();21 SRUSimpleClient client = new SRUSimpleClient(); 22 22 client.registerRecordParser(new ClarinFederatedContentSearchRecordParser()); 23 23 24 24 SRUSearchRetrieveRequest request = new SRUSearchRetrieveRequest(endpointURL); 25 25 request.setQuery(query); 26 request.setRecordSchema(ClarinFederatedContentSearchRecord Parser.FCS_RECORD_SCHEMA);26 request.setRecordSchema(ClarinFederatedContentSearchRecordData.RECORD_SCHEMA); 27 27 request.setMaximumRecords(maximumRecords); 28 28 29 29 if (corpus != null) { 30 30 request.setExtraRequestData("x-context", corpus); 31 System.out.println("I'm setting the x-context");32 33 31 } 32 34 33 try { 34 35 35 client.searchRetrieve(request, new SRUDefaultHandlerAdapter() { 36 36 @Override … … 42 42 String right = record.getRight(); 43 43 44 // System.out.print("LEFT: " + left);45 // System.out.println("HIT: " + hit);46 // System.out.println("RIGHT: " + right);47 48 44 Row r = new Row(); 49 45 r.appendChild(new Label(left)); 50 r.appendChild(new Label(hit)); 46 Label l = new Label(hit); 47 l.setStyle("color:#8f3337;"); 48 r.appendChild(l); 51 49 r.appendChild(new Label(right)); 52 50 … … 58 56 System.out.println(ex.getMessage()); 59 57 } 60 61 62 // System.out.println("NUMBER of LINES: " + zeilen.size());63 58 64 59 return zeilen; -
SRUAggregator/trunk/web/index.zul
r2175 r2186 26 26 <groupbox mold="3d" id="allCorpora"> 27 27 <caption>All Corpora</caption> 28 28 29 <label>Select by Language:</label> 29 30 <combobox id="languageSelect" width="150px" value="German"> … … 61 62 <menupopup> 62 63 <menuitem label="Show Help" id="showHelp" image="buttonHelp.png" /> 64 <menuitem label="About" id="showAbout" image="buttonShowAbout.png" /> 63 65 </menupopup> 64 66 </menu> … … 90 92 91 93 <!-- Fusszeile --> 92 <south height="100px">94 <!-- <south height="100px"> 93 95 94 </south> 96 </south>--> 95 97 </borderlayout> 96 98 </window>
Note: See TracChangeset
for help on using the changeset viewer.