gvsig-projects-pool / org.gvsig.busquedacatastral / trunk / org.gvsig.busquedacatastral / org.gvsig.busquedacatastral.lib / org.gvsig.busquedacatastral.lib.impl / src / main / java / org / gvsig / busquedacatastral / lib / impl / DefaultBusquedaCatastralManager.java @ 435
History | View | Annotate | Download (6.49 KB)
1 |
/* gvSIG. Desktop Geographic Information System.
|
---|---|
2 |
*
|
3 |
* Copyright ? 2007-2016 gvSIG Association
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
18 |
* MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.busquedacatastral.lib.impl; |
24 |
|
25 |
import java.io.File; |
26 |
import java.util.ArrayList; |
27 |
import java.util.Arrays; |
28 |
import java.util.List; |
29 |
|
30 |
import org.gvsig.busquedacatastral.lib.api.BusquedaCatastralManager; |
31 |
import org.gvsig.busquedacatastral.lib.api.QueryCatastral; |
32 |
import org.gvsig.busquedacatastral.lib.api.ReferenciaCatastral; |
33 |
import org.gvsig.busquedacatastral.lib.api.SRSCatastro; |
34 |
import org.gvsig.busquedacatastral.lib.api.TipoVia; |
35 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralException; |
36 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingDataException; |
37 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException; |
38 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralInvalidSRSException; |
39 |
import org.gvsig.fmap.geom.primitive.Point; |
40 |
import org.gvsig.tools.dynobject.DynObject; |
41 |
|
42 |
import org.slf4j.Logger; |
43 |
import org.slf4j.LoggerFactory; |
44 |
|
45 |
|
46 |
/**
|
47 |
* Busqueda catastral manager
|
48 |
*
|
49 |
*/
|
50 |
public class DefaultBusquedaCatastralManager implements BusquedaCatastralManager{ |
51 |
|
52 |
private static final Logger logger = LoggerFactory |
53 |
.getLogger(DefaultBusquedaCatastralManager.class); |
54 |
|
55 |
private ProvinciasFactory provinciasFactory=null; |
56 |
private MunicipiosFactory municipiosFactory=null; |
57 |
private ViasFactory viasFactory=null; |
58 |
private NumerosFactory numerosFactory=null; |
59 |
private ReferenciasCatastralesFactory referenciasCatastralesFactory=null; |
60 |
private PointFactory pointFactory=null; |
61 |
private File cacheFolder; |
62 |
|
63 |
@Override
|
64 |
public void deleteCache() { |
65 |
deleteFolder(cacheFolder); |
66 |
} |
67 |
|
68 |
private static void deleteFolder(File folder) { |
69 |
File[] files = folder.listFiles(); |
70 |
if(files!=null) { //some JVMs return null for empty dirs |
71 |
for(File f: files) { |
72 |
if(f.isDirectory()) {
|
73 |
deleteFolder(f); |
74 |
} else {
|
75 |
f.delete(); |
76 |
} |
77 |
} |
78 |
} |
79 |
folder.delete(); |
80 |
} |
81 |
|
82 |
@Override
|
83 |
public QueryCatastral createQuery() {
|
84 |
return new QueryCatastralImpl(); |
85 |
} |
86 |
|
87 |
|
88 |
|
89 |
@Override
|
90 |
public List<DynObject> getProvincias() |
91 |
throws BusquedaCatastralException {
|
92 |
if (provinciasFactory==null){ |
93 |
provinciasFactory=new ProvinciasFactory(this); |
94 |
} |
95 |
return provinciasFactory.getProvincias();
|
96 |
} |
97 |
|
98 |
|
99 |
|
100 |
@Override
|
101 |
public List<DynObject> getMunicipios(QueryCatastral query) |
102 |
throws BusquedaCatastralException {
|
103 |
if (municipiosFactory==null){ |
104 |
municipiosFactory=new MunicipiosFactory(this); |
105 |
} |
106 |
return municipiosFactory.getMunicipios(query);
|
107 |
} |
108 |
|
109 |
|
110 |
|
111 |
@Override
|
112 |
public List<DynObject> getMunicipios(QueryCatastral query, String municipio) |
113 |
throws BusquedaCatastralException {
|
114 |
if (municipiosFactory==null){ |
115 |
municipiosFactory=new MunicipiosFactory(this); |
116 |
} |
117 |
return municipiosFactory.getMunicipios(query, municipio);
|
118 |
} |
119 |
|
120 |
|
121 |
|
122 |
@Override
|
123 |
public List<TipoVia> getTiposDeVia() |
124 |
throws BusquedaCatastralException {
|
125 |
List<TipoVia> tipoVias=new ArrayList<TipoVia>(Arrays.asList(TipoVia.values())); |
126 |
return tipoVias;
|
127 |
} |
128 |
|
129 |
|
130 |
|
131 |
@Override
|
132 |
public List<DynObject> getVias(QueryCatastral query) |
133 |
throws BusquedaCatastralException {
|
134 |
if (viasFactory==null){ |
135 |
viasFactory=new ViasFactory(this); |
136 |
} |
137 |
return viasFactory.getVias(query);
|
138 |
} |
139 |
|
140 |
|
141 |
|
142 |
@Override
|
143 |
public List<DynObject> getVias(QueryCatastral query, String via) |
144 |
throws BusquedaCatastralException {
|
145 |
if (viasFactory==null){ |
146 |
viasFactory=new ViasFactory(this); |
147 |
} |
148 |
return viasFactory.getVias(query, via);
|
149 |
} |
150 |
|
151 |
|
152 |
|
153 |
@Override
|
154 |
public List<String> getNumeros(QueryCatastral query, String inicio, |
155 |
String fin) throws BusquedaCatastralException { |
156 |
if (numerosFactory==null){ |
157 |
numerosFactory=new NumerosFactory(this); |
158 |
} |
159 |
return numerosFactory.getNumeros(query, inicio, fin);
|
160 |
} |
161 |
|
162 |
|
163 |
|
164 |
@Override
|
165 |
public List<ReferenciaCatastral> getReferenciasCatastrales( |
166 |
QueryCatastral query) throws BusquedaCatastralException {
|
167 |
if (referenciasCatastralesFactory==null){ |
168 |
referenciasCatastralesFactory=new ReferenciasCatastralesFactory(this); |
169 |
} |
170 |
return referenciasCatastralesFactory.getReferencias(query);
|
171 |
} |
172 |
|
173 |
|
174 |
|
175 |
@Override
|
176 |
public Point getPoint(String referenciacatastral, SRSCatastro srs) |
177 |
throws BusquedaCatastralException,
|
178 |
BusquedaCatastralInvalidSRSException { |
179 |
if (pointFactory==null){ |
180 |
pointFactory=new PointFactory();
|
181 |
} |
182 |
return pointFactory.getPoint(referenciacatastral, srs);
|
183 |
} |
184 |
|
185 |
|
186 |
|
187 |
@Override
|
188 |
public Point getPoint(ReferenciaCatastral referenciacatastral, |
189 |
SRSCatastro srs) throws BusquedaCatastralException {
|
190 |
if (pointFactory==null){ |
191 |
pointFactory=new PointFactory();
|
192 |
} |
193 |
return pointFactory.getPoint(referenciacatastral, srs);
|
194 |
} |
195 |
|
196 |
|
197 |
|
198 |
@Override
|
199 |
public DynObject getDatosCatastrales(Point p, SRSCatastro srs) |
200 |
throws BusquedaCatastralException,
|
201 |
BusquedaCatastralInvalidSRSException { |
202 |
throw new UnsupportedOperationException("Not supported yet."); |
203 |
} |
204 |
|
205 |
|
206 |
|
207 |
@Override
|
208 |
public DynObject getDatosCatastrales(String rc) |
209 |
throws BusquedaCatastralException {
|
210 |
throw new UnsupportedOperationException("Not supported yet."); |
211 |
} |
212 |
|
213 |
public File getCacheFolder(){ |
214 |
return this.cacheFolder; |
215 |
} |
216 |
|
217 |
public void setCacheFolder(File cacheFolder){ |
218 |
this.cacheFolder=cacheFolder;
|
219 |
} |
220 |
} |