Revision 9052
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.179/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/java/org/gvsig/busquedacatastral/lib/impl/Main.java | ||
---|---|---|
1 |
package org.gvsig.busquedacatastral.lib.impl; |
|
2 |
import java.io.ByteArrayInputStream; |
|
3 |
import java.io.InputStream; |
|
4 |
import java.rmi.RemoteException; |
|
5 |
|
|
6 |
import javax.xml.bind.JAXBContext; |
|
7 |
import javax.xml.bind.JAXBException; |
|
8 |
import javax.xml.bind.Unmarshaller; |
|
9 |
import javax.xml.rpc.ServiceException; |
|
10 |
|
|
11 |
import org.apache.axis.message.MessageElement; |
|
12 |
import org.gvsig.busquedacatastral.lib.impl.ws.CallejeroCatastroWSLocator; |
|
13 |
import org.gvsig.busquedacatastral.lib.impl.ws.CallejeroCatastroWSSoap; |
|
14 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.MunicipiosWSResponse; |
|
15 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.ProvinciasWSResponse; |
|
16 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaMunicipieror; |
|
17 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaProvincieror; |
|
18 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ObjectFactory; |
|
19 |
|
|
20 |
|
|
21 |
/* |
|
22 |
* Copyright 2016 DiSiD Technologies S.L.L. All rights reserved. |
|
23 |
* |
|
24 |
* Project : DiSiD WebServiceProject |
|
25 |
* SVN Id : $Id$ |
|
26 |
*/ |
|
27 |
|
|
28 |
public class Main { |
|
29 |
|
|
30 |
public static void main(String[] args) { |
|
31 |
try { |
|
32 |
CallejeroCatastroWSLocator locator= |
|
33 |
new CallejeroCatastroWSLocator(); |
|
34 |
CallejeroCatastroWSSoap callejeroWS = |
|
35 |
locator.getCallejeroCatastroSoap(); |
|
36 |
ProvinciasWSResponse provincias = callejeroWS.obtenerProvincias(); |
|
37 |
|
|
38 |
ObjectFactory objfactory=new ObjectFactory(); |
|
39 |
if (provincias!=null){ |
|
40 |
MessageElement[] any = provincias.get_any(); |
|
41 |
MessageElement me=any[0]; |
|
42 |
JAXBContext jaxbContext = JAXBContext.newInstance(ConsultaProvincieror.class); |
|
43 |
|
|
44 |
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); |
|
45 |
InputStream input = new ByteArrayInputStream(me.getAsString().getBytes()); |
|
46 |
ConsultaProvincieror cp = (ConsultaProvincieror) jaxbUnmarshaller.unmarshal(input); |
|
47 |
cp.getProvinciero(); |
|
48 |
} |
|
49 |
MunicipiosWSResponse municipios = callejeroWS.obtenerMunicipios("VALENCIA", ""); |
|
50 |
if (municipios!=null){ |
|
51 |
MessageElement[] any = municipios.get_any(); |
|
52 |
MessageElement me=any[0]; |
|
53 |
JAXBContext jaxbContext = JAXBContext.newInstance(ConsultaMunicipieror.class); |
|
54 |
|
|
55 |
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); |
|
56 |
InputStream input = new ByteArrayInputStream(me.getAsString().getBytes()); |
|
57 |
ConsultaMunicipieror cm = (ConsultaMunicipieror) jaxbUnmarshaller.unmarshal(input); |
|
58 |
cm.getMunicipiero(); |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
} catch (ServiceException e) { |
|
63 |
// TODO Auto-generated catch block |
|
64 |
e.printStackTrace(); |
|
65 |
} catch (RemoteException e) { |
|
66 |
// TODO Auto-generated catch block |
|
67 |
e.printStackTrace(); |
|
68 |
} catch (JAXBException e) { |
|
69 |
// TODO Auto-generated catch block |
|
70 |
e.printStackTrace(); |
|
71 |
} catch (Exception e) { |
|
72 |
// TODO Auto-generated catch block |
|
73 |
e.printStackTrace(); |
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
} |
|
79 |
|
|
80 |
} |
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.179/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/java/org/gvsig/busquedacatastral/lib/impl/ProvinciasFactory.java | ||
---|---|---|
1 |
package org.gvsig.busquedacatastral.lib.impl; |
|
2 |
|
|
3 |
import java.io.ByteArrayInputStream; |
|
4 |
import java.io.File; |
|
5 |
import java.io.IOException; |
|
6 |
import java.io.InputStream; |
|
7 |
import java.rmi.RemoteException; |
|
8 |
import java.util.List; |
|
9 |
|
|
10 |
import javax.xml.bind.JAXBContext; |
|
11 |
import javax.xml.bind.Unmarshaller; |
|
12 |
|
|
13 |
import org.apache.axis.message.MessageElement; |
|
14 |
import org.apache.commons.lang3.StringUtils; |
|
15 |
|
|
16 |
import org.gvsig.busquedacatastral.lib.api.BusquedaCatastralManager; |
|
17 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralException; |
|
18 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException; |
|
19 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralRemoteServiceException; |
|
20 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.ProvinciasWSResponse; |
|
21 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaProvincieror; |
|
22 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Err; |
|
23 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Prov; |
|
24 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Provinciero; |
|
25 |
import org.gvsig.fmap.dal.DataTypes; |
|
26 |
import org.gvsig.fmap.dal.exception.DataException; |
|
27 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
28 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
29 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
30 |
import org.gvsig.tools.ToolsLocator; |
|
31 |
import org.gvsig.tools.dynobject.DynObject; |
|
32 |
import org.gvsig.tools.exception.BaseException; |
|
33 |
import org.gvsig.tools.i18n.I18nManager; |
|
34 |
|
|
35 |
import org.slf4j.Logger; |
|
36 |
import org.slf4j.LoggerFactory; |
|
37 |
|
|
38 |
public class ProvinciasFactory extends WSObjectsFactory{ |
|
39 |
|
|
40 |
private static final Logger logger = LoggerFactory |
|
41 |
.getLogger(ProvinciasFactory.class); |
|
42 |
|
|
43 |
private final static String PROVINCIAS_FILENAME="provincias.dbf"; |
|
44 |
|
|
45 |
|
|
46 |
public ProvinciasFactory(BusquedaCatastralManager manager){ |
|
47 |
super(manager); |
|
48 |
} |
|
49 |
|
|
50 |
private Provinciero provinciero=null; |
|
51 |
public List<DynObject> getProvincias() throws BusquedaCatastralException{ |
|
52 |
//TODO |
|
53 |
//1.-Ver si existe fichero en tmp |
|
54 |
//2.- Si no existe |
|
55 |
// 2.1.- consulta web para obtener provinciero |
|
56 |
// 2.2.- generar archivo a partir de provinciero |
|
57 |
//3.-Leer fichero con listado de provincias |
|
58 |
// 3.1.- Por cada registro en provincia, construir un DynObject |
|
59 |
//4.-Devolver listado de DynObject |
|
60 |
|
|
61 |
File provinciasFile=null; |
|
62 |
|
|
63 |
try { |
|
64 |
provinciasFile = new File(manager.getCacheFolder(),PROVINCIAS_FILENAME); |
|
65 |
if (!provinciasFile.exists()){ |
|
66 |
createDBF(provinciasFile); |
|
67 |
} |
|
68 |
return this.getListFromDBF(provinciasFile); |
|
69 |
} catch ( BusquedaCatastralException e) { |
|
70 |
throw e; |
|
71 |
} catch ( Exception e) { |
|
72 |
logger.warn("Error getting provincias from file '"+provinciasFile.getAbsolutePath()+"'.",e); |
|
73 |
throw new BusquedaCatastralGettingParamsException(e); |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
|
|
78 |
@Override |
|
79 |
protected void defineType(EditableFeatureType type) throws BusquedaCatastralException { |
|
80 |
provinciero=getProvinciero(); |
|
81 |
int maxNombre=0; |
|
82 |
int maxCodigo=0; |
|
83 |
for(Prov prov:provinciero.getProv()){ |
|
84 |
if(StringUtils.isNotEmpty(prov.getNp()) && prov.getNp().length()>maxNombre){ |
|
85 |
maxNombre=prov.getNp().length(); |
|
86 |
} |
|
87 |
if(StringUtils.isNotEmpty(prov.getCpine()) && prov.getCpine().length()>maxCodigo){ |
|
88 |
maxCodigo=prov.getCpine().length(); |
|
89 |
} |
|
90 |
} |
|
91 |
type.add(BusquedaCatastralManager.CAMPO_PROVINCIA_NOMBRE, DataTypes.STRING, |
|
92 |
maxNombre); |
|
93 |
type.add(BusquedaCatastralManager.CAMPO_PROVINCIA_CODIGO, DataTypes.STRING, |
|
94 |
maxCodigo); |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
protected void writeFileData(FeatureStore featureStore) throws DataException, BusquedaCatastralException { |
|
99 |
provinciero=getProvinciero(); |
|
100 |
for(Prov prov:provinciero.getProv()){ |
|
101 |
EditableFeature ef; |
|
102 |
ef = featureStore.createNewFeature().getEditable(); |
|
103 |
ef.set(BusquedaCatastralManager.CAMPO_PROVINCIA_NOMBRE, prov.getNp()); |
|
104 |
ef.set(BusquedaCatastralManager.CAMPO_PROVINCIA_CODIGO, prov.getCpine()); |
|
105 |
featureStore.insert(ef); |
|
106 |
} |
|
107 |
provinciero = null; |
|
108 |
} |
|
109 |
|
|
110 |
private Provinciero getProvinciero() throws BusquedaCatastralException{ |
|
111 |
if( provinciero == null ) { |
|
112 |
try { |
|
113 |
ProvinciasWSResponse provincias = getCatastroWS().obtenerProvincias(); |
|
114 |
if (provincias!=null){ |
|
115 |
MessageElement[] any = provincias.get_any(); |
|
116 |
MessageElement me=any[0]; |
|
117 |
JAXBContext jaxbContext = JAXBContext.newInstance(ConsultaProvincieror.class); |
|
118 |
|
|
119 |
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); |
|
120 |
InputStream input = new ByteArrayInputStream(me.getAsString().getBytes()); |
|
121 |
ConsultaProvincieror cp = (ConsultaProvincieror) jaxbUnmarshaller.unmarshal(input); |
|
122 |
|
|
123 |
if (cp!=null && cp.getLerr()!=null){ |
|
124 |
webserviceErrors(cp.getLerr().getErr()); |
|
125 |
} |
|
126 |
|
|
127 |
provinciero = cp.getProvinciero(); |
|
128 |
}else{ |
|
129 |
logger.error("Webservice response is empty"); |
|
130 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
131 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"),null); |
|
132 |
} |
|
133 |
|
|
134 |
} catch (BusquedaCatastralRemoteServiceException e) { |
|
135 |
logger.error("Error accesing webservice",e); |
|
136 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
137 |
throw e; |
|
138 |
} catch (RemoteException e) { |
|
139 |
logger.error("Error marshalling response from webservice",e); |
|
140 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
141 |
throw new BusquedaCatastralRemoteServiceException(i18nManager.getTranslation("_error_reading_response_from_ws"), e); |
|
142 |
} catch (Exception e) { |
|
143 |
logger.error("Error marshalling response from webservice",e); |
|
144 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
145 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"), e); |
|
146 |
} |
|
147 |
} |
|
148 |
return provinciero; |
|
149 |
} |
|
150 |
|
|
151 |
|
|
152 |
@Override |
|
153 |
protected String getExpressionQuery() { |
|
154 |
return null; |
|
155 |
} |
|
156 |
|
|
157 |
|
|
158 |
} |
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.179/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/java/org/gvsig/busquedacatastral/lib/impl/ReferenciasCatastralesFactory.java | ||
---|---|---|
1 |
package org.gvsig.busquedacatastral.lib.impl; |
|
2 |
|
|
3 |
import java.io.ByteArrayInputStream; |
|
4 |
import java.io.InputStream; |
|
5 |
import java.rmi.RemoteException; |
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.HashSet; |
|
8 |
import java.util.List; |
|
9 |
import java.util.Set; |
|
10 |
|
|
11 |
import javax.xml.bind.JAXBContext; |
|
12 |
import javax.xml.bind.Unmarshaller; |
|
13 |
|
|
14 |
import org.apache.axis.message.MessageElement; |
|
15 |
import org.apache.commons.lang3.StringUtils; |
|
16 |
|
|
17 |
import org.gvsig.busquedacatastral.lib.api.BusquedaCatastralManager; |
|
18 |
import org.gvsig.busquedacatastral.lib.api.QueryCatastral; |
|
19 |
import org.gvsig.busquedacatastral.lib.api.QueryCatastral.TipoParcela; |
|
20 |
import org.gvsig.busquedacatastral.lib.api.QueryCatastral.TipoQuery; |
|
21 |
import org.gvsig.busquedacatastral.lib.api.ReferenciaCatastral; |
|
22 |
import org.gvsig.busquedacatastral.lib.api.TipoVia; |
|
23 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralException; |
|
24 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException; |
|
25 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralRemoteServiceException; |
|
26 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.ConsultaDNPPPWSResponse; |
|
27 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.ConsultaDNPWSResponse; |
|
28 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Bico; |
|
29 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaDnp; |
|
30 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Dt; |
|
31 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Lors; |
|
32 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Lorus; |
|
33 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Lourb; |
|
34 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Lous; |
|
35 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Lrcdnp; |
|
36 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Rc; |
|
37 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Rcdnp; |
|
38 |
import org.gvsig.fmap.dal.exception.DataException; |
|
39 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
40 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
41 |
import org.gvsig.tools.ToolsLocator; |
|
42 |
import org.gvsig.tools.dynobject.DynObject; |
|
43 |
import org.gvsig.tools.i18n.I18nManager; |
|
44 |
|
|
45 |
import org.slf4j.Logger; |
|
46 |
import org.slf4j.LoggerFactory; |
|
47 |
|
|
48 |
public class ReferenciasCatastralesFactory extends WSObjectsFactory{ |
|
49 |
|
|
50 |
private static final Logger logger = LoggerFactory |
|
51 |
.getLogger(ReferenciasCatastralesFactory.class); |
|
52 |
|
|
53 |
|
|
54 |
public ReferenciasCatastralesFactory(BusquedaCatastralManager manager){ |
|
55 |
super(manager); |
|
56 |
} |
|
57 |
|
|
58 |
|
|
59 |
public List<ReferenciaCatastral> getReferencias(QueryCatastral query) throws BusquedaCatastralException{ |
|
60 |
ConsultaDnp consultaDatosNoPrivados=null; |
|
61 |
|
|
62 |
if (query==null){ |
|
63 |
logger.error("Query no valida"); |
|
64 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
65 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_invalid_query"), null); |
|
66 |
}else{ |
|
67 |
if ( TipoQuery.POR_RC.equals(query.getTipoQuery()) ){ |
|
68 |
consultaDatosNoPrivados =getReferenciasByRC(query.getReferenciaCatastral()); |
|
69 |
}else if( TipoQuery.POR_LOCALIZACION.equals(query.getTipoQuery()) ){ |
|
70 |
if (TipoParcela.URBANA.equals(query.getTipoParcela())){ |
|
71 |
consultaDatosNoPrivados =getReferenciasUrbanas(query); |
|
72 |
}else if (TipoParcela.RUSTICA.equals(query.getTipoParcela())){ |
|
73 |
consultaDatosNoPrivados =getReferenciasRusticas(query); |
|
74 |
}else{ |
|
75 |
logger.error("Tipo parcela invalido"); |
|
76 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
77 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_tipo_parcela_not_informed"), null); |
|
78 |
} |
|
79 |
} else{ |
|
80 |
logger.error("Tipo query invalido"); |
|
81 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
82 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_tipo_query_not_informed"), null); |
|
83 |
} |
|
84 |
|
|
85 |
if (consultaDatosNoPrivados!=null && consultaDatosNoPrivados.getLerr()!=null){ |
|
86 |
webserviceErrors(consultaDatosNoPrivados.getLerr().getErr()); |
|
87 |
} |
|
88 |
|
|
89 |
return new ArrayList( createReferenciasCatastrales( consultaDatosNoPrivados) ); |
|
90 |
|
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
private Set<ReferenciaCatastral> createReferenciasCatastrales(ConsultaDnp consultaDatosNoPrivados){ |
|
95 |
Set<ReferenciaCatastral> results=new HashSet<ReferenciaCatastral>(); |
|
96 |
if ( consultaDatosNoPrivados.getLrcdnp()!=null ){ |
|
97 |
getReferenciasCatastralesFrom(consultaDatosNoPrivados.getLrcdnp()); |
|
98 |
results.addAll( getReferenciasCatastralesFrom(consultaDatosNoPrivados.getLrcdnp()) ); |
|
99 |
} |
|
100 |
if ( consultaDatosNoPrivados.getBico()!=null ){ |
|
101 |
DefaultReferenciaCatastral refCatastral=getReferenciaCatastralFrom(consultaDatosNoPrivados.getBico()); |
|
102 |
if (refCatastral!=null){ |
|
103 |
results.add(refCatastral); |
|
104 |
} |
|
105 |
} |
|
106 |
return results; |
|
107 |
} |
|
108 |
|
|
109 |
private DefaultReferenciaCatastral getReferenciaCatastralFrom(Bico bico){ |
|
110 |
if ( bico!=null ){ |
|
111 |
DefaultReferenciaCatastral refCatastral=new DefaultReferenciaCatastral(); |
|
112 |
if (bico.getBi()!=null){ |
|
113 |
if( bico.getBi().getIdbi()!=null ){ |
|
114 |
fillReferenciaCatastralFrom(bico.getBi().getIdbi().getRc(), refCatastral); |
|
115 |
} |
|
116 |
if ( bico.getBi().getDt()!=null ){ |
|
117 |
fillReferenciaCatastralFrom(bico.getBi().getDt(), refCatastral); |
|
118 |
} |
|
119 |
} |
|
120 |
return refCatastral; |
|
121 |
}else{ |
|
122 |
return null; |
|
123 |
} |
|
124 |
} |
|
125 |
|
|
126 |
private Set<ReferenciaCatastral> getReferenciasCatastralesFrom(Lrcdnp lrcdnp){ |
|
127 |
Set<ReferenciaCatastral> results=new HashSet<ReferenciaCatastral>(); |
|
128 |
for ( Rcdnp rcdnp:lrcdnp.getRcdnp()){ |
|
129 |
if(rcdnp!=null){ |
|
130 |
DefaultReferenciaCatastral refCatastral=new DefaultReferenciaCatastral(); |
|
131 |
if (rcdnp.getRc()!=null){ |
|
132 |
fillReferenciaCatastralFrom(rcdnp.getRc(), refCatastral); |
|
133 |
} |
|
134 |
if (rcdnp.getDt()!=null){ |
|
135 |
fillReferenciaCatastralFrom(rcdnp.getDt(), refCatastral); |
|
136 |
} |
|
137 |
results.add(refCatastral); |
|
138 |
} |
|
139 |
} |
|
140 |
return results; |
|
141 |
} |
|
142 |
|
|
143 |
private void fillReferenciaCatastralFrom(Rc rc, DefaultReferenciaCatastral refCatastral){ |
|
144 |
if (rc!=null){ |
|
145 |
refCatastral.setPc1(rc.getPc1()); |
|
146 |
refCatastral.setPc2(rc.getPc2()); |
|
147 |
refCatastral.setCar(rc.getCar()); |
|
148 |
refCatastral.setDc1(rc.getCc1()); |
|
149 |
refCatastral.setDc2(rc.getCc2()); |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
153 |
private void fillReferenciaCatastralFrom(Dt dt, DefaultReferenciaCatastral refCatastral){ |
|
154 |
if (dt!=null){ |
|
155 |
refCatastral.setProvincia(dt.getNp()); |
|
156 |
refCatastral.setMunicipio(dt.getNm()); |
|
157 |
if (dt.getLocs()!=null){ |
|
158 |
if (dt.getLocs().getLous()!=null){ |
|
159 |
Lous lous=dt.getLocs().getLous(); |
|
160 |
if (lous.getLourb()!=null){ |
|
161 |
//Urbana |
|
162 |
Lourb lourb=lous.getLourb(); |
|
163 |
fillReferenciaCatastralFrom(lourb, refCatastral); |
|
164 |
} |
|
165 |
if(lous.getLorus()!=null && lous.getLorus().getCpp()!=null){ |
|
166 |
Lorus lorus=lous.getLorus(); |
|
167 |
fillReferenciaCatastralFrom(lorus, refCatastral);; |
|
168 |
} |
|
169 |
} |
|
170 |
if (dt.getLocs().getLors()!=null){ |
|
171 |
Lors lors=dt.getLocs().getLors(); |
|
172 |
if (lors.getLourb()!=null){ |
|
173 |
//Urbana |
|
174 |
Lourb lourb=lors.getLourb(); |
|
175 |
fillReferenciaCatastralFrom(lourb, refCatastral); |
|
176 |
} |
|
177 |
if(lors.getLorus()!=null && lors.getLorus().getCpp()!=null){ |
|
178 |
Lorus lorus=lors.getLorus(); |
|
179 |
fillReferenciaCatastralFrom(lorus, refCatastral); |
|
180 |
} |
|
181 |
} |
|
182 |
} |
|
183 |
} |
|
184 |
} |
|
185 |
|
|
186 |
private void fillReferenciaCatastralFrom(Lorus lorus, DefaultReferenciaCatastral refCatastral){ |
|
187 |
if(lorus!=null && lorus.getCpp()!=null){ |
|
188 |
refCatastral.setPoligono(lorus.getCpp().getCpo()); |
|
189 |
refCatastral.setParcela(lorus.getCpp().getCpa()); |
|
190 |
refCatastral.setParaje(lorus.getNpa()); |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
194 |
private void fillReferenciaCatastralFrom(Lourb lourb, DefaultReferenciaCatastral refCatastral){ |
|
195 |
if (lourb.getDir()!=null){ |
|
196 |
if (lourb.getDir().getTv()!=null){ |
|
197 |
TipoVia tipoVia=TipoVia.getTipoViaByAbrev(lourb.getDir().getTv()); |
|
198 |
refCatastral.setTipoVia(tipoVia); |
|
199 |
} |
|
200 |
refCatastral.setVia(lourb.getDir().getNv()); |
|
201 |
refCatastral.setPatio(lourb.getDir().getPnp()); |
|
202 |
refCatastral.setKm(lourb.getDir().getKm()); |
|
203 |
if (lourb.getLoint()!=null){ |
|
204 |
refCatastral.setBloque(lourb.getLoint().getBq()); |
|
205 |
refCatastral.setEscalera(lourb.getLoint().getEs()); |
|
206 |
refCatastral.setPlanta(lourb.getLoint().getPt()); |
|
207 |
refCatastral.setPuerta(lourb.getLoint().getPu()); |
|
208 |
} |
|
209 |
} |
|
210 |
} |
|
211 |
|
|
212 |
|
|
213 |
private ConsultaDnp getReferenciasByRC(String rc) throws BusquedaCatastralException{ |
|
214 |
try { |
|
215 |
ConsultaDNPWSResponse dnpResponse = getCatastroWS(). |
|
216 |
consulta_DNPRC("", "", rc); |
|
217 |
if (dnpResponse!=null){ |
|
218 |
MessageElement[] any = dnpResponse.get_any(); |
|
219 |
MessageElement me=any[0]; |
|
220 |
JAXBContext jaxbContext = JAXBContext.newInstance(ConsultaDnp.class); |
|
221 |
|
|
222 |
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); |
|
223 |
InputStream input = new ByteArrayInputStream(me.getAsString().getBytes()); |
|
224 |
ConsultaDnp cdnp = (ConsultaDnp) jaxbUnmarshaller.unmarshal(input); |
|
225 |
|
|
226 |
return cdnp; |
|
227 |
}else{ |
|
228 |
logger.error("Webservice response is empty"); |
|
229 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
230 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"),null); |
|
231 |
} |
|
232 |
|
|
233 |
} catch (RemoteException e) { |
|
234 |
logger.error("Error accesing webservice",e); |
|
235 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
236 |
throw new BusquedaCatastralRemoteServiceException(i18nManager.getTranslation("_error_obtaining_catastro_webservice"), e); |
|
237 |
} catch (Exception e) { |
|
238 |
logger.error("Error marshalling response from webservice",e); |
|
239 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
240 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"), e); |
|
241 |
} |
|
242 |
|
|
243 |
} |
|
244 |
|
|
245 |
private ConsultaDnp getReferenciasUrbanas(QueryCatastral query) throws BusquedaCatastralException{ |
|
246 |
validateQueryUrbana(query); |
|
247 |
try { |
|
248 |
DynObject provincia=query.getProvincia(); |
|
249 |
DynObject municipio=query.getMunicipio(); |
|
250 |
DynObject via=query.getVia(); |
|
251 |
String nombreProvincia=(String) provincia.getDynValue(BusquedaCatastralManager.CAMPO_PROVINCIA_NOMBRE); |
|
252 |
String nombreMunicipio=(String) municipio.getDynValue(BusquedaCatastralManager.CAMPO_MUNICIPIO_NOMBRE); |
|
253 |
String tipoViaAbrev=query.getTipoVia().getAbrev(); |
|
254 |
String nombreVia=(String)via.getDynValue(BusquedaCatastralManager.CAMPO_VIA_NOMBRE); |
|
255 |
|
|
256 |
ConsultaDNPWSResponse dnpResponse = getCatastroWS(). |
|
257 |
consulta_DNPLOC(nombreProvincia, nombreMunicipio, tipoViaAbrev, nombreVia, |
|
258 |
query.getNumero(), query.getBloque(), query.getEscalera(), query.getPlanta(), query.getPuerta()); |
|
259 |
if (dnpResponse!=null){ |
|
260 |
MessageElement[] any = dnpResponse.get_any(); |
|
261 |
MessageElement me=any[0]; |
|
262 |
JAXBContext jaxbContext = JAXBContext.newInstance(ConsultaDnp.class); |
|
263 |
|
|
264 |
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); |
|
265 |
InputStream input = new ByteArrayInputStream(me.getAsString().getBytes()); |
|
266 |
ConsultaDnp cdnp = (ConsultaDnp) jaxbUnmarshaller.unmarshal(input); |
|
267 |
|
|
268 |
return cdnp; |
|
269 |
}else{ |
|
270 |
logger.error("Webservice response is empty"); |
|
271 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
272 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"),null); |
|
273 |
} |
|
274 |
|
|
275 |
} catch (RemoteException e) { |
|
276 |
logger.error("Error accesing webservice",e); |
|
277 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
278 |
throw new BusquedaCatastralRemoteServiceException(i18nManager.getTranslation("_error_obtaining_catastro_webservice"), e); |
|
279 |
} catch (Exception e) { |
|
280 |
logger.error("Error marshalling response from webservice",e); |
|
281 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
282 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"), e); |
|
283 |
} |
|
284 |
} |
|
285 |
|
|
286 |
|
|
287 |
private ConsultaDnp getReferenciasRusticas(QueryCatastral query) throws BusquedaCatastralException{ |
|
288 |
validateQueryRustica(query); |
|
289 |
try { |
|
290 |
DynObject provincia=query.getProvincia(); |
|
291 |
DynObject municipio=query.getMunicipio(); |
|
292 |
String nombreProvincia=(String) provincia.getDynValue(BusquedaCatastralManager.CAMPO_PROVINCIA_NOMBRE); |
|
293 |
String nombreMunicipio=(String) municipio.getDynValue(BusquedaCatastralManager.CAMPO_MUNICIPIO_NOMBRE); |
|
294 |
|
|
295 |
|
|
296 |
ConsultaDNPPPWSResponse dnpResponse = getCatastroWS(). |
|
297 |
consulta_DNPPP(nombreProvincia, nombreMunicipio, query.getPoligono(), query.getParcela()); |
|
298 |
if (dnpResponse!=null){ |
|
299 |
MessageElement[] any = dnpResponse.get_any(); |
|
300 |
MessageElement me=any[0]; |
|
301 |
JAXBContext jaxbContext = JAXBContext.newInstance(ConsultaDnp.class); |
|
302 |
|
|
303 |
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); |
|
304 |
InputStream input = new ByteArrayInputStream(me.getAsString().getBytes()); |
|
305 |
ConsultaDnp cdnp = (ConsultaDnp) jaxbUnmarshaller.unmarshal(input); |
|
306 |
|
|
307 |
return cdnp; |
|
308 |
}else{ |
|
309 |
logger.error("Webservice response is empty"); |
|
310 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
311 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"),null); |
|
312 |
} |
|
313 |
|
|
314 |
} catch (RemoteException e) { |
|
315 |
logger.error("Error accesing webservice",e); |
|
316 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
317 |
throw new BusquedaCatastralRemoteServiceException(i18nManager.getTranslation("_error_obtaining_catastro_webservice"), e); |
|
318 |
} catch (Exception e) { |
|
319 |
logger.error("Error marshalling response from webservice",e); |
|
320 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
321 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"), e); |
|
322 |
} |
|
323 |
} |
|
324 |
|
|
325 |
|
|
326 |
private void validateQueryUrbana(QueryCatastral query) throws BusquedaCatastralException{ |
|
327 |
if (query.getProvincia()==null){ |
|
328 |
logger.error("Provincia no informada"); |
|
329 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
330 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_provincia_not_informed"), null); |
|
331 |
} |
|
332 |
if (query.getMunicipio()==null){ |
|
333 |
logger.error("Municipio no informado"); |
|
334 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
335 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_municipio_not_informed"), null); |
|
336 |
} |
|
337 |
if (query.getTipoVia()==null){ |
|
338 |
logger.error("Tipo Via no informado"); |
|
339 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
340 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_tipo_via_not_informed"), null); |
|
341 |
} |
|
342 |
if (query.getVia()==null){ |
|
343 |
logger.error("Via no informado"); |
|
344 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
345 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_via_not_informed"), null); |
|
346 |
} |
|
347 |
if (query.getNumero()==null){ |
|
348 |
logger.error("Numero no informado"); |
|
349 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
350 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_numero_not_informed"), null); |
|
351 |
} |
|
352 |
} |
|
353 |
|
|
354 |
|
|
355 |
private void validateQueryRustica(QueryCatastral query) throws BusquedaCatastralException{ |
|
356 |
if (query.getProvincia()==null){ |
|
357 |
logger.error("Provincia no informada"); |
|
358 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
359 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_provincia_not_informed"), null); |
|
360 |
} |
|
361 |
if (query.getMunicipio()==null){ |
|
362 |
logger.error("Municipio no informado"); |
|
363 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
364 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_municipio_not_informed"), null); |
|
365 |
} |
|
366 |
if (query.getPoligono()==null){ |
|
367 |
logger.error("Poligono no informado"); |
|
368 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
369 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_poligono_not_informed"), null); |
|
370 |
} |
|
371 |
if (query.getParcela()==null){ |
|
372 |
logger.error("Municipio no informado"); |
|
373 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
374 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_parcela_not_informed"), null); |
|
375 |
} |
|
376 |
} |
|
377 |
|
|
378 |
@Override |
|
379 |
protected void defineType(EditableFeatureType type) |
|
380 |
throws BusquedaCatastralException { |
|
381 |
// Do Nothing |
|
382 |
|
|
383 |
} |
|
384 |
|
|
385 |
@Override |
|
386 |
protected void writeFileData(FeatureStore featureStore) |
|
387 |
throws BusquedaCatastralException, DataException { |
|
388 |
// Do Nothing |
|
389 |
|
|
390 |
} |
|
391 |
|
|
392 |
@Override |
|
393 |
protected String getExpressionQuery() { |
|
394 |
// Do Nothing |
|
395 |
return null; |
|
396 |
} |
|
397 |
|
|
398 |
|
|
399 |
} |
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.179/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/java/org/gvsig/busquedacatastral/lib/impl/QueryCatastralImpl.java | ||
---|---|---|
1 |
package org.gvsig.busquedacatastral.lib.impl; |
|
2 |
|
|
3 |
import org.gvsig.busquedacatastral.lib.api.QueryCatastral; |
|
4 |
import org.gvsig.busquedacatastral.lib.api.TipoVia; |
|
5 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralInvalidQueryException; |
|
6 |
import org.gvsig.tools.ToolsLocator; |
|
7 |
import org.gvsig.tools.dynobject.DynObject; |
|
8 |
import org.gvsig.tools.i18n.I18nManager; |
|
9 |
import org.slf4j.Logger; |
|
10 |
import org.slf4j.LoggerFactory; |
|
11 |
|
|
12 |
|
|
13 |
/** |
|
14 |
* This class implements query catastral |
|
15 |
* @author dmartinezizquierdo |
|
16 |
* |
|
17 |
*/ |
|
18 |
public class QueryCatastralImpl implements QueryCatastral{ |
|
19 |
|
|
20 |
private static final Logger logger = LoggerFactory.getLogger(QueryCatastralImpl.class); |
|
21 |
|
|
22 |
TipoQuery tipoQuery; |
|
23 |
TipoParcela tipoParcela; |
|
24 |
String referenciaCatastral; |
|
25 |
DynObject provincia; |
|
26 |
DynObject municipio; |
|
27 |
TipoVia tipoVia; |
|
28 |
DynObject via; |
|
29 |
String numero; |
|
30 |
String bloque; |
|
31 |
String escalera; |
|
32 |
String planta; |
|
33 |
String puerta; |
|
34 |
String poligono; |
|
35 |
String parcela; |
|
36 |
|
|
37 |
|
|
38 |
@Override |
|
39 |
public void setTipoParcela(TipoParcela tipoParcela) { |
|
40 |
this.tipoParcela=tipoParcela; |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public TipoParcela getTipoParcela() { |
|
45 |
return this.tipoParcela; |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public void setReferenciaCatastral(String referenciaCatastral) { |
|
50 |
this.referenciaCatastral=referenciaCatastral; |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public String getReferenciaCatastral() { |
|
55 |
return referenciaCatastral; |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
public DynObject getProvincia() { |
|
60 |
return provincia; |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
public void setProvincia(DynObject provincia) { |
|
65 |
this.provincia=provincia; |
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public DynObject getMunicipio() { |
|
70 |
return municipio; |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
public void setMunicipio(DynObject municipio) { |
|
75 |
this.municipio=municipio; |
|
76 |
} |
|
77 |
|
|
78 |
@Override |
|
79 |
public TipoVia getTipoVia() { |
|
80 |
return tipoVia; |
|
81 |
} |
|
82 |
|
|
83 |
@Override |
|
84 |
public void setTipoVia(TipoVia tipoVia) { |
|
85 |
this.tipoVia=tipoVia; |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public DynObject getVia() { |
|
90 |
return via; |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public void setVia(DynObject via) { |
|
95 |
this.via=via; |
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public String getNumero() { |
|
100 |
return numero; |
|
101 |
} |
|
102 |
|
|
103 |
@Override |
|
104 |
public void setNumero(String numero) { |
|
105 |
this.numero=numero; |
|
106 |
} |
|
107 |
|
|
108 |
@Override |
|
109 |
public String getBloque() { |
|
110 |
return bloque; |
|
111 |
} |
|
112 |
|
|
113 |
@Override |
|
114 |
public void setBloque(String bloque) { |
|
115 |
this.bloque=bloque; |
|
116 |
} |
|
117 |
|
|
118 |
@Override |
|
119 |
public String getEscalera() { |
|
120 |
return escalera; |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
public void setEscalera(String escalera) { |
|
125 |
this.escalera=escalera; |
|
126 |
} |
|
127 |
|
|
128 |
@Override |
|
129 |
public String getPlanta() { |
|
130 |
return planta; |
|
131 |
} |
|
132 |
|
|
133 |
@Override |
|
134 |
public void setPlanta(String planta) { |
|
135 |
this.planta=planta; |
|
136 |
} |
|
137 |
|
|
138 |
@Override |
|
139 |
public String getPuerta() { |
|
140 |
return puerta; |
|
141 |
} |
|
142 |
|
|
143 |
@Override |
|
144 |
public void setPuerta(String puerta) { |
|
145 |
this.puerta=puerta; |
|
146 |
} |
|
147 |
|
|
148 |
@Override |
|
149 |
public String getPoligono() { |
|
150 |
return poligono; |
|
151 |
} |
|
152 |
|
|
153 |
@Override |
|
154 |
public void setPoligono(String poligono) { |
|
155 |
this.poligono=poligono; |
|
156 |
} |
|
157 |
|
|
158 |
@Override |
|
159 |
public String getParcela() { |
|
160 |
return parcela; |
|
161 |
} |
|
162 |
|
|
163 |
@Override |
|
164 |
public void setParcela(String parcela) { |
|
165 |
this.parcela=parcela; |
|
166 |
} |
|
167 |
|
|
168 |
@Override |
|
169 |
public void validateQuery() throws BusquedaCatastralInvalidQueryException { |
|
170 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
171 |
if (TipoQuery.POR_RC.equals(tipoQuery)){ |
|
172 |
if(referenciaCatastral==null){ |
|
173 |
logger.error("RC not informed"); |
|
174 |
throw new BusquedaCatastralInvalidQueryException(i18nManager.getTranslation("_error_rc_not_informed"),null); |
|
175 |
} |
|
176 |
} |
|
177 |
else if (TipoQuery.POR_LOCALIZACION.equals(tipoQuery)){ |
|
178 |
if (provincia==null){ |
|
179 |
logger.error("Provincia not informed"); |
|
180 |
throw new BusquedaCatastralInvalidQueryException(i18nManager.getTranslation("_error_provincia_not_informed"),null); |
|
181 |
}else{ |
|
182 |
if (municipio==null){ |
|
183 |
logger.error("Municipio not informed"); |
|
184 |
throw new BusquedaCatastralInvalidQueryException(i18nManager.getTranslation("_error_municipio_not_informed"),null); |
|
185 |
}else{ |
|
186 |
if (tipoParcela==null){ |
|
187 |
logger.error("Tipo Parcela not informed"); |
|
188 |
throw new BusquedaCatastralInvalidQueryException(i18nManager.getTranslation("_error_tipo_parcela_not_informed"),null); |
|
189 |
}else{ |
|
190 |
if (tipoParcela.equals(TipoParcela.URBANA)){ |
|
191 |
if (via==null){ |
|
192 |
logger.error("Via not informed"); |
|
193 |
throw new BusquedaCatastralInvalidQueryException(i18nManager.getTranslation("_error_via_not_informed"),null); |
|
194 |
}else{ |
|
195 |
if (numero==null){ |
|
196 |
logger.error("Numero not informed"); |
|
197 |
throw new BusquedaCatastralInvalidQueryException(i18nManager.getTranslation("_error_numero_not_informed"),null); |
|
198 |
} |
|
199 |
} |
|
200 |
}else if (tipoParcela.equals(TipoParcela.RUSTICA)){ |
|
201 |
if (poligono==null){ |
|
202 |
logger.error("Poligono not informed"); |
|
203 |
throw new BusquedaCatastralInvalidQueryException(i18nManager.getTranslation("_error_poligono_not_informed"),null); |
|
204 |
}else if(parcela==null){ |
|
205 |
logger.error("Parcela not informed"); |
|
206 |
throw new BusquedaCatastralInvalidQueryException(i18nManager.getTranslation("_error_parcela_not_informed"),null); |
|
207 |
} |
|
208 |
} |
|
209 |
} |
|
210 |
} |
|
211 |
} |
|
212 |
}else{ |
|
213 |
logger.error("Tipo query not informed"); |
|
214 |
throw new BusquedaCatastralInvalidQueryException(i18nManager.getTranslation("_error_tipo_query_not_informed"),null); |
|
215 |
} |
|
216 |
|
|
217 |
|
|
218 |
} |
|
219 |
|
|
220 |
@Override |
|
221 |
public TipoQuery getTipoQuery() { |
|
222 |
return tipoQuery; |
|
223 |
} |
|
224 |
|
|
225 |
@Override |
|
226 |
public void setTipoQuery(TipoQuery tipoQuery) { |
|
227 |
this.tipoQuery=tipoQuery; |
|
228 |
|
|
229 |
} |
|
230 |
|
|
231 |
} |
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.179/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/java/org/gvsig/busquedacatastral/lib/impl/DefaultReferenciaCatastral.java | ||
---|---|---|
1 |
package org.gvsig.busquedacatastral.lib.impl; |
|
2 |
|
|
3 |
import org.apache.commons.lang3.StringUtils; |
|
4 |
import org.gvsig.busquedacatastral.lib.api.ReferenciaCatastral; |
|
5 |
import org.gvsig.busquedacatastral.lib.api.TipoVia; |
|
6 |
import org.gvsig.tools.ToolsLocator; |
|
7 |
import org.gvsig.tools.i18n.I18nManager; |
|
8 |
|
|
9 |
public class DefaultReferenciaCatastral implements ReferenciaCatastral{ |
|
10 |
|
|
11 |
String pc1;//Posiciones 1-7 |
|
12 |
String pc2;//Posiciones 8-14 |
|
13 |
String car;//Posiciones 15-18 |
|
14 |
String dc1;//19 |
|
15 |
String dc2;//20 |
|
16 |
|
|
17 |
String via; |
|
18 |
TipoVia tipoVia; |
|
19 |
String patio; |
|
20 |
String km; |
|
21 |
String bloque; |
|
22 |
String escalera; |
|
23 |
String planta; |
|
24 |
String puerta; |
|
25 |
String poligono; |
|
26 |
String parcela; |
|
27 |
String provincia; |
|
28 |
String municipio; |
|
29 |
String paraje; |
|
30 |
|
|
31 |
@Override |
|
32 |
public String getRC() { |
|
33 |
return getPc1()+getPc2()+getCar()+getDc1()+getDc2(); |
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public String getRCParcial() { |
|
38 |
return getPc1()+getPc2(); |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public String getLocalizacion() { |
|
43 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
44 |
String localizacion=""; |
|
45 |
if (getTipoVia()!=null){ |
|
46 |
localizacion+=getTipoVia().getAbrev(); |
|
47 |
} |
|
48 |
if (getVia()!=null){ |
|
49 |
if (StringUtils.isNotEmpty(localizacion)){ |
|
50 |
localizacion+=" "; |
|
51 |
} |
|
52 |
localizacion+=getVia(); |
|
53 |
} |
|
54 |
if (getPatio()!=null){ |
|
55 |
if (StringUtils.isNotEmpty(localizacion)){ |
|
56 |
localizacion+=" "; |
|
57 |
} |
|
58 |
localizacion+=getPatio(); |
|
59 |
} |
|
60 |
if (getKm()!=null){ |
|
61 |
if (StringUtils.isNotEmpty(localizacion)){ |
|
62 |
localizacion+=" "; |
|
63 |
} |
|
64 |
String km=i18nManager.getTranslation("_km"); |
|
65 |
localizacion+=km+" "+getKm(); |
|
66 |
} |
|
67 |
if (getBloque()!=null){ |
|
68 |
if (StringUtils.isNotEmpty(localizacion)){ |
|
69 |
localizacion+=" "; |
|
70 |
} |
|
71 |
String bloque=i18nManager.getTranslation("_bloque"); |
|
72 |
localizacion+=bloque+" "+getBloque(); |
|
73 |
} |
|
74 |
if (getEscalera()!=null){ |
|
75 |
if (StringUtils.isNotEmpty(localizacion)){ |
|
76 |
localizacion+=" "; |
|
77 |
} |
|
78 |
String escalera=i18nManager.getTranslation("_escalera"); |
|
79 |
localizacion+=escalera+" "+getEscalera(); |
|
80 |
} |
|
81 |
if (getPlanta()!=null){ |
|
82 |
if (StringUtils.isNotEmpty(localizacion)){ |
|
83 |
localizacion+=" "; |
|
84 |
} |
|
85 |
String planta=i18nManager.getTranslation("_planta"); |
|
86 |
localizacion+=planta+" "+getPlanta(); |
|
87 |
} |
|
88 |
if (getPuerta()!=null){ |
|
89 |
if (StringUtils.isNotEmpty(localizacion)){ |
|
90 |
localizacion+=" "; |
|
91 |
} |
|
92 |
String puerta=i18nManager.getTranslation("_puerta"); |
|
93 |
localizacion+=puerta+" "+getPuerta(); |
|
94 |
} |
|
95 |
if (getPoligono()!=null){ |
|
96 |
if (StringUtils.isNotEmpty(localizacion)){ |
|
97 |
localizacion+=" "; |
|
98 |
} |
|
99 |
String poligono=i18nManager.getTranslation("_poligono"); |
|
100 |
localizacion+=poligono+" "+getPoligono(); |
|
101 |
} |
|
102 |
if (getParcela()!=null){ |
|
103 |
if (StringUtils.isNotEmpty(localizacion)){ |
|
104 |
localizacion+=" "; |
|
105 |
} |
|
106 |
String parcela=i18nManager.getTranslation("_parcela"); |
|
107 |
localizacion+=parcela+" "+getParcela(); |
|
108 |
} |
|
109 |
if (getParaje()!=null){ |
|
110 |
if (StringUtils.isNotEmpty(localizacion)){ |
|
111 |
localizacion+=" "; |
|
112 |
} |
|
113 |
String paraje=i18nManager.getTranslation("_paraje"); |
|
114 |
localizacion+=paraje+" "+getParaje(); |
|
115 |
} |
|
116 |
if (getMunicipio()!=null){ |
|
117 |
if (StringUtils.isNotEmpty(localizacion)){ |
|
118 |
localizacion+=" "; |
|
119 |
} |
|
120 |
localizacion+=getMunicipio(); |
|
121 |
} |
|
122 |
if (getProvincia()!=null){ |
|
123 |
localizacion+="("+getProvincia()+")"; |
|
124 |
} |
|
125 |
return localizacion; |
|
126 |
|
|
127 |
} |
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
@Override |
|
134 |
public boolean equals(Object obj) { |
|
135 |
if (this == obj) |
|
136 |
return true; |
|
137 |
if (obj == null) |
|
138 |
return false; |
|
139 |
if (getClass() != obj.getClass()) |
|
140 |
return false; |
|
141 |
DefaultReferenciaCatastral other = (DefaultReferenciaCatastral) obj; |
|
142 |
if (getLocalizacion() == null) { |
|
143 |
if (other.getLocalizacion() != null) |
|
144 |
return false; |
|
145 |
} else if (!getLocalizacion().equals(other.getLocalizacion())) |
|
146 |
return false; |
|
147 |
if (getRC() == null) { |
|
148 |
if (other.getRC() != null) |
|
149 |
return false; |
|
150 |
} else if (!getRC().equals(other.getRC())) |
|
151 |
return false; |
|
152 |
return true; |
|
153 |
} |
|
154 |
|
|
155 |
|
|
156 |
public String getPc1() { |
|
157 |
return pc1; |
|
158 |
} |
|
159 |
|
|
160 |
|
|
161 |
public void setPc1(String pc1) { |
|
162 |
this.pc1 = pc1; |
|
163 |
} |
|
164 |
|
|
165 |
|
|
166 |
public String getPc2() { |
|
167 |
return pc2; |
|
168 |
} |
|
169 |
|
|
170 |
|
|
171 |
public void setPc2(String pc2) { |
|
172 |
this.pc2 = pc2; |
|
173 |
} |
|
174 |
|
|
175 |
|
|
176 |
public String getCar() { |
|
177 |
return car; |
|
178 |
} |
|
179 |
|
|
180 |
|
|
181 |
public void setCar(String car) { |
|
182 |
this.car = car; |
|
183 |
} |
|
184 |
|
|
185 |
|
|
186 |
public String getDc1() { |
|
187 |
return dc1; |
|
188 |
} |
|
189 |
|
|
190 |
|
|
191 |
public void setDc1(String dc1) { |
|
192 |
this.dc1 = dc1; |
|
193 |
} |
|
194 |
|
|
195 |
|
|
196 |
public String getDc2() { |
|
197 |
return dc2; |
|
198 |
} |
|
199 |
|
|
200 |
|
|
201 |
public void setDc2(String dc2) { |
|
202 |
this.dc2 = dc2; |
|
203 |
} |
|
204 |
|
|
205 |
|
|
206 |
public String getVia() { |
|
207 |
return via; |
|
208 |
} |
|
209 |
|
|
210 |
|
|
211 |
public void setVia(String via) { |
|
212 |
this.via = via; |
|
213 |
} |
|
214 |
|
|
215 |
|
|
216 |
public TipoVia getTipoVia() { |
|
217 |
return tipoVia; |
|
218 |
} |
|
219 |
|
|
220 |
|
|
221 |
public void setTipoVia(TipoVia tipoVia) { |
|
222 |
this.tipoVia = tipoVia; |
|
223 |
} |
|
224 |
|
|
225 |
|
|
226 |
public String getPatio() { |
|
227 |
return patio; |
|
228 |
} |
|
229 |
|
|
230 |
|
|
231 |
public void setPatio(String patio) { |
|
232 |
this.patio = patio; |
|
233 |
} |
|
234 |
|
|
235 |
|
|
236 |
public String getKm() { |
|
237 |
return km; |
|
238 |
} |
|
239 |
|
|
240 |
|
|
241 |
public void setKm(String km) { |
|
242 |
this.km = km; |
|
243 |
} |
|
244 |
|
|
245 |
|
|
246 |
public String getBloque() { |
|
247 |
return bloque; |
|
248 |
} |
|
249 |
|
|
250 |
|
|
251 |
public void setBloque(String bloque) { |
|
252 |
this.bloque = bloque; |
|
253 |
} |
|
254 |
|
|
255 |
|
|
256 |
public String getEscalera() { |
|
257 |
return escalera; |
|
258 |
} |
|
259 |
|
|
260 |
|
|
261 |
public void setEscalera(String escalera) { |
|
262 |
this.escalera = escalera; |
|
263 |
} |
|
264 |
|
|
265 |
|
|
266 |
public String getPlanta() { |
|
267 |
return planta; |
|
268 |
} |
|
269 |
|
|
270 |
|
|
271 |
public void setPlanta(String planta) { |
|
272 |
this.planta = planta; |
|
273 |
} |
|
274 |
|
|
275 |
|
|
276 |
public String getPuerta() { |
|
277 |
return puerta; |
|
278 |
} |
|
279 |
|
|
280 |
|
|
281 |
public void setPuerta(String puerta) { |
|
282 |
this.puerta = puerta; |
|
283 |
} |
|
284 |
|
|
285 |
|
|
286 |
public String getPoligono() { |
|
287 |
return poligono; |
|
288 |
} |
|
289 |
|
|
290 |
|
|
291 |
public void setPoligono(String poligono) { |
|
292 |
this.poligono = poligono; |
|
293 |
} |
|
294 |
|
|
295 |
|
|
296 |
public String getParcela() { |
|
297 |
return parcela; |
|
298 |
} |
|
299 |
|
|
300 |
|
|
301 |
public void setParcela(String parcela) { |
|
302 |
this.parcela = parcela; |
|
303 |
} |
|
304 |
|
|
305 |
|
|
306 |
public String getProvincia() { |
|
307 |
return provincia; |
|
308 |
} |
|
309 |
|
|
310 |
|
|
311 |
public void setProvincia(String provincia) { |
|
312 |
this.provincia = provincia; |
|
313 |
} |
|
314 |
|
|
315 |
|
|
316 |
public String getMunicipio() { |
|
317 |
return municipio; |
|
318 |
} |
|
319 |
|
|
320 |
|
|
321 |
public void setMunicipio(String municipio) { |
|
322 |
this.municipio = municipio; |
|
323 |
} |
|
324 |
|
|
325 |
|
|
326 |
public String getParaje() { |
|
327 |
return paraje; |
|
328 |
} |
|
329 |
|
|
330 |
|
|
331 |
public void setParaje(String paraje) { |
|
332 |
this.paraje = paraje; |
|
333 |
} |
|
334 |
|
|
335 |
} |
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.179/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/java/org/gvsig/busquedacatastral/lib/impl/MunicipiosFactory.java | ||
---|---|---|
1 |
package org.gvsig.busquedacatastral.lib.impl; |
|
2 |
|
|
3 |
import java.io.ByteArrayInputStream; |
|
4 |
import java.io.File; |
|
5 |
import java.io.InputStream; |
|
6 |
import java.rmi.RemoteException; |
|
7 |
import java.util.List; |
|
8 |
|
|
9 |
import javax.xml.bind.JAXBContext; |
|
10 |
import javax.xml.bind.Unmarshaller; |
|
11 |
|
|
12 |
import org.apache.axis.message.MessageElement; |
|
13 |
import org.apache.commons.lang3.StringUtils; |
|
14 |
|
|
15 |
import org.gvsig.busquedacatastral.lib.api.BusquedaCatastralManager; |
|
16 |
import org.gvsig.busquedacatastral.lib.api.QueryCatastral; |
|
17 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralException; |
|
18 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException; |
|
19 |
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralRemoteServiceException; |
|
20 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.MunicipiosWSResponse; |
|
21 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaMunicipieror; |
|
22 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Muni; |
|
23 |
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Municipiero; |
|
24 |
import org.gvsig.fmap.dal.DataTypes; |
|
25 |
import org.gvsig.fmap.dal.exception.DataException; |
|
26 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
27 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
28 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
29 |
import org.gvsig.tools.ToolsLocator; |
|
30 |
import org.gvsig.tools.dynobject.DynObject; |
|
31 |
import org.gvsig.tools.exception.BaseException; |
|
32 |
import org.gvsig.tools.i18n.I18nManager; |
|
33 |
|
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
37 |
public class MunicipiosFactory extends WSObjectsFactory{ |
|
38 |
|
|
39 |
private static final Logger logger = LoggerFactory |
|
40 |
.getLogger(MunicipiosFactory.class); |
|
41 |
|
|
42 |
private final static String MUNICIPIOS_FILENAME="municipios.dbf"; |
|
43 |
|
|
44 |
|
|
45 |
public MunicipiosFactory(BusquedaCatastralManager manager){ |
|
46 |
super(manager); |
|
47 |
} |
|
48 |
|
|
49 |
private Municipiero municipiero=null; |
|
50 |
private QueryCatastral query; |
|
51 |
private String filtro; |
|
52 |
public List<DynObject> getMunicipios(QueryCatastral query) throws BusquedaCatastralException{ |
|
53 |
this.query=query; |
|
54 |
this.filtro=null; |
|
55 |
return getMunicipios(); |
|
56 |
} |
|
57 |
|
|
58 |
public List<DynObject> getMunicipios(QueryCatastral query, String filtro) throws BusquedaCatastralException{ |
|
59 |
this.query=query; |
|
60 |
this.filtro=filtro; |
|
61 |
return getMunicipios(); |
|
62 |
} |
|
63 |
|
|
64 |
private List<DynObject> getMunicipios() throws BusquedaCatastralException{ |
|
65 |
File municipiosFile=null; |
|
66 |
|
|
67 |
try { |
|
68 |
if (query==null||query.getProvincia()==null){ |
|
69 |
logger.error("Provincia no informada"); |
|
70 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
71 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_provincia_not_informed"), null); |
|
72 |
} |
|
73 |
|
|
74 |
DynObject provincia=query.getProvincia(); |
|
75 |
String codProvincia=(String) provincia.getDynValue(BusquedaCatastralManager.CAMPO_PROVINCIA_CODIGO); |
|
76 |
File provinciaFolder=new File(manager.getCacheFolder(),codProvincia); |
|
77 |
if (!provinciaFolder.exists()){ |
|
78 |
provinciaFolder.mkdirs(); |
|
79 |
} |
|
80 |
municipiosFile = new File(provinciaFolder,MUNICIPIOS_FILENAME); |
|
81 |
if (!municipiosFile.exists()){ |
|
82 |
createDBF(municipiosFile); |
|
83 |
} |
|
84 |
return this.getListFromDBF(municipiosFile); |
|
85 |
} catch ( BusquedaCatastralException e) { |
|
86 |
throw e; |
|
87 |
} catch ( Exception e) { |
|
88 |
logger.warn("Error getting municipios from file '"+municipiosFile.getAbsolutePath()+"'.",e); |
|
89 |
throw new BusquedaCatastralGettingParamsException(e); |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
protected void defineType(EditableFeatureType type) throws BusquedaCatastralException { |
|
95 |
municipiero=getMunicipiero(query); |
|
96 |
int maxNombre=0; |
|
97 |
int maxCodProvINE=0; |
|
98 |
int maxCodMuniINE=0; |
|
99 |
|
|
100 |
for( Muni muni:municipiero.getMuni()){ |
|
101 |
if(StringUtils.isNotEmpty(muni.getNm()) && muni.getNm().length()>maxNombre){ |
|
102 |
maxNombre=muni.getNm().length(); |
|
103 |
} |
|
104 |
if(StringUtils.isNotEmpty(muni.getLoine().getCp()) && muni.getLoine().getCp().length()>maxCodProvINE){ |
|
105 |
maxCodProvINE=muni.getLoine().getCp().length(); |
|
106 |
} |
|
107 |
if(StringUtils.isNotEmpty(muni.getLoine().getCm()) && muni.getLoine().getCm().length()>maxCodMuniINE){ |
|
108 |
maxCodMuniINE=muni.getLoine().getCm().length(); |
|
109 |
} |
|
110 |
|
|
111 |
} |
|
112 |
type.add(BusquedaCatastralManager.CAMPO_MUNICIPIO_NOMBRE, DataTypes.STRING, |
|
113 |
maxNombre); |
|
114 |
type.add(BusquedaCatastralManager.CAMPO_MUNICIPIO_DELEGACION_MEH, DataTypes.LONG).setAllowNull(true); |
|
115 |
type.add(BusquedaCatastralManager.CAMPO_MUNICIPIO_CODIGO_MEH, DataTypes.LONG).setAllowNull(true); |
|
116 |
type.add(BusquedaCatastralManager.CAMPO_MUNICIPIO_PROVINCIA_INE, DataTypes.STRING, |
|
117 |
maxCodProvINE).setAllowNull(true); |
|
118 |
type.add(BusquedaCatastralManager.CAMPO_MUNICIPIO_MUNICIPIO_INE, DataTypes.STRING, |
|
119 |
maxCodMuniINE).setAllowNull(true); |
|
120 |
|
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
protected void writeFileData(FeatureStore featureStore) throws BusquedaCatastralException, DataException { |
|
125 |
municipiero=getMunicipiero(query); |
|
126 |
for(Muni muni:municipiero.getMuni()){ |
|
127 |
EditableFeature ef; |
|
128 |
ef = featureStore.createNewFeature().getEditable(); |
|
129 |
ef.set(BusquedaCatastralManager.CAMPO_MUNICIPIO_NOMBRE, muni.getNm()); |
|
130 |
ef.set(BusquedaCatastralManager.CAMPO_MUNICIPIO_DELEGACION_MEH, muni.getLocat().getCd()); |
|
131 |
ef.set(BusquedaCatastralManager.CAMPO_MUNICIPIO_CODIGO_MEH, muni.getLocat().getCmc()); |
|
132 |
ef.set(BusquedaCatastralManager.CAMPO_MUNICIPIO_PROVINCIA_INE, muni.getLoine().getCp()); |
|
133 |
ef.set(BusquedaCatastralManager.CAMPO_MUNICIPIO_MUNICIPIO_INE, muni.getLoine().getCm()); |
|
134 |
featureStore.insert(ef); |
|
135 |
} |
|
136 |
municipiero = null; |
|
137 |
} |
|
138 |
|
|
139 |
private Municipiero getMunicipiero(QueryCatastral query) throws BusquedaCatastralException{ |
|
140 |
if( municipiero == null ) { |
|
141 |
try { |
|
142 |
DynObject provincia=query.getProvincia(); |
|
143 |
String nombreProvincia=(String) provincia.getDynValue(BusquedaCatastralManager.CAMPO_PROVINCIA_NOMBRE); |
|
144 |
MunicipiosWSResponse municipios = getCatastroWS().obtenerMunicipios(nombreProvincia, ""); |
|
145 |
if (municipios!=null){ |
|
146 |
MessageElement[] any = municipios.get_any(); |
|
147 |
MessageElement me=any[0]; |
|
148 |
JAXBContext jaxbContext = JAXBContext.newInstance(ConsultaMunicipieror.class); |
|
149 |
|
|
150 |
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); |
|
151 |
InputStream input = new ByteArrayInputStream(me.getAsString().getBytes()); |
|
152 |
ConsultaMunicipieror cm = (ConsultaMunicipieror) jaxbUnmarshaller.unmarshal(input); |
|
153 |
|
|
154 |
if (cm!=null && cm.getLerr()!=null){ |
|
155 |
webserviceErrors(cm.getLerr().getErr()); |
|
156 |
} |
|
157 |
|
|
158 |
municipiero = cm.getMunicipiero(); |
|
159 |
}else{ |
|
160 |
logger.error("Webservice response is empty"); |
|
161 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
162 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"),null); |
|
163 |
} |
|
164 |
|
|
165 |
} catch (RemoteException e) { |
|
166 |
logger.error("Error accesing webservice",e); |
|
167 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
168 |
throw new BusquedaCatastralRemoteServiceException(i18nManager.getTranslation("_error_obtaining_catastro_webservice"), e); |
|
169 |
} catch (Exception e) { |
|
170 |
logger.error("Error marshalling response from webservice",e); |
|
171 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
172 |
throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"), e); |
|
173 |
} |
|
174 |
} |
|
175 |
return municipiero; |
|
176 |
} |
|
177 |
|
|
178 |
@Override |
|
179 |
protected String getExpressionQuery() { |
|
180 |
if (StringUtils.isNotEmpty(filtro)){ |
|
181 |
StringBuilder strb=new StringBuilder(); |
|
182 |
strb.append(BusquedaCatastralManager.CAMPO_MUNICIPIO_NOMBRE); |
|
183 |
strb.append(" like '%"); |
|
184 |
strb.append(filtro.toUpperCase()+"%'"); |
|
185 |
return strb.toString(); |
|
186 |
} |
|
187 |
return null; |
|
188 |
} |
|
189 |
|
|
190 |
|
|
191 |
} |
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.179/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/java/org/gvsig/busquedacatastral/lib/impl/DefaultBusquedaCatastralManager.java | ||
---|---|---|
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()) { |
Also available in: Unified diff