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.dynamicdatamapping.search;
016    
017    import com.liferay.portal.kernel.dao.search.SearchContainer;
018    import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
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 StructureSearch extends SearchContainer<DDMStructure> {
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("class-name-id");
040                    headerNames.add("storage-type");
041                    headerNames.add("modified-date");
042            }
043    
044            public static final String EMPTY_RESULTS_MESSAGE = "there-are-no-results";
045    
046            public StructureSearch(
047                    PortletRequest portletRequest, PortletURL iteratorURL) {
048    
049                    super(
050                            portletRequest, new StructureDisplayTerms(portletRequest),
051                            new StructureSearchTerms(portletRequest), DEFAULT_CUR_PARAM,
052                            DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);
053    
054                    StructureDisplayTerms displayTerms =
055                            (StructureDisplayTerms)getDisplayTerms();
056    
057                    iteratorURL.setParameter(
058                            StructureDisplayTerms.CLASS_NAME_ID,
059                            String.valueOf(displayTerms.getClassNameId()));
060                    iteratorURL.setParameter(
061                            StructureDisplayTerms.DESCRIPTION, displayTerms.getDescription());
062                    iteratorURL.setParameter(
063                            StructureDisplayTerms.NAME, displayTerms.getName());
064                    iteratorURL.setParameter(
065                            StructureDisplayTerms.STORAGE_TYPE, displayTerms.getStorageType());
066            }
067    
068    }