Changeset 2161


Ignore:
Timestamp:
08/28/12 14:52:41 (12 years ago)
Author:
zastrow
Message:
 
Location:
SRUAggregator/trunk
Files:
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • SRUAggregator/trunk/nbproject/build-impl.xml

    r2097 r2161  
    976976    <target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
    977977        <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"/>
    978979        <copyfiles files="${libs.SRUCQLClient.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
    979980        <mkdir dir="${build.web.dir}/META-INF"/>
     
    982983    <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
    983984        <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"/>
    984986        <copyfiles files="${libs.SRUCQLClient.classpath}" todir="${build.web.dir}/WEB-INF/lib"/>
    985987    </target>
  • SRUAggregator/trunk/nbproject/genfiles.properties

    r2097 r2161  
    1 build.xml.data.CRC32=1ca8f689
     1build.xml.data.CRC32=bb4ec976
    22build.xml.script.CRC32=e9ec94ca
    33build.xml.stylesheet.CRC32=651128d4@1.38.1.1
    44# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
    55# 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=1ca8f689
    7 nbproject/build-impl.xml.script.CRC32=1ad9793f
     6nbproject/build-impl.xml.data.CRC32=bb4ec976
     7nbproject/build-impl.xml.script.CRC32=34eb7b98
    88nbproject/build-impl.xml.stylesheet.CRC32=4e9cae83@1.38.1.1
  • SRUAggregator/trunk/nbproject/project.properties

    r2097 r2161  
    3737javac.classpath=\
    3838    ${libs.zk.classpath}:\
     39    ${libs.SRUClientLibs.classpath}:\
    3940    ${libs.SRUCQLClient.classpath}
    4041# Space-separated list of extra javac options
  • SRUAggregator/trunk/nbproject/project.xml

    r2097 r2161  
    99                <library dirs="200">
    1010                    <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>
    1115                    <path-in-war>WEB-INF/lib</path-in-war>
    1216                </library>
  • SRUAggregator/trunk/src/java/clarind/fcs/Aggregator.java

    r2107 r2161  
    11package clarind.fcs;
    22
     3import eu.clarin.sru.client.SRUClient;
     4import eu.clarin.sru.client.SRUClientException;
     5import eu.clarin.sru.client.SRUDefaultHandlerAdapter;
     6import eu.clarin.sru.client.SRURecordData;
     7import eu.clarin.sru.client.SRUSearchRetrieveRequest;
     8import eu.clarin.sru.client.SRUVersion;
     9import eu.clarin.sru.fcs.ClarinFederatedContentSearchRecordData;
     10import eu.clarin.sru.fcs.ClarinFederatedContentSearchRecordParser;
    311import java.util.ArrayList;
    412import org.zkoss.zk.ui.Component;
     
    1725import org.zkoss.zul.Separator;
    1826import org.zkoss.zul.Label;
     27import org.zkoss.zul.Html;
    1928import org.zkoss.zul.Comboitem;
     29import org.zkoss.zul.Grid;
    2030
    2131public class Aggregator extends SelectorComposer<Component> {
    2232
     33    @Wire
     34    private Grid anzeigeGrid;
    2335    @Wire
    2436    private Textbox searchString;
     
    3143    @Wire
    3244    private Groupbox allCorpora;
    33      @Wire
     45    @Wire
    3446    private Comboitem german;
     47    @Wire
     48    private Html anzeigeResults;
    3549
    3650    @Override
     
    3852        super.doAfterCompose(comp); //wire variables and event listners
    3953        //do whatever you want (you could access wired variables here)
    40        
     54
    4155        languageSelect.setSelectedItem(german);
    42        
     56
    4357        Harvester harv = new Harvester();
    4458        ArrayList<Endpoint> ep = harv.getEndpoints();
     
    5367            if (corpora.size() == 0) {
    5468                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"
    5672                cb.setLabel(ep.get(i).getUrl());
    57                
     73
    5874                allCorpora.getChildren().add(cb);
    5975                allCorpora.getChildren().add(new Separator());
     76
     77                System.out.println("CHECKBOX: " + cb.getId());
    6078            } else {
    6179                Label l = new Label(ep.get(i).getUrl() + ":");
     
    6583                for (i2 = 0; i2 < corpora.size(); i2++) {
    6684                    Checkbox cb = new Checkbox();
    67                    
     85
    6886                    //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
    6987
    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());
    7189                    cb.setLabel(corpora.get(i2).getDisplayTerm());
    72                    
     90
    7391                    allCorpora.getChildren().add(cb);
    7492                    allCorpora.getChildren().add(new Separator());
     93
     94                    System.out.println("CHECKBOX: " + cb.getId());
    7595                } // for i2 ...
    7696            } // if corpora.size else
     
    88108    @Listen("onClick = #searchButton")
    89109    public void onExecuteSearch(Event ev) {
     110//        try {
     111//            ExecuteSRUSearch.execute();
     112//        } catch (Exception ex){
     113//            System.out.println(ex.getMessage());
     114//        }
     115
     116
     117
    90118        try {
     119
     120            if (languageSelect.getText().trim().equals("")) {
     121                Messagebox.show("Please select a language.");
     122                return;
     123            }
     124
     125            anzeigeResults.setContent("");
    91126           
    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 
    101127            int i, i2;
    102 
    103             // ----- IDS:
    104 
    105             display = display + "Corpora:\n";
    106128
    107129            for (i = 0; i < allCorpora.getChildren().size(); i++) {
     
    110132                    if (cb.isChecked()) {
    111133                        // 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
    114155                    }
    115156                }
    116157            } // for i ...
     158            System.out.println("Done");
     159            //Messagebox.show(display);
    117160
    118             Messagebox.show(display);
    119             System.out.println(display);
    120161        } catch (Exception ex) {
    121162            System.out.println(ex.getMessage());
  • SRUAggregator/trunk/src/java/clarind/fcs/SRUSearch.java

    r2107 r2161  
    11package clarind.fcs;
    2 
    32
    43import eu.clarin.sru.client.*;
     
    65import eu.clarin.sru.fcs.ClarinFederatedContentSearchRecordData;
    76import eu.clarin.sru.fcs.ClarinFederatedContentSearchRecordParser;
     7import org.xml.sax.helpers.DefaultHandler;
    88
    9 import java.util.*;
    10 public class TestSRUClient1 {
     9import org.zkoss.zul.Html;
     10import org.zkoss.zul.Grid;
     11import org.zkoss.zul.Rows;
     12import org.zkoss.zul.Row;
     13import org.zkoss.zul.Label;
     14
     15
     16public class SRUSearch {
     17    private StringBuilder sb;
    1118   
    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>");
    2423       
    2524       
    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
    2780    } // main
    28    
    2981}
  • SRUAggregator/trunk/web/index.zul

    r2107 r2161  
    22<zk>
    33    <window  id="mainWindow" contentStyle="background:white;" height="100%" apply="clarind.fcs.Aggregator">
    4         <borderlayout sclass="complex-layout"  width="1000px">
     4        <borderlayout sclass="complex-layout"  >
    55            <!-- Kopf -->
    66            <north height="100px">
     
    99           
    1010            <!-- 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">
    1212 
    13             </west>
     13            </west>-->
    1414     
    1515            <!-- Center - Inhalt -->
    16             <center autoscroll="true">
     16            <west autoscroll="true" splittable="true">
    1717                <panel >
    1818                    <panelchildren style="margin-top:10px;margin-left:10px;margin-right:10px;border:0;">                   
     
    3434                       
    3535                        <groupbox mold="3d" id="allCorpora">
    36                             <caption>All Corpora</caption>
    37                            
     36                            <caption>All Corpora</caption>                           
    3837                        </groupbox>
    39                        
    40                        
    41                        
    4238                    </panelchildren>
    4339                </panel>
    44             </center>
     40            </west>
    4541           
    4642            <!-- 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>
    5060           
    5161            <!-- Fusszeile -->   
Note: See TracChangeset for help on using the changeset viewer.