Changeset 4316
- Timestamp:
- 01/21/14 13:36:47 (10 years ago)
- Location:
- vlo/branches/vlo-2.18
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-2.18
- Property svn:mergeinfo changed
/vlo/trunk merged: 4314-4315
- Property svn:mergeinfo changed
-
vlo/branches/vlo-2.18/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/dao/SolrDao.java
r4199 r4316 34 34 return solrServer; 35 35 } 36 36 37 37 /** 38 * Basic sanitising of Solr queries. 39 * 40 * Query is based on the URL to the VLO web application. Also, explain 41 * about the URL and ?fq=language:dutch 42 * Assume filters have the form a:b 43 * like for example language:dutch 44 * 38 * Basic sanitising of Solr queries. 39 * 40 * Query is based on the URL to the VLO web application. Also, explain about 41 * the URL and ?fq=language:dutch Assume filters have the form a:b like for 42 * example language:dutch 43 * 45 44 * @param query 46 * @return 45 * @return 47 46 */ 48 private SolrQuery sanitise (SolrQuery query){49 47 private SolrQuery sanitise(SolrQuery query) { 48 50 49 // String [] facetsFromConfig; 51 52 50 // try and get the filters facets from the query 53 String 51 String[] filtersInQuery; 54 52 filtersInQuery = query.getFilterQueries(); 55 53 56 54 if (filtersInQuery == null) { 57 55 // the query does not contain filters … … 67 65 for (String filter : filtersInQuery) { 68 66 // split up a filter, look at the string preceeding the semicolon 69 String facetInFilter = filter.split(":") 70 67 String facetInFilter = filter.split(":")[0]; 68 71 69 if (facetsDefined.contains(facetInFilter)) { 72 70 // facet in the filter is in the set that is defined by the config file … … 98 96 99 97 public SolrDocument getSolrDocument(String docId) { 98 if (docId == null) { 99 throw new NullPointerException("Cannot get SOLR document for null docId"); 100 } 100 101 SolrDocument result = null; 101 102 SolrQuery query = new SolrQuery(); -
vlo/branches/vlo-2.18/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/pages/ShowResultPage.java
r4311 r4316 21 21 import org.apache.wicket.Component; 22 22 import org.apache.wicket.MarkupContainer; 23 import org.apache.wicket.RestartResponseException; 23 24 import org.apache.wicket.ajax.AjaxRequestTarget; 24 25 import org.apache.wicket.request.mapper.parameter.PageParameters; … … 74 75 75 76 final StringValue docIdParam = getPageParameters().get(PARAM_DOC_ID); 76 if (docIdParam == null) { 77 throw new RuntimeException("No document id was specified. Cannot construct result page."); 78 } 79 //Document ID is assumed to have been encoded (typcially in DocumentLinkPanel) decode here 80 final String docId = UrlDecoder.QUERY_INSTANCE.decode( 81 docIdParam.toString(), 82 Application.get().getRequestCycleSettings().getResponseRequestEncoding()); // get current character set from request cycle 83 SolrDocument solrDocument = DaoLocator.getSearchResultsDao().getSolrDocument(docId); 84 85 if (solrDocument != null) { 86 final SearchPageQuery query = new SearchPageQuery(currentParam); 87 88 // create parameters from the query, and add them with session related parameters 89 PageParameters newParam = new PageParameters(query.getPageParameters()); 90 // add the session persistent parameters 91 newParam.mergeWith(VloSession.get().getVloSessionPageParameters()); 92 93 BookmarkablePageLink<String> backLink = new BookmarkablePageLink<String>("backLink", FacetedSearchPage.class, newParam); 94 add(backLink); 95 String href = getHref(docId); 96 if (href != null) { 97 add(new ExternalLink("openBrowserLink", href, new ResourceModel(Resources.OPEN_IN_ORIGINAL_CONTEXT).getObject())); 77 if (docIdParam == null || docIdParam.isNull()) { 78 LOG.warn("No document id was specified. Cannot construct result page."); 79 throw new RestartResponseException(new ResultNotFoundPage(currentParam)); 80 } else { 81 //Document ID is assumed to have been encoded (typcially in DocumentLinkPanel) decode here 82 final String docId = UrlDecoder.QUERY_INSTANCE.decode( 83 docIdParam.toString(), 84 Application.get().getRequestCycleSettings().getResponseRequestEncoding()); // get current character set from request cycle 85 86 final SolrDocument solrDocument = DaoLocator.getSearchResultsDao().getSolrDocument(docId); 87 if (solrDocument != null) { 88 final SearchPageQuery query = new SearchPageQuery(currentParam); 89 90 // create parameters from the query, and add them with session related parameters 91 PageParameters newParam = new PageParameters(query.getPageParameters()); 92 // add the session persistent parameters 93 newParam.mergeWith(VloSession.get().getVloSessionPageParameters()); 94 95 BookmarkablePageLink<String> backLink = new BookmarkablePageLink<String>("backLink", FacetedSearchPage.class, newParam); 96 add(backLink); 97 String href = getHref(docId); 98 if (href != null) { 99 add(new ExternalLink("openBrowserLink", href, new ResourceModel(Resources.OPEN_IN_ORIGINAL_CONTEXT).getObject())); 100 } else { 101 add(new Label("openBrowserLink", new ResourceModel(Resources.ORIGINAL_CONTEXT_NOT_AVAILABLE).getObject())); 102 } 103 addAttributesTable(solrDocument); 104 105 /* If there are any, add the link or links to landing pages 106 * contained in the solr document. 107 */ 108 addLandingPageLinks(solrDocument); 109 110 // also, if there are any, add the link or links to search pages 111 addSearchPageLinks(solrDocument); 112 113 // add the rest of the resource links to the result page 114 addResourceLinks(solrDocument); 115 116 addSearchServiceForm(solrDocument); 117 118 addCompleteCmdiView(solrDocument); 119 120 add(new AjaxLazyLoadPanel("prevNextHeader") { 121 122 @Override 123 public Component getLazyLoadComponent(String markupId) { 124 return new PrevNextHeaderPanel(markupId, docId, query); 125 } 126 127 @Override 128 public Component getLoadingComponent(String markupId) { 129 return new PrevNextHeaderPanel(markupId); 130 } 131 }); 98 132 } else { 99 add(new Label("openBrowserLink", new ResourceModel(Resources.ORIGINAL_CONTEXT_NOT_AVAILABLE).getObject())); 100 } 101 addAttributesTable(solrDocument); 102 103 /* If there are any, add the link or links to landing pages 104 * contained in the solr document. 105 */ 106 addLandingPageLinks(solrDocument); 107 108 // also, if there are any, add the link or links to search pages 109 addSearchPageLinks(solrDocument); 110 111 // add the rest of the resource links to the result page 112 addResourceLinks(solrDocument); 113 114 addSearchServiceForm(solrDocument); 115 116 addCompleteCmdiView(solrDocument); 117 118 add(new AjaxLazyLoadPanel("prevNextHeader") { 119 120 @Override 121 public Component getLazyLoadComponent(String markupId) { 122 return new PrevNextHeaderPanel(markupId, docId, query); 123 } 124 125 @Override 126 public Component getLoadingComponent(String markupId) { 127 return new PrevNextHeaderPanel(markupId); 128 } 129 }); 130 } else { 131 setResponsePage(new ResultNotFoundPage(currentParam)); 133 setResponsePage(new ResultNotFoundPage(currentParam)); 134 } 132 135 } 133 136 -
vlo/branches/vlo-2.18/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/pages/SolrFacetFieldDataProvider.java
r4208 r4316 17 17 import eu.clarin.cmdi.vlo.dao.DaoLocator; 18 18 import eu.clarin.cmdi.vlo.dao.SearchResultsDao; 19 import java.io.Serializable; 19 20 20 21 public class SolrFacetFieldDataProvider implements IDataProvider<Count> { 22 21 23 private final static Logger LOG = LoggerFactory.getLogger(SolrFacetFieldDataProvider.class); 22 24 23 25 private static final long serialVersionUID = 1L; 26 private final SolrQuery query; 24 27 private FacetField facet; 25 private SolrQuery query;26 28 27 29 private final String selectedFacet; … … 58 60 @Override 59 61 public Iterator<? extends Count> iterator(long first, long count) { 60 return getFacet().getValues().subList((int) first, (int)first + (int)count).iterator();62 return getFacet().getValues().subList((int) first, (int) first + (int) count).iterator(); 61 63 } 62 64 … … 75 77 } 76 78 77 @SuppressWarnings("serial")78 private static class EmptyFacetField extends FacetField { 79 private static class EmptyFacetField extends FacetField implements Serializable { 80 79 81 public EmptyFacetField(String name) { 80 82 super(name); 81 83 } 82 84 85 @Override 83 86 public List<Count> getValues() { 84 return (List<Count>) Collections.EMPTY_LIST.iterator();87 return Collections.emptyList(); 85 88 } 86 89 90 @Override 87 91 public int getValueCount() { 88 92 return 0; 89 93 } 90 91 94 } 92 95 }
Note: See TracChangeset
for help on using the changeset viewer.