Ignore:
Timestamp:
12/18/13 12:38:15 (10 years ago)
Author:
keeloo
Message:

After splitting of a branch (r4199) including code for moving from wicket 1.4 to wicket 6, some more modifications in the direction of that target.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/to-wicket-1.6/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/pages/SearchServiceDataProvider.java

    r2768 r4201  
    1717
    1818/**
    19  * Data provider of all documents with SearchService entry (FCS) based on existing SolrQuery
    20  *
     19 * Data provider of all documents with SearchService entry (FCS) based on
     20 * existing SolrQuery
     21 *
    2122 * @author Thomas Eckart
    2223 *
    2324 */
    24 public class SearchServiceDataProvider extends SortableDataProvider<SolrDocument> {
    25         private final static Logger LOG = LoggerFactory.getLogger(SearchServiceDataProvider.class);
    26        
    27         private static final long serialVersionUID = -5355607690141772113L;
    28         private final SolrQuery query;
    29         private SolrDocumentList docList;
     25public class SearchServiceDataProvider extends SortableDataProvider<SolrDocument, String> {
    3026
    31         public SearchServiceDataProvider(SolrQuery query) {
    32                 this.query = query;
    33                 this.query.setFacet(false);
    34                 this.query.setStart(0);
    35                 this.query.setRows(10);
    36                 this.query.setFields(FacetConstants.FIELD_SEARCH_SERVICE, FacetConstants.FIELD_ID);
    37                 this.query.setQuery(query.getQuery());
    38                 this.query.addFilterQuery(FacetConstants.FIELD_SEARCH_SERVICE + ":*");
    39                 LOG.debug("Used query for search services: "+this.query.toString());
    40         }
     27    private final static Logger LOG = LoggerFactory.getLogger(SearchServiceDataProvider.class);
     28    private static final long serialVersionUID = -5355607690141772113L;
     29    private final SolrQuery query;
     30    private SolrDocumentList docList;
    4131
    42         private SearchResultsDao getSearchResultsDao() {
    43                 return DaoLocator.getSearchResultsDao();
    44         }
     32    public SearchServiceDataProvider(SolrQuery query) {
     33        this.query = query;
     34        this.query.setFacet(false);
     35        this.query.setStart(0);
     36        this.query.setRows(10);
     37        this.query.setFields(FacetConstants.FIELD_SEARCH_SERVICE, FacetConstants.FIELD_ID);
     38        this.query.setQuery(query.getQuery());
     39        this.query.addFilterQuery(FacetConstants.FIELD_SEARCH_SERVICE + ":*");
     40        LOG.debug("Used query for search services: " + this.query.toString());
     41    }
    4542
    46         private SolrDocumentList getDocList() {
    47                 if (docList == null) {
    48                         docList = getSearchResultsDao().getResults(query);
    49                 }
    50                 return docList;
    51         }
     43    private SearchResultsDao getSearchResultsDao() {
     44        return DaoLocator.getSearchResultsDao();
     45    }
    5246
    53         @Override
    54         public Iterator<SolrDocument> iterator(int first, int count) {
    55                 if (first != query.getStart().intValue() || count != query.getRows().intValue()) {
    56                         query.setStart(first).setRows(count);
    57                         docList = null;
    58                 }
    59                 return getDocList().iterator();
    60         }
    61        
    62         public Iterator<SolrDocument> iterator() {
    63                 return getDocList().iterator();
    64         }
     47    private SolrDocumentList getDocList() {
     48        if (docList == null) {
     49            docList = getSearchResultsDao().getResults(query);
     50        }
     51        return docList;
     52    }
    6553
    66         @Override
    67         public IModel<SolrDocument> model(SolrDocument solrDocument) {
    68                 return new Model<SolrDocument>(solrDocument);
    69         }
     54    @Override
     55    public Iterator<SolrDocument> iterator(long first, long count) {
     56        if (first != query.getStart().intValue() || count != query.getRows().intValue()) {
     57            query.setStart((int) first).setRows((int) count);
     58            docList = null;
     59        }
     60        return getDocList().iterator();
     61    }
    7062
    71         @Override
    72         public int size() {
    73                 return (int) getDocList().getNumFound();
    74         }
     63    public Iterator<SolrDocument> iterator() {
     64        return getDocList().iterator();
     65    }
     66
     67    @Override
     68    public IModel<SolrDocument> model(SolrDocument solrDocument) {
     69        return new Model<SolrDocument>(solrDocument);
     70    }
     71
     72    @Override
     73    public long size() {
     74        return getDocList().getNumFound();
     75    }
    7576}
Note: See TracChangeset for help on using the changeset viewer.