Changeset 2175


Ignore:
Timestamp:
08/30/12 12:16:14 (12 years ago)
Author:
zastrow
Message:
 
Location:
SRUAggregator/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • SRUAggregator/trunk/src/java/clarind/fcs/Aggregator.java

    r2171 r2175  
    3333import org.zkoss.zul.Column;
    3434import org.zkoss.zul.Vbox;
     35import org.zkoss.zul.Iframe;
     36import org.zkoss.zul.Window;
    3537
    3638public class Aggregator extends SelectorComposer<Component> {
    37 
     39   
    3840    @Wire
    3941    private Grid anzeigeGrid;
     
    5658    @Wire
    5759    private Button deselectAll;
    58 
     60    @Wire
     61    private Window mainWindow;
     62   
     63   
    5964    @Override
    6065    public void doAfterCompose(Component comp) throws Exception {
     
    6368
    6469        languageSelect.setSelectedItem(german);
    65 
     70       
    6671        Harvester harv = new Harvester();
    6772        ArrayList<Endpoint> ep = harv.getEndpoints();
    68 
     73       
    6974        int i, i2;
    70 
     75       
    7176        for (i = 0; i < ep.size(); i++) {
    72 
     77           
    7378            System.out.println("Calling corpora ...: " + ep.get(i).getUrl());
    7479            ArrayList<Corpus> corpora = harv.getCorporaOfAnEndpoint(ep.get(i).getUrl());
    75 
     80           
    7681            if (corpora.size() == 0) {
    7782                Checkbox cb = new Checkbox();
     
    8085                //"?operation=searchRetrieve&version=1.2"
    8186                cb.setLabel(ep.get(i).getUrl());
    82 
     87               
    8388                allCorpora.getChildren().add(cb);
    8489                allCorpora.getChildren().add(new Separator());
    85 
     90               
    8691                System.out.println("CHECKBOX: " + cb.getId());
    8792            } else {
    8893                Label l = new Label(ep.get(i).getUrl() + ":");
    89 
     94               
    9095                l.setStyle("font-weight:bold");
    91 
     96               
    9297                allCorpora.getChildren().add(l);
    9398                allCorpora.getChildren().add(new Separator());
    9499                for (i2 = 0; i2 < corpora.size(); i2++) {
    95100                    Checkbox cb = new Checkbox();
    96 
     101                   
    97102                    cb.setId(ep.get(i).getUrl() + "\t" + corpora.get(i2).getValue());
    98103                    cb.setLabel(corpora.get(i2).getDisplayTerm());
    99 
     104                   
    100105                    allCorpora.getChildren().add(cb);
    101106                    allCorpora.getChildren().add(new Separator());
    102 
     107                   
    103108                    System.out.println("CHECKBOX: " + cb.getId());
    104109                } // for i2 ...
     
    106111
    107112            Separator sep = new Separator();
    108 
     113           
    109114            sep.setBar(true);
    110115            allCorpora.getChildren().add(sep);
    111 
     116           
    112117        } // for i ...
    113118
    114119    }
    115 
     120   
    116121    @Listen("onClick = #selectAll")
    117122    public void onSelectAll(Event ev) {
    118123        int i;
    119 
     124       
    120125        for (i = 0; i < allCorpora.getChildren().size(); i++) {
    121126            if (allCorpora.getChildren().get(i) instanceof Checkbox) {
     
    129134    public void onDeselectAll(Event ev) {
    130135        int i;
    131 
     136       
    132137        for (i = 0; i < allCorpora.getChildren().size(); i++) {
    133138            if (allCorpora.getChildren().get(i) instanceof Checkbox) {
     
    145150        }
    146151    }
    147 
     152   
    148153    @Listen("onClick=#clearResults")
    149154    public void onClearResults(Event ev) {
    150155        resultsVbox.getChildren().clear();
    151156    }
    152 
    153     @Listen("onClick=#exportResults")
    154     public void onExportResults(Event ev) {
    155 
     157   
     158    @Listen("onClick=#showHelp")
     159    public void onShowHelp(Event ev) {
     160        resultsVbox.getChildren().clear();
     161        Iframe help = new Iframe();
     162        help.setWidth("100%");
     163        help.setHeight("100%");
     164        help.setSrc("help.html");
     165        resultsVbox.appendChild(help);       
     166    }
     167   
     168    @Listen("onClick=#exportResultsCSV")
     169    public void onExportResultsCSV(Event ev) {
     170       
    156171        int i, i2, i3;
    157172        String temp = "";
    158 
     173        boolean somethingToExport = false;
     174       
    159175        for (i = 0; i < resultsVbox.getChildren().size(); i++) {
    160176            if (resultsVbox.getChildren().get(i) instanceof Grid) {
     177                somethingToExport = true;
    161178                Grid aGrid = (Grid) resultsVbox.getChildren().get(i);
    162179                Rows rows = aGrid.getRows();
    163 
     180               
    164181                for (i2 = 0; i2 < rows.getChildren().size(); i2++) {
    165182                    Row r = (Row) rows.getChildren().get(i2);
    166 
     183                   
    167184                    for (i3 = 0; i3 < r.getChildren().size(); i3++) {
    168185                        Label l = (Label) r.getChildren().get(i3);
     
    177194
    178195        } // for i ...
    179         Filedownload.save(temp, "text/plain", "table.csv");
    180     }
    181 
     196       
     197        if (somethingToExport) {
     198           
     199            Filedownload.save(temp, "text/plain", "ClarinDFederatedContentSearch.csv");
     200        } else {
     201            Messagebox.show("Nothing to export!");
     202        }
     203    }
     204   
     205   
     206     @Listen("onClick=#exportResultsTCF")
     207    public void onExportResultsTCF(Event ev) {
     208       
     209        int i, i2, i3;
     210        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  + "<source>CLARIN-D Federated Content Search</source>\n</MetaData>\n  <TextCorpus xmlns=\"http://www.dspin.de/data/textcorpus\">\n<text>";
     212       
     213       
     214        boolean somethingToExport = false;
     215       
     216        for (i = 0; i < resultsVbox.getChildren().size(); i++) {
     217            if (resultsVbox.getChildren().get(i) instanceof Grid) {
     218                somethingToExport = true;
     219                Grid aGrid = (Grid) resultsVbox.getChildren().get(i);
     220                Rows rows = aGrid.getRows();
     221               
     222                for (i2 = 0; i2 < rows.getChildren().size(); i2++) {
     223                    Row r = (Row) rows.getChildren().get(i2);
     224                   
     225                    for (i3 = 0; i3 < r.getChildren().size(); i3++) {
     226                        Label l = (Label) r.getChildren().get(i3);
     227                        temp = temp + l.getValue() + " ";
     228                    } //for i3
     229                    temp = temp + "\n";
     230                } // for i2
     231            } // if grid
     232
     233        } // for i ...
     234       
     235        if (somethingToExport) {
     236            temp = temp + "</text>\n</TextCorpus>\n</D-Spin>";
     237            Filedownload.save(temp, "text/tcf+xml", "ClarinDFederatedContentSearch.xml");
     238        } else {
     239            Messagebox.show("Nothing to export!");
     240        }
     241    }
     242     
     243   
     244   
    182245    @Listen("onClick = #searchButton")
    183246    public void onExecuteSearch(Event ev) {
    184 
     247       
    185248        try {
    186 
     249           
    187250            if (languageSelect.getText().trim().equals("")) {
    188251                Messagebox.show("Please select a language.");
    189252                return;
    190253            }
    191 
     254           
    192255            int i, i2;
    193 
    194 
     256           
     257           
    195258            resultsVbox.getChildren().clear();
    196 
    197 
    198 
    199 
     259           
     260           
     261            boolean isACorpusSelected = false;
     262           
    200263            for (i = 0; i < allCorpora.getChildren().size(); i++) {
    201264                if (allCorpora.getChildren().get(i) instanceof Checkbox) {
     
    203266                    if (cb.isChecked()) {
    204267                        // now execute the search:
    205 
     268                       
     269                        isACorpusSelected = true;
     270                       
    206271                        System.out.println("---- THE SEARCH ----");
    207 
     272                       
    208273                        String endpointURL = null;
    209274                        String corpus = null;
    210 
     275                       
    211276                        if (cb.getId().contains("\t")) {
    212277                            endpointURL = cb.getId().split("\t")[0];
     
    215280                            endpointURL = cb.getId();
    216281                        }
    217 
     282                       
    218283                        System.out.println("enddpointURL: " + endpointURL);
    219284                        System.out.println("corpus: " + corpus);
    220285                        SRUSearch srusearch = new SRUSearch();
    221286                        System.out.println("Calling the client ");
    222 
     287                       
    223288                        resultsVbox.appendChild(new Label("Query: " + searchString.getText()));
    224289                        resultsVbox.appendChild(new Label("Endpoint: " + endpointURL));
    225290                        resultsVbox.appendChild(new Label("Corpus: " + corpus));
    226 
    227 
     291                       
     292                       
    228293                        ArrayList<Row> zeilen = srusearch.execute(searchString.getText(), endpointURL, corpus, 10);
    229 
     294                       
    230295                        if (zeilen.size() > 0) {
    231 
     296                           
    232297                            Grid g = new Grid();
    233 
     298                           
    234299                            g.setMold("paging");
    235300                            g.setPageSize(10);
    236 
     301                           
    237302                            Columns columns = new Columns();
    238 
     303                           
    239304                            Column c = new Column();
    240305                            c.setLabel("Left");
    241 
     306                           
    242307                            columns.appendChild(c);
    243 
     308                           
    244309                            c = new Column();
    245310                            c.setLabel("Hit");
    246311                            c.setHflex("min");
    247312                            columns.appendChild(c);
    248 
     313                           
    249314                            c = new Column();
    250315                            c.setLabel("Right");
    251316                            columns.appendChild(c);
    252 
     317                           
    253318                            g.appendChild(columns);
    254 
     319                           
    255320                            Rows rows = new Rows();
    256 
     321                           
    257322                            for (i2 = 0; i2 < zeilen.size(); i2++) {
    258323                                System.out.println("Adding row " + i2);
     
    262327
    263328                            g.appendChild(rows);
    264 
     329                           
    265330                            resultsVbox.appendChild(g);
    266331                        } else {
    267332                            resultsVbox.appendChild(new Label("Sorry there were no results!"));
    268 
     333                           
    269334                        } // if zeilen > 0
    270335
     
    275340                }
    276341            } // for i ...
    277             System.out.println("Done");
    278 
     342           
     343            if (!isACorpusSelected) {
     344               
     345                Messagebox.show("Please select at least one corpus!", "CLARIN-D FCS Aggregator", 0, Messagebox.EXCLAMATION);
     346            }
     347           
     348           
     349            System.out.println("Search is done.");
     350           
    279351        } catch (Exception ex) {
    280352            System.out.println(ex.getMessage());
    281353        }
    282 
     354       
    283355    }
    284356}
  • SRUAggregator/trunk/web/index.zul

    r2171 r2175  
    11
    22<zk>
     3<!--title="CLARIN-D Federated Content Search"-->
    34    <window  id="mainWindow" contentStyle="background:white;" height="100%" apply="clarind.fcs.Aggregator">
    45        <borderlayout sclass="complex-layout"  >
     
    1920                        <textbox id="searchString" value="Elefant" />
    2021                        <button id="searchButton"  label="Search" image="buttonSearch.png"/>     
    21                         <!-- forward ="onExecuteSearch"-->
     22
    2223                        <separator />
    2324                       
     
    2728                             <label>Select by Language:</label>
    2829                        <combobox id="languageSelect" width="150px" value="German">                                                                                                                   
    29                             <!--<template name="model"> -->
    3030                            <comboitem label="German" id="german"/>
    3131                            <comboitem label="English" id="english"/>
    3232                            <comboitem label="Dutch" id="dutch" />
    3333                            <comboitem label="-More to come-" />
    34                             <!-- </template> -->
    3534                        </combobox>
    3635                       
    3736                         <separator />
    3837                       
    39                         <button id="selectAll" label="Select All" image="buttonSelectAll.png"/>                                           
    40                        
    41                         <button id="deselectAll" label="Deselect All" image="buttonDeselectAll.png"/>
    42                        
     38                        <button id="selectAll" label="Select All" image="buttonSelectAll.png"/>                                                                 
     39                        <button id="deselectAll" label="Deselect All" image="buttonDeselectAll.png"/>                     
     40                     
    4341                        <separator />
    44                                                    
    45                                                                            
    46                                                                                                                            
     42                                                                                       
    4743                        </groupbox>
    4844                    </panelchildren>
     
    5450                <panel>
    5551                    <panelchildren  id="resultsPanel" style="overflow: auto">
    56                         <toolbar id="resultsToolbar"  height="20px">
    57                             <toolbarbutton id="clearResults" label="Clear Results" image="buttonDelete.png"/>
     52                        <menubar id="menubar" width="100%">
     53                            <menu label="Actions" image="buttonActions.png">
     54                                <menupopup>
     55                                    <menuitem label="Clear Results" id="clearResults" image="buttonDelete.png" />
     56                                  <menuitem label="Export Results to CSV" id="exportResultsCSV" image="buttonExport.png" />
     57                                  <menuitem label="Export Results to TCF" id="exportResultsTCF" image="buttonExport.png" />                           
     58                             </menupopup>                               
     59                            </menu>                           
     60                            <menu label="Help" image="buttonHelp.png">
     61                                <menupopup>
     62                                     <menuitem label="Show Help" id="showHelp" image="buttonHelp.png" />
     63                                </menupopup>   
     64                            </menu>
     65                                                                                 
     66                        </menubar>
     67<!--                         <toolbar id="resultsToolbar"  height="20px">
     68                           <toolbarbutton id="clearResults" label="Clear Results" image="buttonDelete.png"/>
    5869                            <toolbarbutton id="exportResults" label="Export Results" image="buttonExport.png"/>
     70                            <toolbarbutton id="showHelp" label="Show Help" image="buttonHelp.png"/>
    5971                               
    6072                        </toolbar>
     73                        -->
    6174                        <vbox id="resultsVbox">
    62                         <grid id="anzeigeGrid">
    63                             <columns>
    64                                 <column></column>
    65                                 <column></column> 
    66                                 <column></column>                                       
    67                             </columns>
    68                             <rows></rows>
    69                         </grid>
    70                         <html id="anzeigeResults" />
     75                            <iframe src="help.html" width="100%" height="100%"/>
     76                            <grid id="anzeigeGrid">
     77                                <columns>
     78                                    <column></column>
     79                                    <column></column> 
     80                                    <column></column>                                       
     81                                </columns>
     82                                <rows></rows>
     83                            </grid>
     84                            <html id="anzeigeResults" />
    7185                        </vbox>
    7286                    </panelchildren>
    7387                   
    7488                </panel>
    75 
    76                
    7789            </center>
    7890           
Note: See TracChangeset for help on using the changeset viewer.