Changeset 4626
- Timestamp:
- 03/06/14 10:06:18 (11 years ago)
- 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 1 1 package eu.clarin.cmdi.vlo; 2 2 3 import eu.clarin.cmdi.vlo.service.SolrDocumentService; 3 4 import eu.clarin.cmdi.vlo.wicket.pages.FacetedSearchPage; 5 import org.apache.wicket.Application; 4 6 import org.apache.wicket.markup.html.WebPage; 5 7 import org.apache.wicket.protocol.http.WebApplication; 6 8 import org.apache.wicket.spring.injection.annot.SpringComponentInjector; 7 9 import org.springframework.beans.BeansException; 10 import org.springframework.beans.factory.annotation.Autowired; 8 11 import org.springframework.context.ApplicationContext; 9 12 import org.springframework.context.ApplicationContextAware; … … 17 20 public class VloWicketApplication extends WebApplication implements ApplicationContextAware { 18 21 22 @Autowired 23 private SolrDocumentService documentService; 24 25 19 26 private ApplicationContext applicationContext; 20 27 … … 37 44 getComponentInstantiationListeners().add(new SpringComponentInjector(this, applicationContext)); 38 45 } 46 47 /** 48 * 49 * @return the active VLO wicket application 50 */ 51 public static VloWicketApplication get() { 52 return (VloWicketApplication) Application.get(); 53 } 39 54 40 55 /** … … 49 64 this.applicationContext = applicationContext; 50 65 } 66 67 public SolrDocumentService getDocumentService() { 68 return documentService; 69 } 70 71 51 72 } -
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/SolrDocumentService.java
r4530 r4626 26 26 */ 27 27 public interface SolrDocumentService { 28 29 SolrDocument getDocument(String docId); 28 30 29 31 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 40 40 41 41 @Override 42 public SolrDocument getDocument(String docId) { 43 throw new UnsupportedOperationException("Not supported yet."); 44 } 45 46 @Override 42 47 public List<SolrDocument> getDocuments(QueryFacetsSelection selection, int first, int count) { 43 48 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 48 48 public static final List<Long> ITEMS_PER_PAGE_OPTIONS = Arrays.asList(5L, 10L, 25L, 50L, 100L); 49 49 50 @SpringBean51 private SolrDocumentService documentService;52 50 private final IDataProvider<SolrDocument> solrDocumentProvider; 53 51 private final DataView<SolrDocument> resultsView; … … 55 53 public SearchResultsPanel(String id, final IModel<QueryFacetsSelection> selectionModel) { 56 54 super(id, selectionModel); 57 solrDocumentProvider = new SolrDocumentProvider( documentService,selectionModel);55 solrDocumentProvider = new SolrDocumentProvider(selectionModel); 58 56 59 57 // 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 17 17 package eu.clarin.cmdi.vlo.wicket.provider; 18 18 19 import eu.clarin.cmdi.vlo.VloWicketApplication; 19 20 import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection; 20 21 import eu.clarin.cmdi.vlo.service.SolrDocumentService; 22 import eu.clarin.cmdi.vlo.wicket.model.SolrDocumentModel; 21 23 import java.math.BigDecimal; 22 24 import java.util.Iterator; … … 25 27 import org.apache.wicket.markup.repeater.data.IDataProvider; 26 28 import org.apache.wicket.model.IModel; 27 import org.apache.wicket.model.Model;28 29 29 30 /** … … 33 34 public class SolrDocumentProvider implements IDataProvider<SolrDocument> { 34 35 35 private final SolrDocumentService documentService;36 36 private final IModel<QueryFacetsSelection> selectionModel; 37 37 38 public SolrDocumentProvider(SolrDocumentService documentService, IModel<QueryFacetsSelection> selection) { 39 this.documentService = documentService; 38 public SolrDocumentProvider(IModel<QueryFacetsSelection> selection) { 40 39 this.selectionModel = selection; 41 40 } … … 43 42 @Override 44 43 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(), 46 45 BigDecimal.valueOf(first).intValueExact(), // safe long->int conversion 47 46 BigDecimal.valueOf(count).intValueExact()); // safe long->int conversion … … 51 50 @Override 52 51 public long size() { 53 return documentService.getDocumentCount(selectionModel.getObject());52 return getDocumentService().getDocumentCount(selectionModel.getObject()); 54 53 } 55 54 56 55 @Override 57 56 public IModel<SolrDocument> model(SolrDocument object) { 58 return new Model(object);57 return new SolrDocumentModel(object); 59 58 } 60 59 … … 64 63 } 65 64 65 private SolrDocumentService getDocumentService() { 66 return VloWicketApplication.get().getDocumentService(); 67 } 66 68 }
Note: See TracChangeset
for help on using the changeset viewer.