Changeset 4971


Ignore:
Timestamp:
04/14/14 14:22:57 (10 years ago)
Author:
Twan Goosen
Message:

added 'only FCS records' option to new advanced option panel in faceted search page

Location:
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo
Files:
2 added
7 edited

Legend:

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

    r4967 r4971  
    2323
    2424/**
     25 * Represents the selection for a single facet
    2526 *
    2627 * @author twagoo
     
    3132    private final Collection<String> values;
    3233
     34    /**
     35     * Creates an {@link FacetSelectionType#AND} selection for the specified
     36     * values
     37     *
     38     * @param values
     39     */
    3340    public FacetSelection(Collection<String> values) {
    3441        this(FacetSelectionType.AND, values);
    3542    }
    3643
     44    /**
     45     * Creates an empty selection with the specified type
     46     *
     47     * @param type
     48     */
    3749    public FacetSelection(FacetSelectionType type) {
    3850        this(type, Lists.<String>newArrayList());
     
    5062    }
    5163
     64    /**
     65     *
     66     * @return type of selection
     67     */
    5268    public FacetSelectionType getSelectionType() {
    5369        return selectionType;
    5470    }
    5571
     72    /**
     73     *
     74     * @return values subject to selection type
     75     */
    5676    public Collection<String> getValues() {
    5777        return values;
     
    6282    }
    6383
     84    @Override
     85    public int hashCode() {
     86        int hash = 3;
     87        hash = 79 * hash + (this.selectionType != null ? this.selectionType.hashCode() : 0);
     88        hash = 79 * hash + (this.values != null ? this.values.hashCode() : 0);
     89        return hash;
     90    }
     91
     92    @Override
     93    public boolean equals(Object obj) {
     94        if (obj == null) {
     95            return false;
     96        }
     97        if (getClass() != obj.getClass()) {
     98            return false;
     99        }
     100        final FacetSelection other = (FacetSelection) obj;
     101        if (this.selectionType != other.selectionType) {
     102            return false;
     103        }
     104        if (this.values != other.values && (this.values == null || !this.values.equals(other.values))) {
     105            return false;
     106        }
     107        return true;
     108    }
     109
    64110}
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/pojo/FacetSelectionType.java

    r4963 r4971  
    2323public enum FacetSelectionType {
    2424
     25    /**
     26     * Specifies a selection of all documents with a non-empty value for this
     27     * facet; values supplied in the selection should be ignored
     28     */
    2529    NOT_EMPTY,
     30    /**
     31     * Specifies a selection of all documents that match all values supplied in
     32     * the selection
     33     */
    2634    AND,
     35    /**
     36     * Specifies a selection of all documents that match at least one of the
     37     * values supplied in the selection
     38     */
    2739    OR,
     40    /**
     41     * Specifies a selection of all documents that match none of the values
     42     * supplied in the selection
     43     */
    2844    NOT
    2945
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/FacetedSearchPage.html

    r4937 r4971  
    6666            <div class="sidebar">
    6767
    68                 <div wicket:id="facets"></div>
    69 
    70 <!--                <div class="sidebaritem facet collapsedfacet">
    71                      rounded corners - top ****
    72                     <div class="rtop"><div class="r1"></div><div class="r2"></div><div class="r3"></div><div class="r4"></div></div>
    73                     <a href="#" class="expandfacet"><span>expand</span></a>
    74                     <a href="#" class="collapsefacet"><span>collapse</span></a>
    75                     <h1><a href="#">Search options</a></h1>
    76                     <div class="sbilinks facetvalues">
    77                         <form id="advancedoptions" action="">
    78                             <ul>
    79                                 <li>
    80                                     <input type="checkbox" id="onlyfcs"/>
    81                                     <label for="onlyfcs">Only include resources that support content search</label>
    82                                 </li>
    83                                 <li>
    84                                     <input type="checkbox" id="onlymdformat"/>
    85                                     <label for="onlyfcs">Only include resources described with</label>
    86                                     <select>
    87                                         <option>CMDI</option>
    88                                         <option>OLAC</option>
    89                                     </select>
    90                                 </li>
    91                             </ul>
    92                             <input type="submit" value="Apply" />
    93                         </form>
    94                     </div>
    95                      rounded corners - bottom ****
    96                     <div class="rbottom"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div>
    97                 </div>-->
     68                <div wicket:id="facets">[facets]</div>
     69                <div wicket:id="options">[options]</div>
    9870            </div>
    9971        </wicket:extend>
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/FacetedSearchPage.java

    r4924 r4971  
    1414import eu.clarin.cmdi.vlo.wicket.panels.search.FacetValuesPanel;
    1515import eu.clarin.cmdi.vlo.wicket.panels.TopLinksPanel;
     16import eu.clarin.cmdi.vlo.wicket.panels.search.AdvancedSearchOptionsPanel;
    1617import java.util.List;
    1718import org.apache.solr.client.solrj.response.FacetField;
     
    8485        add(facetsPanel);
    8586
     87        Panel optionsPanel = createOptionsPanel("options");
     88        add(optionsPanel);
     89
    8690        searchResultsPanel = new SearchResultsPanel("searchResults", getModel());
    8791        add(searchResultsPanel);
     92    }
     93
     94    public Panel createOptionsPanel(String id) {
     95        final Panel optionsPanel = new AdvancedSearchOptionsPanel(id, getModel()) {
     96
     97            @Override
     98            protected void selectionChanged(AjaxRequestTarget target) {
     99                updateSelection(target);
     100            }
     101        };
     102        return optionsPanel;
    88103    }
    89104
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/AdvancedSearchOptionsPanel.html

    r4963 r4971  
    2424    <body>
    2525        <wicket:panel>
    26             <div class="sidebaritem facet collapsedfacet">
     26            <div class="sidebaritem facet expandedfacet">
    2727                <!--rounded corners - top ****-->
    2828                <div class="rtop"><div class="r1"></div><div class="r2"></div><div class="r3"></div><div class="r4"></div></div>
     
    3131                <h1><a href="#">Search options</a></h1>
    3232                <div class="sbilinks facetvalues">
    33                     <form id="advancedoptions" action="">
     33                    <form wicket:id="options" id="advancedoptions" action="">
    3434                        <ul>
    3535                            <li>
     
    4646                            </li>
    4747                        </ul>
    48                         <input type="submit" value="Apply" />
     48                        <input type="submit" value="Apply" class="nonjsfallback" />
    4949                    </form>
    5050                </div>
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/AdvancedSearchOptionsPanel.java

    r4963 r4971  
    1515 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1616 */
    17 
    1817package eu.clarin.cmdi.vlo.wicket.panels.search;
    1918
     19import eu.clarin.cmdi.vlo.FacetConstants;
     20import eu.clarin.cmdi.vlo.pojo.FacetSelection;
     21import eu.clarin.cmdi.vlo.pojo.FacetSelectionType;
    2022import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection;
     23import eu.clarin.cmdi.vlo.wicket.model.FacetSelectionModel;
     24import eu.clarin.cmdi.vlo.wicket.model.ToggleModel;
     25import org.apache.wicket.ajax.AjaxRequestTarget;
     26import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
     27import org.apache.wicket.markup.html.form.CheckBox;
     28import org.apache.wicket.markup.html.form.Form;
    2129import org.apache.wicket.markup.html.panel.GenericPanel;
    2230import org.apache.wicket.model.IModel;
    2331
    2432/**
     33 * A panel showing advanced search options:
     34 * <ul>
     35 * <li>selection of records that support FCS</li>
     36 * <li>selection of records that are based on either CMDI or OLAC</li>
     37 * </ul>
    2538 *
    2639 * @author twagoo
    2740 */
    28 public class AdvancedSearchOptionsPanel extends GenericPanel<QueryFacetsSelection> {
     41public abstract class AdvancedSearchOptionsPanel extends GenericPanel<QueryFacetsSelection> {
    2942
    3043    public AdvancedSearchOptionsPanel(String id, IModel<QueryFacetsSelection> model) {
    3144        super(id, model);
     45
     46        // create a model for the selection state for the FCS facet
     47        final IModel<FacetSelection> fcsFacetModel = new FacetSelectionModel(model, FacetConstants.FIELD_SEARCH_SERVICE);
     48        // wrap in a toggle model that allows switching between a null selection and a 'not empty' selection
     49        final ToggleModel<FacetSelection> toggleModel = new ToggleModel<FacetSelection>(fcsFacetModel, null, new FacetSelection(FacetSelectionType.NOT_EMPTY));
     50
     51        final Form options = new Form("options");
     52        final CheckBox fcsCheck = new CheckBox("fcs", toggleModel);
     53        fcsCheck.add(new OnChangeAjaxBehavior() {
     54
     55            @Override
     56            protected void onUpdate(AjaxRequestTarget target) {
     57                selectionChanged(target);
     58            }
     59        });
     60        options.add(fcsCheck);
     61        add(options);
    3262    }
    33    
     63
     64    protected abstract void selectionChanged(AjaxRequestTarget target);
     65
    3466}
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/FacetsPanel.java

    r4963 r4971  
    1818
    1919import eu.clarin.cmdi.vlo.pojo.ExpansionState;
    20 import eu.clarin.cmdi.vlo.pojo.FacetSelection;
    2120import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection;
    2221import eu.clarin.cmdi.vlo.service.solr.FacetFieldsService;
     
    2423import eu.clarin.cmdi.vlo.wicket.model.FacetFieldModel;
    2524import eu.clarin.cmdi.vlo.wicket.model.FacetFieldSelectionModel;
    26 import java.util.Collection;
    2725import java.util.HashMap;
    2826import java.util.List;
Note: See TracChangeset for help on using the changeset viewer.