View Javadoc
1   /*******************************************************************************
2    *   Gisgraphy Project 
3    * 
4    *   This library is free software; you can redistribute it and/or
5    *   modify it under the terms of the GNU Lesser General Public
6    *   License as published by the Free Software Foundation; either
7    *   version 2.1 of the License, or (at your option) any later version.
8    * 
9    *   This library is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   *   Lesser General Public License for more details.
13   * 
14   *   You should have received a copy of the GNU Lesser General Public
15   *   License along with this library; if not, write to the Free Software
16   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
17   * 
18   *  Copyright 2008  Gisgraphy project 
19   *  David Masclet <davidmasclet@gisgraphy.com>
20   *  
21   *  
22   *******************************************************************************/
23  package com.gisgraphy.webapp.action;
24  
25  import java.util.ArrayList;
26  import java.util.Collections;
27  import java.util.List;
28  
29  import com.gisgraphy.domain.valueobject.FeatureCode;
30  import com.gisgraphy.domain.valueobject.Pagination;
31  import com.opensymphony.xwork2.ActionSupport;
32  
33  /**
34   * base class for Gisgraphy search Action
35   * 
36   * @author <a href="mailto:david.masclet@gisgraphy.com">David Masclet</a>
37   */
38  public class SearchAction extends ActionSupport {
39  
40      protected final static String POPUP_VIEW = "popup";
41  
42      /**
43       * 
44       */
45      private static final long serialVersionUID = -9018894533914543310L;
46  
47      private boolean advancedSearch;
48  
49      private int from = Pagination.DEFAULT_FROM;
50  
51      private int to = Pagination.DEFAULT_MAX_RESULTS;
52  
53      private String format;
54  
55      private boolean indent;
56  
57      public static final int DEFAULT_NUMBER_OF_RESULTS_PER_PAGE = 10;
58  
59      /**
60       * The error message in case of exception
61       */
62      protected String errorMessage = "";
63  
64      /**
65       * @param from
66       *                the from to set
67       */
68      public void setFrom(int from) {
69  	this.from = from;
70      }
71  
72      /**
73       * @param to
74       *                the to to set
75       */
76      public void setTo(int to) {
77  	this.to = to;
78      }
79  
80      /**
81       * @param format
82       *                the format to set
83       */
84      public void setFormat(String format) {
85  	this.format = format;
86      }
87  
88      /**
89       * @param indent
90       *                the indent to set
91       */
92      public void setIndent(boolean indent) {
93  	this.indent = indent;
94      }
95  
96      /**
97       * @return the available placetypes
98       */
99      public List<String> getPlacetypes() {
100 	List<String> sort = new ArrayList<String>(FeatureCode.entityClass
101 		.keySet());
102 	Collections.sort(sort);
103 	return sort;
104     }
105 
106     /**
107      * @return the advancedSearch
108      */
109     public boolean isAdvancedSearch() {
110 	return advancedSearch;
111     }
112 
113     /**
114      * @param advancedSearch
115      *                the advancedSearch to set
116      */
117     public void setAdvancedSearch(boolean advancedSearch) {
118 	this.advancedSearch = advancedSearch;
119     }
120 
121     /**
122      * @return the from
123      */
124     public int getFrom() {
125 	return from;
126     }
127 
128     /**
129      * @return the to
130      */
131     public int getTo() {
132 	return to;
133     }
134 
135     /**
136      * @return the format
137      */
138     public String getFormat() {
139 	return format;
140     }
141 
142     /**
143      * @return the indent
144      */
145     public boolean isIndent() {
146 	return indent;
147     }
148 
149     /**
150      * @return the errorMessage
151      */
152     public String getErrorMessage() {
153 	return errorMessage;
154     }
155 
156     /**
157      * @return the dEFAULT_NUMBER_OF_RESULTS_PER_PAGE
158      */
159     public int getDefaultNumberOfResultsPerPage() {
160 	return DEFAULT_NUMBER_OF_RESULTS_PER_PAGE;
161     }
162 
163 }