001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.widgets.dataview;
029
030import org.opencms.file.CmsObject;
031
032import java.util.List;
033import java.util.Locale;
034
035/**
036 * Interface for a data source for use by CmsDataViewWidget.<p>
037 *
038 * This provides everything the widget needs to query an external data source, display the query
039 * results (items) in tabular form, and provide the data to be stored when the user selects one or multiple items.
040 */
041public interface I_CmsDataView {
042
043    /**
044     * Retrieves the list of columns to be displayed in the external data view widget.<p>
045     *
046     * This method should always return the same columns.
047     *
048     * @return a list of column definitions
049     */
050    List<CmsDataViewColumn> getColumns();
051
052    /**
053     * Gets the initial list of filters.<p>
054     *
055     * This is only used for the initial display of the data table; if the user changes the filters,
056     * the method updateFilters() is called instead.
057     *
058     * @return the initial list of filters
059     */
060    List<CmsDataViewFilter> getFilters();
061
062    /**
063     * Retrieves the data item with the given id.<p>
064     *
065     * If no data item with that id exists, this method should return null.<p>
066     *
067     * @param id the id for which to retrieve the item
068     *
069     * @return the data item with the given the
070     */
071    I_CmsDataViewItem getItemById(String id);
072
073    /**
074     * Gets the page size, used for paging results.<p>
075     *
076     * @return the page size
077     */
078    int getPageSize();
079
080    /**
081     * Gets the result for the given query, with the given offset and limited to the given number of results.<p>
082     *
083     * The returned result includes a list of result items, and a total hit count for the given query (i.e. the number of results
084     * that would be returned for offset 0 and unlimited result count). The hit count should be as accurate as possible.
085     *
086     * @param query the query
087     * @param offset position of the first result to return (starts with 0)
088     * @param count maximum number of results to return
089     *
090     * @return the result object
091     */
092    CmsDataViewResult getResults(CmsDataViewQuery query, int offset, int count);
093
094    /**
095     * Initializes this data view instance.<p>
096     *
097     * @param cms the CMS context to use for VFS operations
098     * @param configData a string containing configuration data
099     * @param locale the locale to use for the user interface
100     */
101    void initialize(CmsObject cms, String configData, Locale locale);
102
103    /**
104     * Returns an updated list of filters based on the current filters and their values.<p>
105     *
106     * This is called when the user changes any of the current filters in the data select widget.
107     * The list passed as a parameter should not be modified, instead a new filter list should be returned.
108     * If you do not need a dynamically changing set of filters, just return the argument 'prevFilters'
109     * in your implementation.
110     *
111     * @param prevFilters the current set of filters
112     * @return the new list of filters
113     */
114    List<CmsDataViewFilter> updateFilters(List<CmsDataViewFilter> prevFilters);
115
116}