Changeset 2171
- Timestamp:
- 08/29/12 12:46:08 (12 years ago)
- Location:
- SRUAggregator/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUAggregator/trunk/src/java/clarind/fcs/Aggregator.java
r2161 r2171 1 1 package clarind.fcs; 2 2 3 import eu.clarin.sru.client.SRUClient;4 import eu.clarin.sru.client.SRUClientException;5 import eu.clarin.sru.client.SRUDefaultHandlerAdapter;6 import eu.clarin.sru.client.SRURecordData;7 import eu.clarin.sru.client.SRUSearchRetrieveRequest;8 import eu.clarin.sru.client.SRUVersion;9 import eu.clarin.sru.fcs.ClarinFederatedContentSearchRecordData;10 import eu.clarin.sru.fcs.ClarinFederatedContentSearchRecordParser;3 //import eu.clarin.sru.client.SRUClient; 4 //import eu.clarin.sru.client.SRUClientException; 5 //import eu.clarin.sru.client.SRUDefaultHandlerAdapter; 6 //import eu.clarin.sru.client.SRURecordData; 7 //import eu.clarin.sru.client.SRUSearchRetrieveRequest; 8 //import eu.clarin.sru.client.SRUVersion; 9 //import eu.clarin.sru.fcs.ClarinFederatedContentSearchRecordData; 10 //import eu.clarin.sru.fcs.ClarinFederatedContentSearchRecordParser; 11 11 import java.util.ArrayList; 12 import org.zkoss.zhtml.Filedownload; 12 13 import org.zkoss.zk.ui.Component; 13 14 import org.zkoss.zk.ui.event.Event; … … 25 26 import org.zkoss.zul.Separator; 26 27 import org.zkoss.zul.Label; 27 import org.zkoss.zul.Html;28 //import org.zkoss.zul.Html; 28 29 import org.zkoss.zul.Comboitem; 29 30 import org.zkoss.zul.Grid; 31 //import org.zkoss.zul.Panelchildren; 32 import org.zkoss.zul.Columns; 33 import org.zkoss.zul.Column; 34 import org.zkoss.zul.Vbox; 30 35 31 36 public class Aggregator extends SelectorComposer<Component> { … … 46 51 private Comboitem german; 47 52 @Wire 48 private Html anzeigeResults; 53 private Vbox resultsVbox; 54 @Wire 55 private Button selectAll; 56 @Wire 57 private Button deselectAll; 49 58 50 59 @Override … … 79 88 Label l = new Label(ep.get(i).getUrl() + ":"); 80 89 90 l.setStyle("font-weight:bold"); 91 81 92 allCorpora.getChildren().add(l); 82 93 allCorpora.getChildren().add(new Separator()); … … 84 95 Checkbox cb = new Checkbox(); 85 96 86 //http://clarinws.informatik.uni-leipzig.de:8080/CQL?operation=searchRetrieve&version=1.2&query=Boppard&x-context=11858/00-229C-0000-0003-174F-D&maximumRecords=287 88 97 cb.setId(ep.get(i).getUrl() + "\t" + corpora.get(i2).getValue()); 89 98 cb.setLabel(corpora.get(i2).getDisplayTerm()); … … 95 104 } // for i2 ... 96 105 } // if corpora.size else 106 107 Separator sep = new Separator(); 108 109 sep.setBar(true); 110 allCorpora.getChildren().add(sep); 111 97 112 } // for i ... 98 } 113 114 } 115 116 @Listen("onClick = #selectAll") 117 public void onSelectAll(Event ev) { 118 int i; 119 120 for (i = 0; i < allCorpora.getChildren().size(); i++) { 121 if (allCorpora.getChildren().get(i) instanceof Checkbox) { 122 Checkbox cb = (Checkbox) allCorpora.getChildren().get(i); 123 cb.setChecked(true); 124 } 125 } 126 } //onSelectAll 127 128 @Listen("onClick = #deselectAll") 129 public void onDeselectAll(Event ev) { 130 int i; 131 132 for (i = 0; i < allCorpora.getChildren().size(); i++) { 133 if (allCorpora.getChildren().get(i) instanceof Checkbox) { 134 Checkbox cb = (Checkbox) allCorpora.getChildren().get(i); 135 cb.setChecked(false); 136 } 137 } 138 } //onDeselectAll 99 139 100 140 @Listen("onSelect = #languageSelect") … … 106 146 } 107 147 148 @Listen("onClick=#clearResults") 149 public void onClearResults(Event ev) { 150 resultsVbox.getChildren().clear(); 151 } 152 153 @Listen("onClick=#exportResults") 154 public void onExportResults(Event ev) { 155 156 int i, i2, i3; 157 String temp = ""; 158 159 for (i = 0; i < resultsVbox.getChildren().size(); i++) { 160 if (resultsVbox.getChildren().get(i) instanceof Grid) { 161 Grid aGrid = (Grid) resultsVbox.getChildren().get(i); 162 Rows rows = aGrid.getRows(); 163 164 for (i2 = 0; i2 < rows.getChildren().size(); i2++) { 165 Row r = (Row) rows.getChildren().get(i2); 166 167 for (i3 = 0; i3 < r.getChildren().size(); i3++) { 168 Label l = (Label) r.getChildren().get(i3); 169 temp = temp + l.getValue(); 170 if (i3 < r.getChildren().size() - 1) { 171 temp = temp + "\t"; 172 } //if i3 173 } //for i3 174 temp = temp + "\n"; 175 } // for i2 176 } // if grid 177 178 } // for i ... 179 Filedownload.save(temp, "text/plain", "table.csv"); 180 } 181 108 182 @Listen("onClick = #searchButton") 109 183 public void onExecuteSearch(Event ev) { 110 // try {111 // ExecuteSRUSearch.execute();112 // } catch (Exception ex){113 // System.out.println(ex.getMessage());114 // }115 116 117 184 118 185 try { … … 123 190 } 124 191 125 anzeigeResults.setContent("");126 127 192 int i, i2; 193 194 195 resultsVbox.getChildren().clear(); 196 197 198 128 199 129 200 for (i = 0; i < allCorpora.getChildren().size(); i++) { … … 132 203 if (cb.isChecked()) { 133 204 // now execute the search: 134 // String query = cb.getId() + "&maximumRecords=10&query=" + searchString.getText(); 135 // display = display + query + "\n"; 205 136 206 System.out.println("---- THE SEARCH ----"); 137 207 … … 149 219 System.out.println("corpus: " + corpus); 150 220 SRUSearch srusearch = new SRUSearch(); 151 anzeigeResults.setContent(anzeigeResults.getContent() + srusearch.execute(searchString.getText(), endpointURL, corpus, 10, anzeigeResults, anzeigeGrid).toString()); 152 153 154 221 System.out.println("Calling the client "); 222 223 resultsVbox.appendChild(new Label("Query: " + searchString.getText())); 224 resultsVbox.appendChild(new Label("Endpoint: " + endpointURL)); 225 resultsVbox.appendChild(new Label("Corpus: " + corpus)); 226 227 228 ArrayList<Row> zeilen = srusearch.execute(searchString.getText(), endpointURL, corpus, 10); 229 230 if (zeilen.size() > 0) { 231 232 Grid g = new Grid(); 233 234 g.setMold("paging"); 235 g.setPageSize(10); 236 237 Columns columns = new Columns(); 238 239 Column c = new Column(); 240 c.setLabel("Left"); 241 242 columns.appendChild(c); 243 244 c = new Column(); 245 c.setLabel("Hit"); 246 c.setHflex("min"); 247 columns.appendChild(c); 248 249 c = new Column(); 250 c.setLabel("Right"); 251 columns.appendChild(c); 252 253 g.appendChild(columns); 254 255 Rows rows = new Rows(); 256 257 for (i2 = 0; i2 < zeilen.size(); i2++) { 258 System.out.println("Adding row " + i2); 259 System.out.println("ROW: " + zeilen.get(i2)); 260 rows.appendChild(zeilen.get(i2)); 261 } // for i2 ... 262 263 g.appendChild(rows); 264 265 resultsVbox.appendChild(g); 266 } else { 267 resultsVbox.appendChild(new Label("Sorry there were no results!")); 268 269 } // if zeilen > 0 270 271 Separator sep = new Separator(); 272 sep.setSpacing("20px"); 273 resultsVbox.appendChild(sep); 155 274 } 156 275 } 157 276 } // for i ... 158 277 System.out.println("Done"); 159 //Messagebox.show(display);160 278 161 279 } catch (Exception ex) { -
SRUAggregator/trunk/src/java/clarind/fcs/SRUSearch.java
r2161 r2171 5 5 import eu.clarin.sru.fcs.ClarinFederatedContentSearchRecordData; 6 6 import eu.clarin.sru.fcs.ClarinFederatedContentSearchRecordParser; 7 import org.xml.sax.helpers.DefaultHandler;7 //import org.xml.sax.helpers.DefaultHandler; 8 8 9 import org.zkoss.zul.Html;10 import org.zkoss.zul.Grid;11 import org.zkoss.zul.Rows;12 9 import org.zkoss.zul.Row; 13 10 import org.zkoss.zul.Label; 14 11 12 import java.util.*; 15 13 16 14 public class SRUSearch { 17 private StringBuilder sb; 18 19 public StringBuilder execute(String query, String endpointURL, String corpus, int maximumRecords, Html results, final Grid grid) throws Exception { 20 sb = new StringBuilder(); 21 sb.append("URL: "+ endpointURL + "<br>"); 22 sb.append("CORPUS: " + corpus + "<br><hr>"); 23 24 15 16 private ArrayList<Row> zeilen; 17 18 public ArrayList<Row> execute(String query, String endpointURL, String corpus, int maximumRecords) throws Exception { 19 zeilen = new ArrayList<Row>(); 20 25 21 SRUClient client = new SRUClient(); 26 22 client.registerRecordParser(new ClarinFederatedContentSearchRecordParser()); … … 36 32 37 33 } 38 34 try { 39 35 client.searchRetrieve(request, new SRUDefaultHandlerAdapter() { 40 36 @Override … … 45 41 String hit = record.getKeyword(); 46 42 String right = record.getRight(); 47 48 System.out.print("LEFT: " + left); 49 System.out.println("HIT: " + hit); 50 System.out.println("RIGHT: " + right); 51 52 sb.append(left); 53 sb.append("<font color='red'>"); 54 sb.append(" " + hit + " "); 55 sb.append("</font>"); 56 sb.append(right); 57 sb.append("<br><br>"); 58 59 // Rows rows = grid.getRows(); 60 // Row r = new Row(); 61 // r.appendChild(new Label(left)); 62 // r.appendChild(new Label(hit)); 63 // r.appendChild(new Label(right)); 64 // 65 // rows.appendChild(r); 66 67 43 44 // System.out.print("LEFT: " + left); 45 // System.out.println("HIT: " + hit); 46 // System.out.println("RIGHT: " + right); 47 48 Row r = new Row(); 49 r.appendChild(new Label(left)); 50 r.appendChild(new Label(hit)); 51 r.appendChild(new Label(right)); 52 53 zeilen.add(r); 68 54 } 69 55 } 70 56 }); 71 sb.append("<hr>"); 72 return sb; 57 } catch (Exception ex){ 58 System.out.println(ex.getMessage()); 59 } 60 61 62 // System.out.println("NUMBER of LINES: " + zeilen.size()); 63 64 return zeilen; 73 65 } 74 66 75 67 public static void main(String[] args) throws Exception { 76 77 78 79 80 68 } // main 81 69 } -
SRUAggregator/trunk/web/index.zul
r2161 r2171 4 4 <borderlayout sclass="complex-layout" > 5 5 <!-- Kopf --> 6 <north height=" 100px">7 6 <north height="65px"> 7 <image src="clarindLogo.png"/> 8 8 </north> 9 9 … … 18 18 <panelchildren style="margin-top:10px;margin-left:10px;margin-right:10px;border:0;"> 19 19 <textbox id="searchString" value="Elefant" /> 20 <button id="searchButton" label="Search" />20 <button id="searchButton" label="Search" image="buttonSearch.png"/> 21 21 <!-- forward ="onExecuteSearch"--> 22 22 <separator /> 23 <label>Language:</label> 23 24 25 <groupbox mold="3d" id="allCorpora"> 26 <caption>All Corpora</caption> 27 <label>Select by Language:</label> 24 28 <combobox id="languageSelect" width="150px" value="German"> 25 29 <!--<template name="model"> --> … … 31 35 </combobox> 32 36 37 <separator /> 38 39 <button id="selectAll" label="Select All" image="buttonSelectAll.png"/> 40 41 <button id="deselectAll" label="Deselect All" image="buttonDeselectAll.png"/> 42 33 43 <separator /> 34 35 <groupbox mold="3d" id="allCorpora">36 <caption>All Corpora</caption>44 45 46 37 47 </groupbox> 38 48 </panelchildren> … … 43 53 <center flex="true" margins="0,5,0,0" autoscroll="true" > 44 54 <panel> 45 <panelchildren style="overflow: auto"> 55 <panelchildren id="resultsPanel" style="overflow: auto"> 56 <toolbar id="resultsToolbar" height="20px"> 57 <toolbarbutton id="clearResults" label="Clear Results" image="buttonDelete.png"/> 58 <toolbarbutton id="exportResults" label="Export Results" image="buttonExport.png"/> 59 60 </toolbar> 61 <vbox id="resultsVbox"> 46 62 <grid id="anzeigeGrid"> 47 63 <columns> … … 50 66 <column></column> 51 67 </columns> 68 <rows></rows> 52 69 </grid> 53 70 <html id="anzeigeResults" /> 71 </vbox> 54 72 </panelchildren> 55 73
Note: See TracChangeset
for help on using the changeset viewer.