source: vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/RecordPage.java @ 4632

Last change on this file since 4632 was 4632, checked in by Twan Goosen, 10 years ago

added field table for record by means of a data provider (of the new DocumentField? pojo interface, plus hybrid model/implementation) with filtering capabilities and a dataview that produces a table

File size: 2.9 KB
Line 
1/*
2 * Copyright (C) 2014 CLARIN
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17package eu.clarin.cmdi.vlo.wicket.pages;
18
19import eu.clarin.cmdi.vlo.FacetConstants;
20import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection;
21import eu.clarin.cmdi.vlo.service.FieldFilter;
22import eu.clarin.cmdi.vlo.wicket.components.FieldsTablePanel;
23import eu.clarin.cmdi.vlo.wicket.components.SolrFieldLabel;
24import eu.clarin.cmdi.vlo.wicket.model.SolrFieldStringModel;
25import eu.clarin.cmdi.vlo.wicket.provider.DocumentFieldsProvider;
26import java.io.Serializable;
27import org.apache.solr.common.SolrDocument;
28import org.apache.wicket.markup.html.WebPage;
29import org.apache.wicket.markup.html.link.ExternalLink;
30import org.apache.wicket.model.IModel;
31
32/**
33 *
34 * @author twagoo
35 */
36public class RecordPage extends WebPage {
37
38    private final IModel<QueryFacetsSelection> contextModel;
39
40    public RecordPage(IModel<SolrDocument> documentModel, IModel<QueryFacetsSelection> contextModel) {
41        super(documentModel);
42        this.contextModel = contextModel;
43
44        add(new SolrFieldLabel("name", documentModel, FacetConstants.FIELD_NAME, "Unnamed record"));
45        add(createLandingPageLink("landingPageLink", documentModel));
46        add(new FieldsTablePanel("documentProperties", new DocumentFieldsProvider(documentModel, new BasicPropertiesFieldFilter())));
47    }
48
49    private ExternalLink createLandingPageLink(String id, IModel<SolrDocument> documentModel) {
50        final SolrFieldStringModel landingPageHrefModel = new SolrFieldStringModel(documentModel, FacetConstants.FIELD_LANDINGPAGE);
51        // add landing page link
52        final ExternalLink landingPageLink = new ExternalLink(id, landingPageHrefModel) {
53
54            @Override
55            protected void onConfigure() {
56                super.onConfigure();
57                setVisible(landingPageHrefModel.getObject() != null);
58            }
59
60        };
61        return landingPageLink;
62    }
63
64    @Override
65    public void detachModels() {
66        super.detachModels();
67        // not passed to parent
68        contextModel.detach();
69    }
70
71    private class BasicPropertiesFieldFilter implements FieldFilter, Serializable {
72
73        @Override
74        public boolean allowField(String fieldName) {
75            return !fieldName.startsWith("_");
76            //TODO: Exclude excluded fields and technical fields
77        }
78    }
79
80}
Note: See TracBrowser for help on using the repository browser.