Changeset 2107
- Timestamp:
- 08/16/12 14:53:42 (12 years ago)
- Location:
- SRUAggregator/trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUAggregator/trunk/nbproject/private/private.xml
r2097 r2107 3 3 <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/> 4 4 <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> 5 <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">6 <file>file:/Users/zastrow/Documents/ClarinD/schrauber/Aggregator/trunk/src/java/clarind/fcs/Harvester.java</file>7 <file>file:/Users/zastrow/Documents/ClarinD/schrauber/Aggregator/trunk/src/java/clarind/fcs/Aggregator.java</file>8 <file>file:/Users/zastrow/Documents/ClarinD/schrauber/Aggregator/trunk/web/index.zul</file>9 </open-files>10 5 </project-private> -
SRUAggregator/trunk/src/java/clarind/fcs/Aggregator.java
r2097 r2107 17 17 import org.zkoss.zul.Separator; 18 18 import org.zkoss.zul.Label; 19 import org.zkoss.zul.Comboitem; 19 20 20 21 public class Aggregator extends SelectorComposer<Component> { … … 30 31 @Wire 31 32 private Groupbox allCorpora; 33 @Wire 34 private Comboitem german; 32 35 33 36 @Override … … 35 38 super.doAfterCompose(comp); //wire variables and event listners 36 39 //do whatever you want (you could access wired variables here) 40 41 languageSelect.setSelectedItem(german); 42 37 43 Harvester harv = new Harvester(); 38 44 ArrayList<Endpoint> ep = harv.getEndpoints(); … … 43 49 44 50 System.out.println("Calling corpora ...: " + ep.get(i).getUrl()); 45 ArrayList< String> corpora = harv.getCorporaOfAnEndpoint(ep.get(i).getUrl());51 ArrayList<Corpus> corpora = harv.getCorporaOfAnEndpoint(ep.get(i).getUrl()); 46 52 47 53 if (corpora.size() == 0) { 48 54 Checkbox cb = new Checkbox(); 55 cb.setId(ep.get(i).getUrl() + "?operation=searchRetrieve&version=1.2"); 49 56 cb.setLabel(ep.get(i).getUrl()); 57 50 58 allCorpora.getChildren().add(cb); 51 59 allCorpora.getChildren().add(new Separator()); … … 57 65 for (i2 = 0; i2 < corpora.size(); i2++) { 58 66 Checkbox cb = new Checkbox(); 59 cb.setLabel(corpora.get(i2)); 67 68 //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 70 cb.setId(ep.get(i).getUrl() + "?operation=searchRetrieve&version=1.2&x-context=" + corpora.get(i2).getValue()); 71 cb.setLabel(corpora.get(i2).getDisplayTerm()); 60 72 61 73 allCorpora.getChildren().add(cb); … … 77 89 public void onExecuteSearch(Event ev) { 78 90 try { 91 92 if (languageSelect.getText().trim().equals("")){ 93 Messagebox.show("Please select a language."); 94 return; 95 } 96 79 97 String display = "SearchString: " + searchString.getText() + "\n"; 80 98 … … 92 110 if (cb.isChecked()) { 93 111 // now execute the search: 94 display = display + cb.getLabel() + "\n"; 112 String query = cb.getId() + "&maximumRecords=10&query=" + searchString.getText(); 113 display = display + query + "\n"; 95 114 } 96 115 } … … 98 117 99 118 Messagebox.show(display); 100 119 System.out.println(display); 101 120 } catch (Exception ex) { 102 121 System.out.println(ex.getMessage()); -
SRUAggregator/trunk/src/java/clarind/fcs/Harvester.java
r2097 r2107 17 17 final String crStartpoint = "http://130.183.206.32/restxml/"; 18 18 19 private NodeList evaluateXPath(String statement, org.w3c.dom.Document domtree){19 private NodeList evaluateXPath(String statement, org.w3c.dom.Document domtree) { 20 20 NodeList result = null; 21 21 … … 28 28 return result; 29 29 } 30 31 30 31 public String evaluateXPathToString(String statement, org.w3c.dom.Document domtree) { 32 32 String result = null; 33 33 … … 40 40 return result; 41 41 } 42 43 44 public ArrayList<Endpoint> getEndpoints() throws Exception { 42 43 public ArrayList<Endpoint> getEndpoints() throws Exception { 45 44 ArrayList<Endpoint> ep = new ArrayList<Endpoint>(); 46 45 47 46 URL u = new URL(crStartpoint); 48 47 InputStream is = u.openStream(); 49 48 50 49 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 51 50 DocumentBuilder builder = factory.newDocumentBuilder(); … … 54 53 is.close(); 55 54 String instituteName = evaluateXPathToString("//Name", document); 56 55 57 56 NodeList institutionsUrls = evaluateXPath("//Center_id_link", document); 58 57 59 58 int i, i2; 60 61 for (i=0; i<institutionsUrls.getLength();i++){62 63 64 65 66 67 68 69 70 71 for(i2=0; i2<endpointsUrls.getLength();i2++){72 String epUrl = endpointsUrls.item(i2).getTextContent();73 74 75 59 60 for (i = 0; i < institutionsUrls.getLength(); i++) { 61 u = new URL(institutionsUrls.item(i).getTextContent()); 62 is = u.openStream(); 63 64 org.w3c.dom.Document doc = builder.parse(is); 65 is.close(); 66 ////WebReference[./Description[text()="CQL"]]/Website 67 68 NodeList endpointsUrls = evaluateXPath("//WebReference[./Description[text()=\"CQL\"]]/Website", doc); 69 70 for (i2 = 0; i2 < endpointsUrls.getLength(); i2++) { 71 String epUrl = endpointsUrls.item(i2).getTextContent(); 72 ep.add(new Endpoint(epUrl, instituteName)); 73 } // for i2 74 76 75 } // for i ... 77 76 78 77 79 78 return ep; 80 79 } //getEndpoints 81 82 83 public ArrayList<String> getCorporaOfAnEndpoint(String endpointUrl) throws Exception { 84 System.out.println("getCorporaOfAnEndpoint: " + endpointUrl); 85 ArrayList<String> corpora = new ArrayList<String>(); 86 87 URL u = new URL(endpointUrl + "?operation=scan&scanClause=fcs.resource"); 80 81 public ArrayList<Corpus> getCorporaOfAnEndpoint(String endpointUrl) throws Exception { 82 83 ArrayList<Corpus> corpora = new ArrayList<Corpus>(); 84 String urlToCall = endpointUrl + "?operation=scan&scanClause=fcs.resource&version=1.2"; 85 URL u = new URL(urlToCall); 86 87 System.out.println("getCorporaOfAnEndpoint: " + urlToCall); 88 88 89 InputStream is = u.openStream(); 89 90 90 91 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 91 92 DocumentBuilder builder = factory.newDocumentBuilder(); … … 93 94 94 95 is.close(); 96 97 //http://clarinws.informatik.uni-leipzig.de:8080/CQL? 98 99 //NodeList corporaNodes = evaluateXPath("//*[local-name()='term']/*[local-name()='value']", document); 100 NodeList corporaNodes = evaluateXPath("//*[local-name()='terms']/*[local-name()='term']", document); 101 102 int i, i2; 103 if (corporaNodes.getLength() > 0) { 104 105 System.out.println("Length of corpora: " + corporaNodes.getLength()); 106 107 for (i = 0; i < corporaNodes.getLength(); i++) { 108 Node n = corporaNodes.item(i); 109 110 System.out.println("NODENAEM: " + n.getNodeName()); 111 112 Corpus c = new Corpus(); 113 114 for (i2 = 0; i2 < n.getChildNodes().getLength(); i2++) { 115 Node child = n.getChildNodes().item(i2); 116 117 if (child.getNodeName().endsWith("value")) { 118 c.setValue(child.getTextContent()); 119 } 120 121 if (child.getNodeName().endsWith("displayTerm")) { 122 c.setDisplayTerm(child.getTextContent()); 123 } 124 125 if (child.getNodeName().endsWith("numberOfRecords")) { 126 c.setNumberOfRecords(child.getTextContent()); 127 } 128 129 } //for i2 130 131 corpora.add(c); 132 133 } // for i ... 134 } // if coporaNodes ... 95 135 96 //http://clarinws.informatik.uni-leipzig.de:8080/CQL? 97 98 NodeList corporaNodes = evaluateXPath("//*[local-name()='term']/*[local-name()='value']", document); 99 100 int i, i2; 101 102 for(i=0; i<corporaNodes.getLength();i++){ 103 corpora.add(corporaNodes.item(i).getTextContent()); 104 105 } // for i ... 136 System.out.println("------------"); 106 137 return corpora; 107 138 } // getCorporaOfAnEndpoint 108 109 110 public static void main (String[] args) throws Exception { 139 140 public static void main(String[] args) throws Exception { 111 141 Harvester cr = new Harvester(); 112 142 ArrayList<Endpoint> ep = cr.getEndpoints(); 113 143 114 144 int i; 115 116 for (i=0; i<ep.size();i++){145 146 for (i = 0; i < ep.size(); i++) { 117 147 System.out.println(ep.get(i).getInstitution() + " " + ep.get(i).getUrl()); 118 148 } // for i ... 119 120 149 150 121 151 } 122 123 124 125 126 152 } -
SRUAggregator/trunk/web/index.zul
r2097 r2107 22 22 <separator /> 23 23 <label>Language:</label> 24 <combobox id="languageSelect" width="150px" >24 <combobox id="languageSelect" width="150px" value="German"> 25 25 <!--<template name="model"> --> 26 <comboitem label="German" />27 <comboitem label="English" />28 <comboitem label="Dutch" />26 <comboitem label="German" id="german"/> 27 <comboitem label="English" id="english"/> 28 <comboitem label="Dutch" id="dutch" /> 29 29 <comboitem label="-More to come-" /> 30 30 <!-- </template> --> … … 34 34 35 35 <groupbox mold="3d" id="allCorpora"> 36 <caption>All Corpora</caption>36 <caption>All Corpora</caption> 37 37 38 38 </groupbox>
Note: See TracChangeset
for help on using the changeset viewer.