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.journal.search;
016    
017    import com.liferay.portal.kernel.dao.search.SearchContainer;
018    import com.liferay.portal.kernel.util.StringUtil;
019    import com.liferay.portlet.journal.model.JournalStructure;
020    
021    import java.util.ArrayList;
022    import java.util.List;
023    
024    import javax.portlet.PortletRequest;
025    import javax.portlet.PortletURL;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     */
030    public class StructureSearch extends SearchContainer<JournalStructure> {
031    
032            static List<String> headerNames = new ArrayList<String>();
033    
034            static {
035                    headerNames.add("id");
036                    headerNames.add("name");
037                    headerNames.add("description");
038            }
039    
040            public static final String EMPTY_RESULTS_MESSAGE =
041                    "no-structures-were-found";
042    
043            public StructureSearch(
044                    PortletRequest portletRequest, int delta, PortletURL iteratorURL) {
045    
046                    super(
047                            portletRequest, new StructureDisplayTerms(portletRequest),
048                            new StructureSearchTerms(portletRequest), DEFAULT_CUR_PARAM, delta,
049                            iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
050    
051                    StructureDisplayTerms displayTerms =
052                            (StructureDisplayTerms)getDisplayTerms();
053    
054                    iteratorURL.setParameter(
055                            StructureDisplayTerms.DESCRIPTION, displayTerms.getDescription());
056                    iteratorURL.setParameter(
057                            StructureDisplayTerms.GROUP_IDS,
058                            StringUtil.merge(displayTerms.getGroupIds()));
059                    iteratorURL.setParameter(
060                            StructureDisplayTerms.NAME, displayTerms.getName());
061                    iteratorURL.setParameter(
062                            StructureDisplayTerms.STRUCTURE_ID, displayTerms.getStructureId());
063            }
064    
065            public StructureSearch(
066                    PortletRequest portletRequest, PortletURL iteratorURL) {
067    
068                    this(portletRequest, DEFAULT_DELTA, iteratorURL);
069            }
070    
071    }