Changeset 4530


Ignore:
Timestamp:
02/18/14 07:15:00 (10 years ago)
Author:
twagoo
Message:

started implementation of search results. Created panel and added required service interfaces/implementations

Location:
vlo/branches/vlo-3.0/vlo-web-app/src
Files:
4 added
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/config/VloSpringConfig.java

    r4517 r4530  
    2020import eu.clarin.cmdi.vlo.service.FacetFieldsService;
    2121import eu.clarin.cmdi.vlo.service.SearchResultsDao;
     22import eu.clarin.cmdi.vlo.service.SolrDocumentService;
    2223import eu.clarin.cmdi.vlo.service.SolrQueryFactory;
    2324import eu.clarin.cmdi.vlo.service.impl.SearchResultsDaoImpl;
     25import eu.clarin.cmdi.vlo.service.impl.SolrDocumentServiceImpl;
    2426import eu.clarin.cmdi.vlo.service.impl.SolrFacetFieldsService;
    2527import eu.clarin.cmdi.vlo.service.impl.SolrQueryFactoryImpl;
     
    7072        return new SolrFacetFieldsService(searchResultsDao(), queryFactory());
    7173    }
     74   
     75    @Bean
     76    public SolrDocumentService documentService() {
     77        return new SolrDocumentServiceImpl(searchResultsDao(), queryFactory());
     78    }
    7279
    7380    @Bean
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/SearchResultsDao.java

    r4501 r4530  
    2929public interface SearchResultsDao {
    3030
    31     SolrDocumentList getDocIdList(SolrQuery query);
     31    SolrDocumentList getDocuments(SolrQuery query);
    3232
    3333    List<FacetField> getFacets(SolrQuery query);
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/SolrQueryFactory.java

    r4520 r4530  
    3131
    3232    SolrQuery createCountFacetsQuery();
     33   
     34    SolrQuery createDocumentQuery(QueryFacetsSelection selection, int first, int count);
    3335
    3436}
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/impl/SearchResultsDaoImpl.java

    r4527 r4530  
    3838
    3939    @Override
    40     public SolrDocumentList getDocIdList(SolrQuery query) {
    41         query = query.getCopy();
    42         setDefaultSortField(query);
    43         query.setFields(FacetConstants.FIELD_ID);
    44         query.setFacet(false);
    45         query.setStart(0);
    46         query.setRows(Integer.MAX_VALUE);
     40    public SolrDocumentList getDocuments(SolrQuery query) {
    4741        QueryResponse queryResponse = fireQuery(query);
    48         return queryResponse.getResults();
     42        final SolrDocumentList documents = queryResponse.getResults();
     43        logger.debug("Found {} documents", documents.getNumFound());
     44        return documents;
    4945    }
    5046
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/impl/SolrQueryFactoryImpl.java

    r4520 r4530  
    5151    public SolrQuery createFacetQuery(QueryFacetsSelection queryFacetsSelections) {
    5252        final SolrQuery query = getDefaultFacetQuery();
     53        addQueryFacetParameters(query, queryFacetsSelections);
     54        return query;
     55    }
     56
     57    @Override
     58    public SolrQuery createDocumentQuery(QueryFacetsSelection selection, int first, int count) {
     59        final SolrQuery query = getDefaultDocumentQuery();
     60        addQueryFacetParameters(query, selection);
     61        query.setStart(first);
     62        query.setRows(count);
     63        return query;
     64    }
     65
     66    protected void addQueryFacetParameters(final SolrQuery query, QueryFacetsSelection queryFacetsSelections) {
    5367        final String queryString = queryFacetsSelections.getQuery();
    5468
     
    7286        }
    7387        query.setFilterQueries(encodedQueries.toArray(new String[encodedQueries.size()]));
    74         return query;
    7588    }
    7689
     
    8699    }
    87100
     101    private SolrQuery getDefaultDocumentQuery() {
     102        SolrQuery result = new SolrQuery();
     103        result.setFields(FacetConstants.FIELD_NAME, FacetConstants.FIELD_ID, FacetConstants.FIELD_DESCRIPTION, FacetConstants.FIELD_COLLECTION, FacetConstants.FIELD_RESOURCE);
     104        return result;
     105    }
     106
    88107    @Override
    89108    public synchronized SolrQuery createCountFacetsQuery() {
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components/SearchResultsPanel.html

    r4515 r4530  
    2424    <body>
    2525        <wicket:panel>
    26             <div class="sidebaritem">
    27                 <!-- rounded corners - top **** -->
    28                 <div class="rtop"><div class="r1"></div><div class="r2"></div><div class="r3"></div><div class="r4"></div></div>
    29                 <h1>Narrow down</h1>
    30                 <p>
    31                     Use the categories below to limit the search results to those matching the selected value(s).
    32                 </p>
    33                 <wicket:container wicket:id="facets">
    34                     <div wicket:id="facet">[facet]</div>
    35                 </wicket:container>
    36                 <!-- rounded corners - bottom **** -->
    37                 <div class="rbottom"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div>
     26            <h1>Search results</h1>
     27            <div id="searchresultsheader">
     28                <span wicket:id="resultCount" id="searchresultcount">604056 results</span>
     29                <span id="searchresultpagecount">Showing 1 to 25</span>
     30
     31                <div class="searchresultpagination">
     32                    &lt;&lt;
     33                    &lt;
     34                    1
     35                    <a href="">2</a>
     36                    <a href="">3</a>
     37                    <a href="">4</a>
     38                    <a href="">5</a>
     39                    <a href="">6</a>
     40                    <a href="">7</a>
     41                    <a href="">8</a>
     42                    <a href="">9</a>
     43                    <a href="">10</a>
     44                    <a href="">&gt;</a>
     45                    <a href="">&gt;&gt;</a>
     46                </div>
     47
     48            </div>
     49
     50            <ul id="searchresultitems">
     51                <li wicket:id="resultItem" class="searchresultitem">
     52                    <h2>
     53                        <a wicket:id="title" href="record1.html">[TITLE]</a>
     54                    </h2>
     55                    <div class="searchresultitembrief">
     56                        <p class="searchresultmoreless">
     57                            <a href="#" class="searchresultdetailstoggle">expand</a>
     58                        </p>
     59                        <p class="searchresultdescription" wicket:id="description">
     60                            [DESCRIPTION]
     61                        </p>
     62                        <p class="searchresultresources">
     63                            Resources: <a href="record1.html">1 text file</a>, <a href="record1.html">1 audio file</a>, <a href="record1.html">1 annotation file</a>
     64                        </p>
     65                    </div>
     66
     67                    <div class="searchresultitemextended">
     68                        <p class="searchresultmoreless">
     69                            <a href="#" class="searchresultdetailstoggle">collapse</a>
     70                        </p>
     71                        <p class="searchresultdescription">
     72                            In China (and specifically in Beijing) of the late seventies, the call for a democracy movement was growing ever stronger, before finally being silenced by the new regime under Deng Xiaoping. This paper exmaines both the historical sources and the eventual outcome of this movement during the anxious years of '78-'79.
     73                        </p>
     74                        <div class="searchresultattributes">
     75                            <table class="recorddetailstable">
     76                                <tbody class="attributesTbody">
     77                                    <tr>
     78                                        <td class="attribute">
     79                                            <div>Collection</div>
     80                                        </td><td class="attributeValue">
     81                                            <div>UBU Clarin Set<a class="recordfacetselect" title="Search for similar" href="index2.html"><span>[search for similar]</span></a></div>
     82                                        </td>
     83                                    </tr>
     84                                    <tr>
     85                                        <td class="attribute">
     86                                            <div>Genre</div>
     87                                        </td><td class="attributeValue">
     88                                            <div>info:eu-repo/semantics/bachelorthesis <a class="recordfacetselect" title="Search for similar" href="index2.html"><span>[search for similar]</span></a></div>
     89                                        </td>
     90                                    </tr><tr>
     91                                        <td class="attribute">
     92                                            <div>Languages</div>
     93                                        </td><td class="attributeValue">
     94                                            <div>Dutch <a class="recordattributeinfo" href="http://infra.clarin.eu/service/language/info.php?code=nld"><span>[info]</span></a> <a class="recordfacetselect" title="Search for similar" href="index2.html"><span>[search for similar]</span></a></div>
     95                                        </td>
     96                                    </tr><tr>
     97                                        <td class="attribute">
     98                                            <div>National project</div>
     99                                        </td><td class="attributeValue">
     100                                            <div>CLARIN-NL <a class="recordfacetselect" title="Search for similar" href="index2.html"><span>[search for similar]</span></a></div>
     101                                        </td>
     102                                    </tr><tr>
     103                                        <td class="attribute">
     104                                            <div>Resource type</div>
     105                                        </td><td class="attributeValue">
     106                                            <div>text <a class="recordfacetselect" title="Search for similar" href="index2.html"><span>[search for similar]</span></a></div>
     107                                        </td>
     108                                    </tr>
     109                                </tbody>
     110                            </table>
     111
     112                            <h3>Resources</h3>
     113                            <ul>
     114                                <li class="writtenresource"><a href="">http://dspace.library.uu.nl/bitstream/1874/235456/1/Bachelorscriptie+Rene+Witteveen+3375005.docx</a></li>
     115                                <li class="audioresource"><a href="">http://corpus1.mpi.nl/qfs1/media-archive/dobes_data/Ache/Documentaci_n_-_Documentation/Comunidades_-_Communities/Cerro_Moroti/Media/002-djawu_klluu-2011-09-01.wav</a></li>
     116                                <li class="annotationresource"><a href="">http://corpus1.mpi.nl/qfs1/media-archive/dobes_data/Ache/Documentaci_n_-_Documentation/Comunidades_-_Communities/Cerro_Moroti/Annotations/002-djawu_klluu-2011-09-01.eaf</a></li>
     117                            </ul>
     118                        </div>
     119
     120                        <p class="searchresultfullrecord">
     121                            <a href="record1.html">View full record</a>
     122                        </p>
     123                    </div>
     124                    <div class="searchresultitemend"></div>
     125                </li>
     126            </ul>
     127            <div id="searchresultpagination">
     128                &lt;&lt;
     129                &lt;
     130                1
     131                <a href="">2</a>
     132                <a href="">3</a>
     133                <a href="">4</a>
     134                <a href="">5</a>
     135                <a href="">6</a>
     136                <a href="">7</a>
     137                <a href="">8</a>
     138                <a href="">9</a>
     139                <a href="">10</a>
     140                <a href="">&gt;</a>
     141                <a href="">&gt;&gt;</a>
     142
     143                <form id="resultpagesizeform">
     144                    <label for="resultpagesize">Results per page:</label>
     145                    <select id="resultpagesize">
     146                        <option>5</option>
     147                        <option>10</option>
     148                        <option selected="selected">25</option>
     149                        <option>50</option>
     150                        <option>100</option>
     151                    </select>
     152                </form>
    38153            </div>
    39154        </wicket:panel>
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/FacetedSearchPage.html

    r4528 r4530  
    103103                    </p>
    104104                </form>
    105                 <div id="searchresults">
    106                     <h1>Search results</h1>
    107                     <div id="searchresultsheader">
    108                         <span id="searchresultcount">604056 results</span>
    109                         <span id="searchresultpagecount">Showing 1 to 25</span>
    110 
    111                         <div class="searchresultpagination">
    112                             &lt;&lt;
    113                             &lt;
    114                             1
    115                             <a href="">2</a>
    116                             <a href="">3</a>
    117                             <a href="">4</a>
    118                             <a href="">5</a>
    119                             <a href="">6</a>
    120                             <a href="">7</a>
    121                             <a href="">8</a>
    122                             <a href="">9</a>
    123                             <a href="">10</a>
    124                             <a href="">&gt;</a>
    125                             <a href="">&gt;&gt;</a>
    126                         </div>
    127 
    128                     </div>
    129 
    130                     <ul id="searchresultitems">
    131                         <li class="searchresultitem">
    132                             <h2>
    133                                 <a href="record1.html">"Chinese Democratie en de Transformatie"</a>
    134                             </h2>
    135                             <div class="searchresultitembrief">
    136                                 <p class="searchresultmoreless">
    137                                     <a href="#" class="searchresultdetailstoggle">expand</a>
    138                                 </p>
    139                                 <p class="searchresultdescription">
    140                                     In China (and specifically in Beijing) of the late seventies, the call for a democracy movement was growing ever stronger, before finally being silenced by the new regime under Deng Xiaoping...
    141                                 </p>
    142                                 <p class="searchresultresources">
    143                                     Resources: <a href="record1.html">1 text file</a>, <a href="record1.html">1 audio file</a>, <a href="record1.html">1 annotation file</a>
    144                                 </p>
    145                             </div>
    146 
    147                             <div class="searchresultitemextended">
    148                                 <p class="searchresultmoreless">
    149                                     <a href="#" class="searchresultdetailstoggle">collapse</a>
    150                                 </p>
    151                                 <p class="searchresultdescription">
    152                                     In China (and specifically in Beijing) of the late seventies, the call for a democracy movement was growing ever stronger, before finally being silenced by the new regime under Deng Xiaoping. This paper exmaines both the historical sources and the eventual outcome of this movement during the anxious years of '78-'79.
    153                                 </p>
    154                                 <div class="searchresultattributes">
    155                                     <table class="recorddetailstable">
    156                                         <tbody class="attributesTbody">
    157                                             <tr>
    158                                                 <td class="attribute">
    159                                                     <div>Collection</div>
    160                                                 </td><td class="attributeValue">
    161                                                     <div>UBU Clarin Set<a class="recordfacetselect" title="Search for similar" href="index2.html"><span>[search for similar]</span></a></div>
    162                                                 </td>
    163                                             </tr>
    164                                             <tr>
    165                                                 <td class="attribute">
    166                                                     <div>Genre</div>
    167                                                 </td><td class="attributeValue">
    168                                                     <div>info:eu-repo/semantics/bachelorthesis <a class="recordfacetselect" title="Search for similar" href="index2.html"><span>[search for similar]</span></a></div>
    169                                                 </td>
    170                                             </tr><tr>
    171                                                 <td class="attribute">
    172                                                     <div>Languages</div>
    173                                                 </td><td class="attributeValue">
    174                                                     <div>Dutch <a class="recordattributeinfo" href="http://infra.clarin.eu/service/language/info.php?code=nld"><span>[info]</span></a> <a class="recordfacetselect" title="Search for similar" href="index2.html"><span>[search for similar]</span></a></div>
    175                                                 </td>
    176                                             </tr><tr>
    177                                                 <td class="attribute">
    178                                                     <div>National project</div>
    179                                                 </td><td class="attributeValue">
    180                                                     <div>CLARIN-NL <a class="recordfacetselect" title="Search for similar" href="index2.html"><span>[search for similar]</span></a></div>
    181                                                 </td>
    182                                             </tr><tr>
    183                                                 <td class="attribute">
    184                                                     <div>Resource type</div>
    185                                                 </td><td class="attributeValue">
    186                                                     <div>text <a class="recordfacetselect" title="Search for similar" href="index2.html"><span>[search for similar]</span></a></div>
    187                                                 </td>
    188                                             </tr>
    189                                         </tbody>
    190                                     </table>
    191 
    192                                     <h3>Resources</h3>
    193                                     <ul>
    194                                         <li class="writtenresource"><a href="">http://dspace.library.uu.nl/bitstream/1874/235456/1/Bachelorscriptie+Rene+Witteveen+3375005.docx</a></li>
    195                                         <li class="audioresource"><a href="">http://corpus1.mpi.nl/qfs1/media-archive/dobes_data/Ache/Documentaci_n_-_Documentation/Comunidades_-_Communities/Cerro_Moroti/Media/002-djawu_klluu-2011-09-01.wav</a></li>
    196                                         <li class="annotationresource"><a href="">http://corpus1.mpi.nl/qfs1/media-archive/dobes_data/Ache/Documentaci_n_-_Documentation/Comunidades_-_Communities/Cerro_Moroti/Annotations/002-djawu_klluu-2011-09-01.eaf</a></li>
    197                                     </ul>
    198                                 </div>
    199 
    200                                 <p class="searchresultfullrecord">
    201                                     <a href="record1.html">View full record</a>
    202                                 </p>
    203                             </div>
    204                             <div class="searchresultitemend"></div>
    205                         </li>
    206                         <li class="searchresultitem">
    207                             <h2>
    208                                 <a href="record1.html">"Zichzelf zien"': het dubbelgangermotief in E.T.A. Hoffmanns Prinzessin Brambilla. ein Capriccio nach Jacob Callot. Een Lacaniaanse analyse</a>
    209                             </h2>
    210                             <p class="searchresultmoreless">
    211                                 <a href="#" class="searchresultdetailstoggle">expand</a>
    212                             </p>
    213                             <p class="searchresultdescription">
    214                                 Mogelijke implicaties van het 'zichzelf zien'(zoals de vroege romanticus Jean Paul Richter het dubbelgangermotief benoemde), werkte E.T.A. Hoffmann uit in de experimentele tekst PRINZESSIN BRAMBILLA. Daarin verbindt de auteur...
    215                             </p>
    216                             <p class="searchresultresources">
    217                                 Resources: <a href="record1.html">1 text file</a>, <a href="record1.html">1 audio file</a>
    218                             </p>
    219                             <div class="searchresultitemend"></div>
    220                         </li>
    221                         <li class="searchresultitem">
    222                             <h2>
    223                                 <a href="record1.html">2007 Festival</a>
    224                             </h2>
    225                             <p class="searchresultmoreless"><a href="#" class="searchresultdetailstoggle">expand</a></p>
    226                             <p class="searchresultdescription">
    227                                 Video documentation of the "festival of folk songs and dances". One file consisting of the three original tapes concatenated.
    228                             </p>
    229                             <p class="searchresultresources">
    230                                 Resources: <a href="record1.html">1 text file</a>, <a href="record1.html">1 audio file</a>
    231                             </p>
    232                             <div class="searchresultitemend"></div>
    233                         </li>
    234                         <li class="searchresultitem">
    235                             <h2>
    236                                 <a href="record1.html">...DE LEUGEN REGEERT...</a>
    237                             </h2>
    238                             <p class="searchresultmoreless"><a href="#" class="searchresultdetailstoggle">expand</a></p>
    239                             <p class="searchresultdescription">
    240                                 Presentatie: Felix Meurders. Hij wordt bijgestaan door een Mediaraad, die gedurende het programma commentaar levert op de onderwerpen. Vaste onderdelen: deleugenregeert.nl en een media-analyse door Francisco van Jole. Serie...
    241                             </p>
    242                             <p class="searchresultresources">
    243                                 Resources: <a href="record1.html">1 annotation file</a>, <a href="record1.html">1 audio file</a>
    244                             </p>
    245                             <div class="searchresultitemend"></div>
    246                         </li>
    247                     </ul>
    248                     <div id="searchresultpagination">
    249                         &lt;&lt;
    250                         &lt;
    251                         1
    252                         <a href="">2</a>
    253                         <a href="">3</a>
    254                         <a href="">4</a>
    255                         <a href="">5</a>
    256                         <a href="">6</a>
    257                         <a href="">7</a>
    258                         <a href="">8</a>
    259                         <a href="">9</a>
    260                         <a href="">10</a>
    261                         <a href="">&gt;</a>
    262                         <a href="">&gt;&gt;</a>
    263 
    264                         <form id="resultpagesizeform">
    265                             <label for="resultpagesize">Results per page:</label>
    266                             <select id="resultpagesize">
    267                                 <option>5</option>
    268                                 <option>10</option>
    269                                 <option selected="selected">25</option>
    270                                 <option>50</option>
    271                                 <option>100</option>
    272                             </select>
    273                         </form>
    274                     </div>
    275                 </div>
     105                <div wicket:id="searchResults" id="searchresults">[SEARCH RESULTS]</div>
    276106            </div>
    277107
    278108            <div class="sidebar">
    279                
     109
    280110                <div wicket:id="facets"></div>
    281                
     111
    282112                <div class="sidebaritem facet collapsedfacet">
    283113                    <!-- rounded corners - top **** -->
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/FacetedSearchPage.java

    r4528 r4530  
    44import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection;
    55import eu.clarin.cmdi.vlo.wicket.components.SearchForm;
     6import eu.clarin.cmdi.vlo.wicket.components.SearchResultsPanel;
    67import java.util.Collection;
    78import java.util.Collections;
     
    3536       
    3637        add(new SearchForm("search", queryModel));
     38       
     39        add(new SearchResultsPanel("searchResults", queryModel));
    3740    }
    3841}
  • vlo/branches/vlo-3.0/vlo-web-app/src/test/java/eu/clarin/cmdi/vlo/wicket/pages/TestFacetedSearchPage.java

    r4519 r4530  
    66import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection;
    77import eu.clarin.cmdi.vlo.service.FacetFieldsService;
     8import eu.clarin.cmdi.vlo.service.SolrDocumentService;
    89import java.util.Arrays;
    910import java.util.List;
    1011import org.apache.solr.client.solrj.response.FacetField;
     12import org.apache.solr.common.SolrDocument;
    1113import org.apache.wicket.util.tester.WicketTester;
    1214import org.jmock.Expectations;
     
    5052        }
    5153
     54        @Override
     55        public SolrDocumentService documentService() {
     56            return mockery().mock(SolrDocumentService.class);
     57        }
    5258    }
    5359
     
    5965    @Autowired
    6066    private FacetFieldsService facetFieldsService;
     67    @Autowired
     68    private SolrDocumentService documentService;
    6169
    6270    @Before
     
    7078        mockery.checking(new Expectations() {
    7179            {
     80                // mock facets
    7281                atLeast(1).of(facetFieldsService).getFacetFieldCount();
    7382                will(returnValue(2L));
    7483                oneOf(facetFieldsService).getFacetFields(with(any(QueryFacetsSelection.class)));
    7584                will(returnValue(Arrays.asList(new FacetField("language"), new FacetField("resource class"))));
     85               
     86                // mock search results
     87                atLeast(1).of(documentService).getDocumentCount(with(any(QueryFacetsSelection.class)));
     88                will(returnValue(1000L));
     89                oneOf(documentService).getDocuments(with(any(QueryFacetsSelection.class)), with(equal(0)), with(equal(10)));
     90                will(returnValue(Arrays.asList(new SolrDocument(), new SolrDocument())));
    7691            }
    7792        });
Note: See TracChangeset for help on using the changeset viewer.