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.domain.repository;
24  
25  import java.util.List;
26  
27  import com.gisgraphy.domain.geoloc.entity.GisFeature;
28  import com.gisgraphy.domain.valueobject.GisFeatureDistance;
29  import com.vividsolutions.jts.geom.Point;
30  
31  /**
32   * Interface of data access object for {@link GisFeature}
33   * 
34   * @author <a href="mailto:david.masclet@gisgraphy.com">David Masclet</a>
35   */
36  public interface IGisFeatureDao extends IGisDao<GisFeature> {
37  
38      /**
39       * Do a full text search for the given name. The search will be case,
40       * iso-latin, comma-separated insensitive<br>
41       * search for 'saint-André', 'saint-Andre', 'SaInT-andré', 'st-andré', etc
42       * will return the same results. The search is done for all type,
43       * independentely of the type
44       * 
45       * @param name
46       *                the name or zipcode of the GisFeature to search
47       * @param includeAlternateNames
48       *                whether we search in the alternatenames and names
49       * @return a list of gisFeatures of type of the class for the given text.
50       *         the max list size is {@link GenericGisDao#MAX_FULLTEXT_RESULTS};
51       * @see IGisDao#listFromText(String, boolean)
52       */
53      public List<GisFeature> listAllFeaturesFromText(String name,
54  	    boolean includeAlternateNames);
55  
56      /**
57       * <u>tips</u> to search the nearestplace use firstresult=1 and
58       * maxResults=1
59       * 
60       * @param gisFeature
61       *                The GisFeature from which we want to find GIS Object
62       * @param distance
63       *                distance The radius in meters
64       * @param firstResult
65       *                the firstResult index (for pagination), numbered from 1,
66       *                if < 1 : it will not be taken into account
67       * @param maxResults
68       *                The Maximum number of results to retrieve (for
69       *                pagination), if <= 0 : it will not be taken into acount
70       * @param requiredClass
71       *                the class of the object to be retireved
72       * @param isMunicipality whether we should filter on city that are flag as 'municipality'.
73  						act as a filter, if false it doesn't filters( false doesn't mean that we return non municipality)
74       * @return A List of GisFeatureDistance with the nearest elements or an
75       *         emptylist (never return null), ordered by distance.<u>note</u>
76       *         the specified gisFeature will not be included into results
77       * @see GisFeatureDistance
78       */
79      public List<GisFeatureDistance> getNearestAndDistanceFromGisFeature(
80  	    final GisFeature gisFeature, final double distance,
81  	    final int firstResult, final int maxResults,
82  	    boolean includeDistanceField,
83  	    final Class<? extends GisFeature> requiredClass, boolean isMunicipality);
84  
85      /**
86       * 
87       * @param gisFeature
88       *                The GisFeature from which we want to find GIS Object
89       * @param distance
90       *                distance The radius in meters
91       * @param requiredClass
92       *                the class of the object to be retireved
93       * @return A List of GisFeatureDistance with the nearest elements or an
94       *         emptylist (never return null), ordered by distance.<u>note</u>
95       *         the specified gisFeature will not be included into results
96       * @see GisFeatureDistance
97       */
98      public List<GisFeatureDistance> getNearestAndDistanceFromGisFeature(
99  	    final GisFeature gisFeature, final double distance,
100 	    boolean includeDistanceField,
101 	    final Class<? extends GisFeature> requiredClass);
102 
103     /**
104      * <u>tips</u> to search the nearestplace use firstresult=1 and
105      * maxResults=1
106      * 
107      * @param point
108      *                The point from which we want to find GIS Object
109      * @param distance
110      *                distance The radius in meters
111      * @param firstResult
112      *                the firstResult index (for pagination), numbered from 1,
113      *                if < 1 : it will not be taken into account
114      * @param maxResults
115      *                The Maximum number of results to retrieve (for
116      *                pagination), if <= 0 : it will not be taken into acount
117      * @param requiredClass
118      *                the class of the object to be retireved
119      * @return A List of GisFeatureDistance with the nearest elements or an
120      *         emptylist (never return null), ordered by distance.<u>note</u>
121      *         the specified gisFeature will not be included into results
122      * @see GisFeatureDistance
123      */
124     public List<GisFeatureDistance> getNearestAndDistanceFrom(
125 	    final Point point, final double distance, final int firstResult,
126 	    final int maxResults,
127 	    final boolean includeDistanceField,
128 	    final Class<? extends GisFeature> requiredClass);
129 
130     /**
131      * 
132      * @param point
133      *                The point from which we want to find GIS Object
134      * @param distance
135      *                distance The radius in meters
136      * @param requiredClass
137      *                the class of the object to be retireved
138      * @return A List of GisFeatureDistance with the nearest elements or an
139      *         emptylist (never return null), ordered by distance.<u>note</u>
140      *         the specified gisFeature will not be included into results
141      * @see GisFeatureDistance
142      */
143     public List<GisFeatureDistance> getNearestAndDistanceFrom(
144 	    final Point point, final double distance,
145 	    final boolean includeDistanceField,
146 	    final Class<? extends GisFeature> requiredClass);
147 
148     /**
149      * Delete all gisFeatures and subclass except Adms and countries (gisFeature
150      * with null featureCode will be deleted too). this method is usefull when
151      * gisFeature 'belongs' to some adms and we want to delete the gisfeature
152      * first and then the adms and countries. We don't control the fact that
153      * adms should be delete after all gisFeature due to Primary /foreign key
154      * with {@linkplain GenericGisDao#deleteAll()}
155      * 
156      * @return the number of deleted elements
157      */
158     public int deleteAllExceptAdmsAndCountries();
159     
160     /**
161      * @return the highest featureId (independant from the placetype) 
162      */
163     public long getMaxFeatureId();
164 
165 }