001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.dynamicdatamapping.search;
016    
017    import com.liferay.portal.kernel.dao.search.SearchContainer;
018    import com.liferay.portlet.dynamicdatamapping.model.DDMTemplate;
019    
020    import java.util.ArrayList;
021    import java.util.HashMap;
022    import java.util.List;
023    import java.util.Map;
024    
025    import javax.portlet.PortletRequest;
026    import javax.portlet.PortletURL;
027    
028    /**
029     * @author Eduardo Lundgren
030     */
031    public class TemplateSearch extends SearchContainer<DDMTemplate> {
032    
033            static List<String> headerNames = new ArrayList<String>();
034            static Map<String, String> orderableHeaders = new HashMap<String, String>();
035    
036            static {
037                    headerNames.add("id");
038                    headerNames.add("name");
039                    headerNames.add("type");
040                    headerNames.add("language");
041                    headerNames.add("modified-date");
042            }
043    
044            public static final String EMPTY_RESULTS_MESSAGE = "there-are-no-templates";
045    
046            public TemplateSearch(
047                    PortletRequest portletRequest, PortletURL iteratorURL) {
048    
049                    super(
050                            portletRequest, new TemplateDisplayTerms(portletRequest),
051                            new TemplateSearchTerms(portletRequest), DEFAULT_CUR_PARAM,
052                            DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
053    
054                    TemplateDisplayTerms displayTerms =
055                            (TemplateDisplayTerms)getDisplayTerms();
056    
057                    iteratorURL.setParameter(
058                            TemplateDisplayTerms.DESCRIPTION, displayTerms.getDescription());
059                    iteratorURL.setParameter(
060                            TemplateDisplayTerms.NAME, displayTerms.getName());
061            }
062    
063    }