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.journal.search;
016    
017    import com.liferay.portal.kernel.dao.search.SearchContainer;
018    import com.liferay.portlet.journal.model.JournalStructure;
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     */
029    public class StructureSearch extends SearchContainer<JournalStructure> {
030    
031            static List<String> headerNames = new ArrayList<String>();
032    
033            static {
034                    headerNames.add("id");
035                    headerNames.add("description");
036            }
037    
038            public static final String EMPTY_RESULTS_MESSAGE =
039                    "no-structures-were-found";
040    
041            public StructureSearch(
042                    PortletRequest portletRequest, int delta, PortletURL iteratorURL) {
043    
044                    super(
045                            portletRequest, new StructureDisplayTerms(portletRequest),
046                            new StructureSearchTerms(portletRequest), DEFAULT_CUR_PARAM, delta,
047                            iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
048    
049                    StructureDisplayTerms displayTerms =
050                            (StructureDisplayTerms)getDisplayTerms();
051    
052                    iteratorURL.setParameter(
053                            StructureDisplayTerms.DESCRIPTION, displayTerms.getDescription());
054                    iteratorURL.setParameter(
055                            StructureDisplayTerms.GROUP_ID,
056                            String.valueOf(displayTerms.getGroupId()));
057                    iteratorURL.setParameter(
058                            StructureDisplayTerms.NAME, displayTerms.getName());
059                    iteratorURL.setParameter(
060                            StructureDisplayTerms.STRUCTURE_ID, displayTerms.getStructureId());
061            }
062    
063            public StructureSearch(
064                    PortletRequest portletRequest, PortletURL iteratorURL) {
065    
066                    this(portletRequest, DEFAULT_DELTA, iteratorURL);
067            }
068    
069    }