001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.journal.search;
016    
017    import com.liferay.portal.kernel.dao.search.SearchContainer;
018    import com.liferay.portal.kernel.repository.model.FileEntry;
019    
020    import java.util.ArrayList;
021    import java.util.List;
022    
023    import javax.portlet.PortletRequest;
024    import javax.portlet.PortletURL;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     * @author Vilmos Papp
029     */
030    public class FileEntrySearch extends SearchContainer<FileEntry> {
031    
032            static List<String> headerNames = new ArrayList<String>();
033    
034            static {
035                    headerNames.add("document");
036                    headerNames.add("size");
037                    headerNames.add("downloads");
038                    headerNames.add("locked");
039            }
040    
041            public static final String EMPTY_RESULTS_MESSAGE = "there-are-no-documents";
042    
043            public FileEntrySearch(
044                    PortletRequest portletRequest, FileEntryDisplayTerms displayTerms,
045                    FileEntrySearchTerms searchTerms, String cur, int delta,
046                    PortletURL iteratorURL, List<String> headers,
047                    String emptyResultsMessage) {
048    
049                    super(
050                            portletRequest, new FileEntryDisplayTerms(portletRequest),
051                            new FileEntrySearchTerms(portletRequest), cur, delta, iteratorURL,
052                            headers, emptyResultsMessage);
053    
054                    iteratorURL.setParameter(
055                            FileEntryDisplayTerms.DOCUMENT, displayTerms.getDocument());
056                    iteratorURL.setParameter(
057                            FileEntryDisplayTerms.LOCKED,
058                            String.valueOf(displayTerms.isLocked()));
059                    iteratorURL.setParameter(
060                            FileEntryDisplayTerms.SELECTED_GROUP_ID,
061                            String.valueOf(displayTerms.getSelectedGroupId()));
062                    iteratorURL.setParameter(
063                            FileEntryDisplayTerms.SIZE, displayTerms.getSize());
064            }
065    
066            public FileEntrySearch(
067                    PortletRequest portletRequest, PortletURL iteratorURL) {
068    
069                    this(
070                            portletRequest, new FileEntryDisplayTerms(portletRequest),
071                            new FileEntrySearchTerms(portletRequest), DEFAULT_CUR_PARAM,
072                            DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
073            }
074    
075    }