001    /**
002     * Copyright (c) 2000-2010 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            }
040    
041            public static final String EMPTY_RESULTS_MESSAGE =
042                    "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 =
053                            (AssetDisplayTerms)getDisplayTerms();
054    
055                    iteratorURL.setParameter(
056                            AssetDisplayTerms.DESCRIPTION, displayTerms.getDescription());
057                    iteratorURL.setParameter(
058                            AssetDisplayTerms.GROUP_ID,
059                            String.valueOf(displayTerms.getGroupId()));
060                    iteratorURL.setParameter(
061                            AssetDisplayTerms.TITLE, displayTerms.getTitle());
062                    iteratorURL.setParameter(
063                            AssetDisplayTerms.USER_NAME, displayTerms.getUserName());
064            }
065    
066            public AssetSearch(
067                    PortletRequest portletRequest, PortletURL iteratorURL) {
068    
069                    this(portletRequest, DEFAULT_DELTA, iteratorURL);
070            }
071    
072    }