Changeset 2161
- Timestamp:
- 08/28/12 14:52:41 (12 years ago)
- Location:
- SRUAggregator/trunk
- Files:
-
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
SRUAggregator/trunk/nbproject/build-impl.xml
r2097 r2161 976 976 <target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest"> 977 977 <copyfiles files="${libs.zk.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/> 978 <copyfiles files="${libs.SRUClientLibs.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/> 978 979 <copyfiles files="${libs.SRUCQLClient.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/> 979 980 <mkdir dir="${build.web.dir}/META-INF"/> … … 982 983 <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir"> 983 984 <copyfiles files="${libs.zk.classpath}" todir="${build.web.dir}/WEB-INF/lib"/> 985 <copyfiles files="${libs.SRUClientLibs.classpath}" todir="${build.web.dir}/WEB-INF/lib"/> 984 986 <copyfiles files="${libs.SRUCQLClient.classpath}" todir="${build.web.dir}/WEB-INF/lib"/> 985 987 </target> -
SRUAggregator/trunk/nbproject/genfiles.properties
r2097 r2161 1 build.xml.data.CRC32= 1ca8f6891 build.xml.data.CRC32=bb4ec976 2 2 build.xml.script.CRC32=e9ec94ca 3 3 build.xml.stylesheet.CRC32=651128d4@1.38.1.1 4 4 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 5 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 nbproject/build-impl.xml.data.CRC32= 1ca8f6897 nbproject/build-impl.xml.script.CRC32= 1ad9793f6 nbproject/build-impl.xml.data.CRC32=bb4ec976 7 nbproject/build-impl.xml.script.CRC32=34eb7b98 8 8 nbproject/build-impl.xml.stylesheet.CRC32=4e9cae83@1.38.1.1 -
SRUAggregator/trunk/nbproject/project.properties
r2097 r2161 37 37 javac.classpath=\ 38 38 ${libs.zk.classpath}:\ 39 ${libs.SRUClientLibs.classpath}:\ 39 40 ${libs.SRUCQLClient.classpath} 40 41 # Space-separated list of extra javac options -
SRUAggregator/trunk/nbproject/project.xml
r2097 r2161 9 9 <library dirs="200"> 10 10 <file>${libs.zk.classpath}</file> 11 <path-in-war>WEB-INF/lib</path-in-war> 12 </library> 13 <library dirs="200"> 14 <file>${libs.SRUClientLibs.classpath}</file> 11 15 <path-in-war>WEB-INF/lib</path-in-war> 12 16 </library> -
SRUAggregator/trunk/src/java/clarind/fcs/Aggregator.java
r2107 r2161 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 11 import java.util.ArrayList; 4 12 import org.zkoss.zk.ui.Component; … … 17 25 import org.zkoss.zul.Separator; 18 26 import org.zkoss.zul.Label; 27 import org.zkoss.zul.Html; 19 28 import org.zkoss.zul.Comboitem; 29 import org.zkoss.zul.Grid; 20 30 21 31 public class Aggregator extends SelectorComposer<Component> { 22 32 33 @Wire 34 private Grid anzeigeGrid; 23 35 @Wire 24 36 private Textbox searchString; … … 31 43 @Wire 32 44 private Groupbox allCorpora; 33 45 @Wire 34 46 private Comboitem german; 47 @Wire 48 private Html anzeigeResults; 35 49 36 50 @Override … … 38 52 super.doAfterCompose(comp); //wire variables and event listners 39 53 //do whatever you want (you could access wired variables here) 40 54 41 55 languageSelect.setSelectedItem(german); 42 56 43 57 Harvester harv = new Harvester(); 44 58 ArrayList<Endpoint> ep = harv.getEndpoints(); … … 53 67 if (corpora.size() == 0) { 54 68 Checkbox cb = new Checkbox(); 55 cb.setId(ep.get(i).getUrl() + "?operation=searchRetrieve&version=1.2"); 69 cb.setId(ep.get(i).getUrl()); 70 71 //"?operation=searchRetrieve&version=1.2" 56 72 cb.setLabel(ep.get(i).getUrl()); 57 73 58 74 allCorpora.getChildren().add(cb); 59 75 allCorpora.getChildren().add(new Separator()); 76 77 System.out.println("CHECKBOX: " + cb.getId()); 60 78 } else { 61 79 Label l = new Label(ep.get(i).getUrl() + ":"); … … 65 83 for (i2 = 0; i2 < corpora.size(); i2++) { 66 84 Checkbox cb = new Checkbox(); 67 85 68 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=2 69 87 70 cb.setId(ep.get(i).getUrl() + " ?operation=searchRetrieve&version=1.2&x-context=" + corpora.get(i2).getValue());88 cb.setId(ep.get(i).getUrl() + "\t" + corpora.get(i2).getValue()); 71 89 cb.setLabel(corpora.get(i2).getDisplayTerm()); 72 90 73 91 allCorpora.getChildren().add(cb); 74 92 allCorpora.getChildren().add(new Separator()); 93 94 System.out.println("CHECKBOX: " + cb.getId()); 75 95 } // for i2 ... 76 96 } // if corpora.size else … … 88 108 @Listen("onClick = #searchButton") 89 109 public void onExecuteSearch(Event ev) { 110 // try { 111 // ExecuteSRUSearch.execute(); 112 // } catch (Exception ex){ 113 // System.out.println(ex.getMessage()); 114 // } 115 116 117 90 118 try { 119 120 if (languageSelect.getText().trim().equals("")) { 121 Messagebox.show("Please select a language."); 122 return; 123 } 124 125 anzeigeResults.setContent(""); 91 126 92 if (languageSelect.getText().trim().equals("")){93 Messagebox.show("Please select a language.");94 return;95 }96 97 String display = "SearchString: " + searchString.getText() + "\n";98 99 display = display + "Language: " + languageSelect.getSelectedItem().getLabel() + "\n";100 101 127 int i, i2; 102 103 // ----- IDS:104 105 display = display + "Corpora:\n";106 128 107 129 for (i = 0; i < allCorpora.getChildren().size(); i++) { … … 110 132 if (cb.isChecked()) { 111 133 // now execute the search: 112 String query = cb.getId() + "&maximumRecords=10&query=" + searchString.getText(); 113 display = display + query + "\n"; 134 // String query = cb.getId() + "&maximumRecords=10&query=" + searchString.getText(); 135 // display = display + query + "\n"; 136 System.out.println("---- THE SEARCH ----"); 137 138 String endpointURL = null; 139 String corpus = null; 140 141 if (cb.getId().contains("\t")) { 142 endpointURL = cb.getId().split("\t")[0]; 143 corpus = cb.getId().split("\t")[1]; 144 } else { 145 endpointURL = cb.getId(); 146 } 147 148 System.out.println("enddpointURL: " + endpointURL); 149 System.out.println("corpus: " + corpus); 150 SRUSearch srusearch = new SRUSearch(); 151 anzeigeResults.setContent(anzeigeResults.getContent() + srusearch.execute(searchString.getText(), endpointURL, corpus, 10, anzeigeResults, anzeigeGrid).toString()); 152 153 154 114 155 } 115 156 } 116 157 } // for i ... 158 System.out.println("Done"); 159 //Messagebox.show(display); 117 160 118 Messagebox.show(display);119 System.out.println(display);120 161 } catch (Exception ex) { 121 162 System.out.println(ex.getMessage()); -
SRUAggregator/trunk/src/java/clarind/fcs/SRUSearch.java
r2107 r2161 1 1 package clarind.fcs; 2 3 2 4 3 import eu.clarin.sru.client.*; … … 6 5 import eu.clarin.sru.fcs.ClarinFederatedContentSearchRecordData; 7 6 import eu.clarin.sru.fcs.ClarinFederatedContentSearchRecordParser; 7 import org.xml.sax.helpers.DefaultHandler; 8 8 9 import java.util.*; 10 public class TestSRUClient1 { 9 import org.zkoss.zul.Html; 10 import org.zkoss.zul.Grid; 11 import org.zkoss.zul.Rows; 12 import org.zkoss.zul.Row; 13 import org.zkoss.zul.Label; 14 15 16 public class SRUSearch { 17 private StringBuilder sb; 11 18 12 public static void main (String[] args) throws Exception { 13 14 String url = "http://weblicht.sfs.uni-tuebingen.de/rws/cqp-ws/cqp/sru"; 15 16 SRUClient client = new SRUClient(SRUVersion.VERSION_1_2); 17 18 client.registerRecordParser(new ClarinFederatedContentSearchRecordParser()); 19 20 SRUDefaultHandlerAdapter handler = new SRUDefaultHandlerAdapter(); 21 22 SRUExplainRequest request = new SRUExplainRequest(url); 23 client.explain(request, handler); 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>"); 24 23 25 24 26 25 SRUClient client = new SRUClient(); 26 client.registerRecordParser(new ClarinFederatedContentSearchRecordParser()); 27 28 SRUSearchRetrieveRequest request = new SRUSearchRetrieveRequest(endpointURL); 29 request.setQuery(query); 30 request.setRecordSchema(ClarinFederatedContentSearchRecordParser.FCS_RECORD_SCHEMA); 31 request.setMaximumRecords(maximumRecords); 32 33 if (corpus != null) { 34 request.setExtraRequestData("x-context", corpus); 35 System.out.println("I'm setting the x-context"); 36 37 } 38 39 client.searchRetrieve(request, new SRUDefaultHandlerAdapter() { 40 @Override 41 public void onRecord(String identifier, int position, SRURecordData data) throws SRUClientException { 42 if (ClarinFederatedContentSearchRecordParser.FCS_NS.equals(data.getRecordSchema())) { 43 ClarinFederatedContentSearchRecordData record = (ClarinFederatedContentSearchRecordData) data; 44 String left = record.getLeft(); 45 String hit = record.getKeyword(); 46 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 68 } 69 } 70 }); 71 sb.append("<hr>"); 72 return sb; 73 } 74 75 public static void main(String[] args) throws Exception { 76 77 78 79 27 80 } // main 28 29 81 } -
SRUAggregator/trunk/web/index.zul
r2107 r2161 2 2 <zk> 3 3 <window id="mainWindow" contentStyle="background:white;" height="100%" apply="clarind.fcs.Aggregator"> 4 <borderlayout sclass="complex-layout" width="1000px">4 <borderlayout sclass="complex-layout" > 5 5 <!-- Kopf --> 6 6 <north height="100px"> … … 9 9 10 10 <!-- Linke Sidebar --> 11 <west width="200px" flex="true" splittable="true" margins="0,5,0,0">11 <!-- <west width="0px" flex="true" splittable="true" margins="0,5,0,0"> 12 12 13 </west> 13 </west>--> 14 14 15 15 <!-- Center - Inhalt --> 16 < center autoscroll="true">16 <west autoscroll="true" splittable="true"> 17 17 <panel > 18 18 <panelchildren style="margin-top:10px;margin-left:10px;margin-right:10px;border:0;"> … … 34 34 35 35 <groupbox mold="3d" id="allCorpora"> 36 <caption>All Corpora</caption> 37 36 <caption>All Corpora</caption> 38 37 </groupbox> 39 40 41 42 38 </panelchildren> 43 39 </panel> 44 </ center>40 </west> 45 41 46 42 <!-- Rechte Sidebar --> 47 <east width="200px" flex="true" splittable="true" margins="0,5,0,0"> 48 49 </east> 43 <center flex="true" margins="0,5,0,0" autoscroll="true" > 44 <panel> 45 <panelchildren style="overflow: auto"> 46 <grid id="anzeigeGrid"> 47 <columns> 48 <column></column> 49 <column></column> 50 <column></column> 51 </columns> 52 </grid> 53 <html id="anzeigeResults" /> 54 </panelchildren> 55 56 </panel> 57 58 59 </center> 50 60 51 61 <!-- Fusszeile -->
Note: See TracChangeset
for help on using the changeset viewer.