Changeset 4212 for vlo/branches/to-wicket-1.6-twagoo/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/pages/FacetedSearchPage.java
- Timestamp:
- 01/06/14 08:18:53 (10 years ago)
- Location:
- vlo/branches/to-wicket-1.6-twagoo
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/to-wicket-1.6-twagoo/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/pages/FacetedSearchPage.java
r4208 r4212 10 10 import fiftyfive.wicket.basic.TruncatedLabel; 11 11 import java.io.UnsupportedEncodingException; 12 import java.net.URL; 12 13 import java.net.URLEncoder; 13 14 import java.util.ArrayList; … … 21 22 import org.apache.solr.common.SolrDocument; 22 23 import org.apache.wicket.request.mapper.parameter.PageParameters; 23 import org.apache.wicket.RequestCycle;24 24 import org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField; 25 25 import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable; … … 42 42 import org.apache.wicket.model.ResourceModel; 43 43 import org.apache.wicket.protocol.http.RequestUtils; 44 import org.apache.wicket.request.Url; 45 import org.apache.wicket.request.cycle.RequestCycle; 44 46 45 47 public class FacetedSearchPage extends BasePage { 48 46 49 private static final long serialVersionUID = 1L; 47 50 … … 50 53 private final static String facetConceptsFile = VloConfig.getFacetConceptsFile(); 51 54 private final static Map<String, FacetConcept> facetNameMap = VLOMarshaller.getFacetConceptMapping(facetConceptsFile).getFacetConceptMap(); 52 55 56 public FacetedSearchPage() { 57 this(new VloPageParameters()); 58 } 59 53 60 /** 54 61 * @param parameters Page parameters … … 66 73 @SuppressWarnings("serial") 67 74 private class SearchBoxForm extends Form<SearchPageQuery> { 75 68 76 private final AutoCompleteTextField<String> searchBox; 69 77 70 78 /* 71 79 * Add multiline list of selected facet values … … 78 86 79 87 // create an interator for walking over the facets 80 Iterator<Map.Entry<String, String>> entries =81 selectedFacets.entrySet().iterator();88 Iterator<Map.Entry<String, String>> entries 89 = selectedFacets.entrySet().iterator(); 82 90 83 91 /* … … 90 98 if (!entries.hasNext()) { 91 99 // not a single facet has been selected 92 facetOverview = new MultiLineLabel("facetOverview", 100 facetOverview = new MultiLineLabel("facetOverview", 93 101 "No facets values selected"); 94 102 } else { … … 152 160 } 153 161 }; 154 162 155 163 add(searchBox); 156 164 Button submit = new Button("searchSubmit"); 157 165 add(submit); 158 166 159 167 // merge link to help menu page 160 String helpUrl = VloConfig.getHelpUrl(); 168 String helpUrl = VloConfig.getHelpUrl(); 161 169 ExternalLink helpLink = new ExternalLink("helpLink", helpUrl, "help"); 162 170 add(helpLink); 163 164 VloPageParameters param; 165 param = new VloPageParameters (query.getPageParameters()); 166 167 String thisURL; 168 thisURL = RequestUtils.toAbsolutePath( 169 RequestCycle.get().urlFor(ShowResultPage.class, param.convert()).toString(), null); 171 172 VloPageParameters param; 173 param = new VloPageParameters(query.getPageParameters()); 174 175 final RequestCycle reqCycle = getRequestCycle(); 176 final Url reqUrl = Url.parse(reqCycle.urlFor(ShowResultPage.class, param.convert())); 177 String thisURL = reqCycle.getUrlRenderer().renderFullUrl(reqUrl); 178 170 179 try { 171 180 thisURL = URLEncoder.encode(thisURL, "UTF-8"); 172 181 } catch (UnsupportedEncodingException e) { 173 182 } 174 183 175 184 String feedbackFormUrl = VloConfig.getFeedbackFromUrl() + thisURL; 176 185 ExternalLink feedbackLink = new ExternalLink("feedbackLink", feedbackFormUrl, "found an error?"); 177 186 add(feedbackLink); 178 187 179 188 addFacetOverview(); 180 189 } … … 186 195 187 196 VloPageParameters newParam = new VloPageParameters(); 188 197 189 198 setResponsePage(FacetedSearchPage.class, newParam); 190 199 } … … 194 203 add(new SearchBoxForm("searchForm", query)); 195 204 } 196 205 197 206 @SuppressWarnings("serial") 198 207 private void addFacetColumns() { 199 208 GridView<FacetField> facetColumns = new GridView<FacetField>("facetColumns", (IDataProvider<FacetField>) new SolrFacetDataProvider(query.getSolrQuery() 200 209 .getCopy())) { 201 @Override 202 protected void populateItem(Item<FacetField> item) { 203 String facetName = ((FacetField)item.getDefaultModelObject()).getName(); 204 String descriptionTooltip = ""; 205 if(facetNameMap.containsKey(facetName)) 206 descriptionTooltip = facetNameMap.get(facetName).getDescription(); 207 item.add(new FacetBoxPanel("facetBox", item.getModel(), descriptionTooltip).create(query)); 208 } 209 210 @Override 211 protected void populateEmptyItem(Item<FacetField> item) { 212 item.add(new Label("facetBox", "")); 213 } 214 }; 210 @Override 211 protected void populateItem(Item<FacetField> item) { 212 String facetName = ((FacetField) item.getDefaultModelObject()).getName(); 213 String descriptionTooltip = ""; 214 if (facetNameMap.containsKey(facetName)) { 215 descriptionTooltip = facetNameMap.get(facetName).getDescription(); 216 } 217 item.add(new FacetBoxPanel("facetBox", item.getModel(), descriptionTooltip).create(query)); 218 } 219 220 @Override 221 protected void populateEmptyItem(Item<FacetField> item) { 222 item.add(new Label("facetBox", "")); 223 } 224 }; 215 225 facetColumns.setColumns(2); 216 226 add(facetColumns); … … 222 232 columns = new ArrayList<IColumn<SolrDocument, String>>(); 223 233 columns.add(new AbstractColumn<SolrDocument, String>(new ResourceModel(Resources.NAME)) { 224 234 225 235 @Override 226 236 public void populateItem(Item<ICellPopulator<SolrDocument>> cellItem, String componentId, IModel<SolrDocument> rowModel) { … … 232 242 @Override 233 243 public void populateItem(Item<ICellPopulator<SolrDocument>> cellItem, String componentId, IModel<SolrDocument> rowModel) { 234 244 String descriptionText = (String) rowModel.getObject().getFirstValue(FacetConstants.FIELD_DESCRIPTION); 235 245 cellItem.add(new TruncatedLabel(componentId, 100, descriptionText)); 236 237 246 } 238 247 }); … … 241 250 add(searchResultList); 242 251 } 243 252 244 253 /** 245 254 * Add contentSearch form (FCS) … … 248 257 */ 249 258 private void addSearchServiceForm() { 250 259 251 260 BookmarkablePageLink link; 252 link = new BookmarkablePageLink 253 link.add (new Label("naar deze pagina"));254 261 link = new BookmarkablePageLink("link", FacetedSearchPage.class); 262 link.add(new Label("naar deze pagina")); 263 255 264 // get values for cql endpoint substitution 256 265 String cqlEndpointFilter = VloConfig.getCqlEndpointFilter(); … … 281 290 List<String> idArray = new ArrayList<String>(); 282 291 idArray.add(id); 283 292 284 293 // substitute endpoint 285 if (cqlEndpointFilter.length() == 0) {294 if (cqlEndpointFilter.length() == 0) { 286 295 // no substitution 287 296 } else { 288 297 // check for the need to substitute 289 298 } 290 291 if (cqlEndpointFilter.equals(cqlEndpointFilter)) {299 300 if (cqlEndpointFilter.equals(cqlEndpointFilter)) { 292 301 // no substitution, take the value from the record 293 302 aggregationContextMap.put(fcsEndpoint, idArray);
Note: See TracChangeset
for help on using the changeset viewer.