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.assetpublisher.search;
016    
017    import com.liferay.portal.kernel.dao.search.SearchContainer;
018    import com.liferay.portlet.asset.model.AssetEntry;
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 Julio Camarero
029     */
030    public class AssetSearch extends SearchContainer<AssetEntry> {
031    
032            static List<String> headerNames = new ArrayList<String>();
033    
034            static {
035                    headerNames.add("title");
036                    headerNames.add("description");
037                    headerNames.add("user-name");
038                    headerNames.add("modified-date");
039                    headerNames.add("scope");
040            }
041    
042            public static final String EMPTY_RESULTS_MESSAGE = "there-are-no-results";
043    
044            public AssetSearch(
045                    PortletRequest portletRequest, int delta, PortletURL iteratorURL) {
046    
047                    super(
048                            portletRequest, new AssetDisplayTerms(portletRequest),
049                            new AssetSearchTerms(portletRequest), DEFAULT_CUR_PARAM, delta,
050                            iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
051    
052                    AssetDisplayTerms displayTerms = (AssetDisplayTerms)getDisplayTerms();
053    
054                    iteratorURL.setParameter(
055                            AssetDisplayTerms.DESCRIPTION, displayTerms.getDescription());
056                    iteratorURL.setParameter(
057                            AssetDisplayTerms.GROUP_ID,
058                            String.valueOf(displayTerms.getGroupId()));
059                    iteratorURL.setParameter(
060                            AssetDisplayTerms.TITLE, displayTerms.getTitle());
061                    iteratorURL.setParameter(
062                            AssetDisplayTerms.USER_NAME, displayTerms.getUserName());
063            }
064    
065            public AssetSearch(PortletRequest portletRequest, PortletURL iteratorURL) {
066                    this(portletRequest, DEFAULT_DELTA, iteratorURL);
067            }
068    
069    }