Changeset 4626


Ignore:
Timestamp:
03/06/14 10:06:18 (11 years ago)
Author:
Twan Goosen
Message:
  • Created loadable/detachable model for a SolrDocument?. Document service now registered on VloWicketApplication? so that model can use it without needing injection or a reference.
  • Added method to document service interface to get a document by id, to be implemented
Location:
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo
Files:
1 added
5 edited

Legend:

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

    r4515 r4626  
    11package eu.clarin.cmdi.vlo;
    22
     3import eu.clarin.cmdi.vlo.service.SolrDocumentService;
    34import eu.clarin.cmdi.vlo.wicket.pages.FacetedSearchPage;
     5import org.apache.wicket.Application;
    46import org.apache.wicket.markup.html.WebPage;
    57import org.apache.wicket.protocol.http.WebApplication;
    68import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
    79import org.springframework.beans.BeansException;
     10import org.springframework.beans.factory.annotation.Autowired;
    811import org.springframework.context.ApplicationContext;
    912import org.springframework.context.ApplicationContextAware;
     
    1720public class VloWicketApplication extends WebApplication implements ApplicationContextAware {
    1821
     22    @Autowired
     23    private SolrDocumentService documentService;
     24   
     25   
    1926    private ApplicationContext applicationContext;
    2027
     
    3744        getComponentInstantiationListeners().add(new SpringComponentInjector(this, applicationContext));
    3845    }
     46   
     47    /**
     48     *
     49     * @return the active VLO wicket application
     50     */
     51    public static VloWicketApplication get() {
     52        return (VloWicketApplication) Application.get();
     53    }
    3954
    4055    /**
     
    4964        this.applicationContext = applicationContext;
    5065    }
     66
     67    public SolrDocumentService getDocumentService() {
     68        return documentService;
     69    }
     70   
     71   
    5172}
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/SolrDocumentService.java

    r4530 r4626  
    2626 */
    2727public interface SolrDocumentService {
     28   
     29    SolrDocument getDocument(String docId);
    2830
    2931    List<SolrDocument> getDocuments(QueryFacetsSelection selection, int first, int count);
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/impl/SolrDocumentServiceImpl.java

    r4566 r4626  
    4040
    4141    @Override
     42    public SolrDocument getDocument(String docId) {
     43        throw new UnsupportedOperationException("Not supported yet.");
     44    }
     45
     46    @Override
    4247    public List<SolrDocument> getDocuments(QueryFacetsSelection selection, int first, int count) {
    4348        SolrQuery query = queryFatory.createDocumentQuery(selection,first, count);
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/components/SearchResultsPanel.java

    r4622 r4626  
    4848    public static final List<Long> ITEMS_PER_PAGE_OPTIONS = Arrays.asList(5L, 10L, 25L, 50L, 100L);
    4949
    50     @SpringBean
    51     private SolrDocumentService documentService;
    5250    private final IDataProvider<SolrDocument> solrDocumentProvider;
    5351    private final DataView<SolrDocument> resultsView;
     
    5553    public SearchResultsPanel(String id, final IModel<QueryFacetsSelection> selectionModel) {
    5654        super(id, selectionModel);
    57         solrDocumentProvider = new SolrDocumentProvider(documentService, selectionModel);
     55        solrDocumentProvider = new SolrDocumentProvider(selectionModel);
    5856
    5957        // data view for search results
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/provider/SolrDocumentProvider.java

    r4606 r4626  
    1717package eu.clarin.cmdi.vlo.wicket.provider;
    1818
     19import eu.clarin.cmdi.vlo.VloWicketApplication;
    1920import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection;
    2021import eu.clarin.cmdi.vlo.service.SolrDocumentService;
     22import eu.clarin.cmdi.vlo.wicket.model.SolrDocumentModel;
    2123import java.math.BigDecimal;
    2224import java.util.Iterator;
     
    2527import org.apache.wicket.markup.repeater.data.IDataProvider;
    2628import org.apache.wicket.model.IModel;
    27 import org.apache.wicket.model.Model;
    2829
    2930/**
     
    3334public class SolrDocumentProvider implements IDataProvider<SolrDocument> {
    3435
    35     private final SolrDocumentService documentService;
    3636    private final IModel<QueryFacetsSelection> selectionModel;
    3737
    38     public SolrDocumentProvider(SolrDocumentService documentService, IModel<QueryFacetsSelection> selection) {
    39         this.documentService = documentService;
     38    public SolrDocumentProvider(IModel<QueryFacetsSelection> selection) {
    4039        this.selectionModel = selection;
    4140    }
     
    4342    @Override
    4443    public Iterator<? extends SolrDocument> iterator(long first, long count) {
    45         final List<SolrDocument> documents = documentService.getDocuments(selectionModel.getObject(),
     44        final List<SolrDocument> documents = getDocumentService().getDocuments(selectionModel.getObject(),
    4645                BigDecimal.valueOf(first).intValueExact(), // safe long->int conversion
    4746                BigDecimal.valueOf(count).intValueExact()); // safe long->int conversion
     
    5150    @Override
    5251    public long size() {
    53         return documentService.getDocumentCount(selectionModel.getObject());
     52        return getDocumentService().getDocumentCount(selectionModel.getObject());
    5453    }
    5554
    5655    @Override
    5756    public IModel<SolrDocument> model(SolrDocument object) {
    58         return new Model(object);
     57        return new SolrDocumentModel(object);
    5958    }
    6059
     
    6463    }
    6564
     65    private SolrDocumentService getDocumentService() {
     66        return VloWicketApplication.get().getDocumentService();
     67    }
    6668}
Note: See TracChangeset for help on using the changeset viewer.