001    /**
002     * Copyright (c) 2000-2013 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.List;
022    
023    import javax.portlet.PortletRequest;
024    import javax.portlet.PortletURL;
025    
026    /**
027     * @author Eduardo Lundgren
028     */
029    public class TemplateSearch extends SearchContainer<DDMTemplate> {
030    
031            static List<String> headerNames = new ArrayList<String>();
032    
033            static {
034                    headerNames.add("id");
035                    headerNames.add("name");
036                    headerNames.add("type");
037                    headerNames.add("language");
038                    headerNames.add("modified-date");
039            }
040    
041            public static final String EMPTY_RESULTS_MESSAGE = "there-are-no-templates";
042    
043            public TemplateSearch(
044                    PortletRequest portletRequest, PortletURL iteratorURL) {
045    
046                    super(
047                            portletRequest, new TemplateDisplayTerms(portletRequest),
048                            new TemplateSearchTerms(portletRequest), DEFAULT_CUR_PARAM,
049                            DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
050    
051                    TemplateDisplayTerms displayTerms =
052                            (TemplateDisplayTerms)getDisplayTerms();
053    
054                    iteratorURL.setParameter(
055                            TemplateDisplayTerms.DESCRIPTION, displayTerms.getDescription());
056                    iteratorURL.setParameter(
057                            TemplateDisplayTerms.NAME, displayTerms.getName());
058            }
059    
060    }