Revision 2549

View differences:

org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/BusquedaCatastralManager.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.api;
24

  
25
import java.io.File;
26
import java.io.IOException;
27
import java.util.List;
28

  
29
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralException;
30
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingDataException;
31
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException;
32
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralInvalidSRSException;
33
import org.gvsig.fmap.geom.primitive.Point;
34
import org.gvsig.tools.dynobject.DynObject;
35

  
36
/**
37
 * This class is responsible of the management of the library's business logic.
38
 * It is the library's main entry point, and provides all the services to manage
39
 * {@link WebMapService}s.
40
 *
41
 * @see WebMapService
42
 * @author gvSIG team
43
 * @version $Id$
44
 */
45
public interface BusquedaCatastralManager {
46

  
47
       //Provincia
48
       public static final String CAMPO_PROVINCIA_NOMBRE="np";
49
       public static final String CAMPO_PROVINCIA_ETIQUETA="np";
50
       public static final String CAMPO_PROVINCIA_CODIGO="cpine";
51
       //Municipio
52
       public static final String CAMPO_MUNICIPIO_NOMBRE="nm";
53
       public static final String CAMPO_MUNICIPIO_ETIQUETA="nm";
54
       public static final String CAMPO_MUNICIPIO_DELEGACION_MEH="locat_cd";
55
       public static final String CAMPO_MUNICIPIO_CODIGO_MEH="locat_cmc";
56
       public static final String CAMPO_MUNICIPIO_PROVINCIA_INE="loine_cp";
57
       public static final String CAMPO_MUNICIPIO_MUNICIPIO_INE="loine_cm";
58

  
59
       //Via
60
       public static final String CAMPO_VIA_NOMBRE="dir_nv";
61
       public static final String CAMPO_VIA_ETIQUETA="dir_nv";
62
       public static final String CAMPO_VIA_TIPOVIA="dir_tp";
63
       public static final String CAMPO_VIA_COD_DGC="dir_cv";
64
       public static final String CAMPO_VIA_PROV_INE="loine_cp";
65
       public static final String CAMPO_VIA_MUNI_INE="loine_cm";
66

  
67

  
68
       /**
69
        * deletes cache
70
        */
71
       public void deleteCache() throws IOException;
72

  
73
       /**
74
        * Creates a query object to get data from catastro
75
        * @return QueryCatastral
76
        */
77
       public QueryCatastral createQuery();
78

  
79
       /**
80
        * Gets Provincias from catastro
81
        * @return List<DynObject>
82
        */
83
       public List<DynObject> getProvincias() throws BusquedaCatastralException;
84

  
85
       /**
86
        * Gets Municipios from catastro, depending from provincia
87
        * @param query
88
        * @return List<DynObject>
89
        */
90
       public List<DynObject> getMunicipios(QueryCatastral query) throws BusquedaCatastralException;
91

  
92
       /**
93
        * Gets Municipios from catastro, depending from provincia and filtered
94
        * @param query
95
        * @param municipio
96
        * @return List<DynObject>
97
        */
98
       public List<DynObject> getMunicipios(QueryCatastral query, String municipio)throws BusquedaCatastralException;
99

  
100
       /**
101
        * Tipos de vias del catastro
102
        * @return List<TipoVia>
103
        */
104
       public List<TipoVia> getTiposDeVia()throws BusquedaCatastralException;
105

  
106
       /**
107
        * Vias del catastro en funcion del municipio
108
        * @param query
109
        * @return List<DynObject>
110
        */
111
       public List<DynObject> getVias(QueryCatastral query)throws BusquedaCatastralException;
112

  
113
       /**
114
        * Vias del catastro en funcion del municipio, filtrado
115
        * @param query
116
        * @param via
117
        * @return List<DynObject>
118
        */
119
       public List<DynObject> getVias(QueryCatastral query, String via)throws BusquedaCatastralException;
120

  
121
       /**
122
        * Devuelve los posibles numeros de una v?a entre un intervalo dado
123
        * @param query
124
        * @param inicio
125
        * @param fin
126
        * @return List<String>
127
        */
128
       public List<String> getNumeros(QueryCatastral query,String inicio, String fin)throws BusquedaCatastralException;
129

  
130
       /**
131
        * Devuelve las referecias catastrales para la query formada
132
        * @param query
133
        * @return List<ReferenciaCatastral>
134
        */
135
       public List<ReferenciaCatastral> getReferenciasCatastrales(QueryCatastral query)throws BusquedaCatastralException;
136

  
137
       /**
138
        * Devuelve un punto del centroide correspondiente de la referencia catastral
139
        * @param referenciacatastral
140
        * @return Point
141
        */
142
       public Point getPoint(String referenciacatastral, SRSCatastro srs)throws BusquedaCatastralException;
143

  
144
       /**
145
        * Devuelve un punto del centroide correspondiente del codigo de la referencia catastral
146
        * @param referenciacatastral
147
        * @param srs
148
        * @return Point
149
     * @throws BusquedaCatastralException
150
        */
151
       public Point getPoint(ReferenciaCatastral referenciacatastral, SRSCatastro srs)throws BusquedaCatastralException;
152

  
153
       /**
154
        * Devuelve los datos catastrales de la parcela en el punto indicado
155
        * @param p
156
     * @param srs
157
        * @return DynObject
158
     * @throws BusquedaCatastralException
159
        */
160
       public DynObject getDatosCatastrales(Point p, SRSCatastro srs)throws BusquedaCatastralException;
161

  
162
       /**
163
        * Devuelve los datos catastrales del codigo de la referencia catastral
164
        * @param rc
165
        * @return DynObject
166
     * @throws BusquedaCatastralException
167
        */
168
       public DynObject getDatosCatastrales(String rc)throws BusquedaCatastralException;
169

  
170
       /**
171
     * @return
172
     */
173
    public File getCacheFolder();
174

  
175
       /**
176
     * @param cacheFolder
177
     */
178
    public void setCacheFolder(File cacheFolder);
179
}
180

  
181

  
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/QueryCatastral.java
1
package org.gvsig.busquedacatastral.lib.api;
2

  
3
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralInvalidQueryException;
4
import org.gvsig.tools.dynobject.DynObject;
5

  
6
/**
7
 * Params to query catastro
8
 * @author dmartinezizquierdo
9
 *
10
 */
11
public interface QueryCatastral {
12

  
13
    enum TipoParcela{URBANA,RUSTICA};
14

  
15
    enum TipoQuery{POR_RC,POR_LOCALIZACION};
16

  
17
    public TipoQuery getTipoQuery();
18

  
19
    public void setTipoQuery(TipoQuery tipoQuery);
20

  
21
    public TipoParcela getTipoParcela();
22

  
23
    public void setReferenciaCatastral(String referenciaCatastral);
24

  
25
    public String getReferenciaCatastral();
26

  
27
    public void setTipoParcela(TipoParcela tipoParcela);
28

  
29
    public DynObject getProvincia();
30

  
31
    public void setProvincia(DynObject provincia);
32

  
33
    public DynObject getMunicipio();
34

  
35
    public void setMunicipio(DynObject municipio);
36

  
37
    public TipoVia getTipoVia();
38

  
39
    public void setTipoVia(TipoVia tipoVia);
40

  
41
    public DynObject getVia();
42

  
43
    public void setVia(DynObject via);
44

  
45
    public String getNumero();
46

  
47
    public void setNumero (String numero);
48

  
49
    public String getBloque ();
50

  
51
    public void setBloque (String bloque);
52

  
53
    public String getEscalera ();
54

  
55
    public void setEscalera (String escalera);
56

  
57
    public String getPlanta ();
58

  
59
    public void setPlanta (String planta);
60

  
61
    public String getPuerta ();
62

  
63
    public void setPuerta (String puerta);
64

  
65
    public String getPoligono();
66

  
67
    public void setPoligono (String poligono);
68

  
69
    public String getParcela ();
70

  
71
    public void setParcela (String parcela);
72

  
73
    public void validateQuery() throws BusquedaCatastralInvalidQueryException;
74
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/SRSCatastro.java
1
package org.gvsig.busquedacatastral.lib.api;
2

  
3
import org.gvsig.tools.ToolsLocator;
4

  
5
/**
6
 * Enumeracion con los SRS aceptados por Catastro
7
 * @author dmartinezizquierdo
8
 *
9
 */
10
public enum SRSCatastro {
11
    EPSG_4230("EPSG:4230","Geogr?ficas en ED 50"),
12
    EPSG_4326("EPSG:4326","Geogr?ficas en WGS 80",true),//default
13
    EPSG_4258("EPSG:4258","Geogr?ficas en ETRS89"),
14
    EPSG_32627("EPSG:32627","UTM huso 27N en WGS 84"),
15
    EPSG_32628("EPSG:32628","UTM huso 28N en WGS 84"),
16
    EPSG_32629("EPSG:32629","UTM huso 29N en WGS 84"),
17
    EPSG_32630("EPSG:32630","UTM huso 30N en WGS 84"),
18
    EPSG_32631("EPSG:32631","UTM huso 31N en WGS 84"),
19
    EPSG_25829("EPSG:25829","UTM huso 29N en ETRS89"),
20
    EPSG_25830("EPSG:25830","UTM huso 30N en ETRS89"),
21
    EPSG_25831("EPSG:25831","UTM huso 31N en ETRS89"),
22
    EPSG_23029("EPSG:23029","UTM huso 29N en ED50"),
23
    EPSG_23030("EPSG:23030","UTM huso 30N en ED50"),
24
    EPSG_23031("EPSG:23031","UTM huso 31N en ED50");
25

  
26

  
27
    private final String cod;
28
    private final String label;
29
    private final boolean isDefault;
30

  
31
    SRSCatastro(String cod, String label, boolean isDefault){
32
        this.cod = cod;
33
        this.label = label;
34
        this.isDefault=isDefault;
35
    }
36

  
37
    SRSCatastro(String cod, String label){
38
        this.cod = cod;
39
        this.label = label;
40
        this.isDefault=false;
41
    }
42

  
43
    /**
44
     * Gets SRS codigo
45
     * @return String
46
     */
47
    public String getCod(){
48
        return this.cod;
49
    }
50

  
51
    /**
52
     * Gets SRS label
53
     * @return String
54
     */
55
    public String getLabel(){
56
        return this.label;
57
    }
58

  
59
    /**
60
     * gets the default SRS for Catastro
61
     * @return
62
     */
63
    public static SRSCatastro getDefaultSRS(){
64
        for (SRSCatastro srs:SRSCatastro.values()){
65
            if(srs.isDefault){
66
                return srs;
67
            }
68
        }
69
        return null;
70
    }
71

  
72
    /**
73
     * gets the default SRS for Catastro
74
     * @return
75
     */
76
    public static SRSCatastro getCatastroByCod(String cod){
77
        for (SRSCatastro srs:SRSCatastro.values()){
78
            if(srs.getCod().equals(cod)){
79
                return srs;
80
            }
81
        }
82
        return null;
83
    }
84
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/TipoVia.java
1
package org.gvsig.busquedacatastral.lib.api;
2

  
3
import org.gvsig.tools.ToolsLocator;
4

  
5
/**
6
 * Enumeracion con los tipos de vias
7
 * @author dmartinezizquierdo
8
 *
9
 */
10
public enum TipoVia {
11
    BLANK("","-----"),
12
    ACCESO("AC","ACCESO"),
13
    AGREGADO("AG","AGREGADO"),
14
    ALDEA_ALAMEDA("AL","ALDEA, ALAMEDA"),
15
    ANDADOR("AN","ANDADOR"),
16
    AREA_ARRABAL("AR","AREA, ARRABAL"),
17
    AUTOPISTA("AU","AUTOPISTA"),
18
    AVENIDA("AV","AVENIDA"),
19
    ARROYO("AY","ARROYO"),
20
    BAJADA("BJ","BAJADA"),
21
    BLOQUE("BL","BLOQUE"),
22
    BARRIO("BO","BARRIO"),
23
    BARRANQUIL("BQ","BARRANQUIL"),
24
    BARRANCO("BR","BARRANCO"),
25
    CA?ADA("CA","CA?ADA"),
26
    COLEGIO_CIGARRAL("CG","COLEGIO, CIGARRAL"),
27
    CHALET("CH","CHALET"),
28
    CINTURON("CI","CINTURON"),
29
    CALLEJA_CALLEJON("CJ","CALLEJA, CALLEJON"),
30
    CALLE("CL","CALLE"),
31
    CAMINO_CARMEN("CM","CAMINO, CARMEN"),
32
    COLONIA("CN","COLONIA"),
33
    CONCEJO_COLEGIO("CO","CONCEJO, COLEGIO"),
34
    CAMPA_CAMPO("CP","CAMPA, CAMPO"),
35
    CARRETERA_CARRERA("CR","CARRETERA, CARRERA"),
36
    CASERIO("CS","CASERIO"),
37
    CUESTA_COSTANILLA("CT","CUESTA, COSTANILLA"),
38
    CONJUNTO("CU","CONJUNTO"),
39
    CALEYA("CY","CALEYA"),
40
    CALLIZO("CZ","CALLIZO"),
41
    DETR?S("DE","DETR?S"),
42
    DIPUTACION("DP","DIPUTACION"),
43
    DISEMINADOS("DS","DISEMINADOS"),
44
    EDIFICIOS("ED","EDIFICIOS"),
45
    EXTRAMUROS("EM","EXTRAMUROS"),
46
    ENTRADA_ENSANCHE("EN","ENTRADA, ENSANCHE"),
47
    ESPALDA("EP","ESPALDA"),
48
    EXTRARRADIO("ER","EXTRARRADIO"),
49
    ESCALINATA("ES","ESCALINATA"),
50
    EXPLANADA("EX","EXPLANADA"),
51
    FERROCARRIL("FC","FERROCARRIL"),
52
    FINCA("FN","FINCA"),
53
    GLORIETA("GL","GLORIETA"),
54
    GRUPO("GR","GRUPO"),
55
    GRAN_VIA("GV","GRAN VIA"),
56
    HUERTA_HUERTO("HT","HUERTA, HUERTO"),
57
    JARDINES("JR","JARDINES"),
58
    LAGO("LA","LAGO"),
59
    LADO_LADERA("LD","LADO, LADERA"),
60
    LUGAR("LG","LUGAR"),
61
    MALECON("MA","MALECON"),
62
    MERCADO("MC","MERCADO"),
63
    MUELLE("ML","MUELLE"),
64
    MUNICIPIO("MN","MUNICIPIO"),
65
    MASIAS("MS","MASIAS"),
66
    MONTE("MT","MONTE"),
67
    MANZANA("MZ","MANZANA"),
68
    POBLADO("PB","POBLADO"),
69
    PLACETA("PC","PLACETA"),
70
    PARTIDA("PD","PARTIDA"),
71
    PARTICULAR("PI","PARTICULAR"),
72
    PASAJE_PASADIZO("PJ","PASAJE, PASADIZO"),
73
    POLIGONO("PL","POLIGONO"),
74
    PARAMO("PM","PARAMO"),
75
    PARROQUIA_PARQUE("PQ","PARROQUIA, PARQUE"),
76
    PROLONGACION_CONTINUAC("PR","PROLONGACION, CONTINUAC."),
77
    PASEO("PS","PASEO"),
78
    PUENTE("PT","PUENTE"),
79
    PASADIZO("PU","PASADIZO"),
80
    PLAZA("PZ","PLAZA"),
81
    QUINTA("QT","QUINTA"),
82
    RACONADA("RA","RACONADA"),
83
    RAMBLA("RB","RAMBLA"),
84
    RINCON_RINCONA("RC","RINCON, RINCONA"),
85
    RONDA("RD","RONDA"),
86
    RAMAL("RM","RAMAL"),
87
    RAMPA("RP","RAMPA"),
88
    RIERA("RR","RIERA"),
89
    RUA("RU","RUA"),
90
    SALIDA("SA","SALIDA"),
91
    SECTOR("SC","SECTOR"),
92
    SENDA("SD","SENDA"),
93
    SOLAR("SL","SOLAR"),
94
    SALON("SN","SALON"),
95
    SUBIDA("SU","SUBIDA"),
96
    TERRENOS("TN","TERRENOS"),
97
    TORRENTE("TO","TORRENTE"),
98
    TRAVESIA("TR","TRAVESIA"),
99
    URBANIZACION("UR","URBANIZACION"),
100
    VALLE("VA","VALLE"),
101
    VIADUCTO("VD","VIADUCTO"),
102
    VIA("VI","VIA"),
103
    VIAL("VL","VIAL"),
104
    VEREDA("VR","VEREDA");
105

  
106

  
107
    private final String abrev;
108
    private final String label;
109

  
110
    TipoVia(String abrev, String label){
111
        this.abrev = abrev;
112
        this.label = label;
113
    }
114

  
115
    /**
116
     * Gets Tipo via codigo
117
     * @return String
118
     */
119
    public String getAbrev(){
120
        return this.abrev;
121
    }
122

  
123
    /**
124
     * Gets Tipo via label
125
     * @return String
126
     */
127
    public String getLabel(){
128
        return this.label;
129
    }
130

  
131
    /**
132
     * gets the tipoVia for the given cod
133
     * @return
134
     */
135
    public static TipoVia getTipoViaByAbrev(String abrev){
136
        for (TipoVia tipoVia:TipoVia.values()){
137
            if(tipoVia.getAbrev().equals(abrev)){
138
                return tipoVia;
139
            }
140
        }
141
        return null;
142
    }
143
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/BusquedaCatastralLocator.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.api;
24

  
25
import org.gvsig.tools.locator.BaseLocator;
26
import org.gvsig.tools.locator.Locator;
27
import org.gvsig.tools.locator.LocatorException;
28

  
29
/**
30
 * This locator is the entry point for the BusquedaCatastral library,
31
 * providing access to all services through the
32
 * {@link BusquedaCatastralManager} .
33
 *
34
 * @author gvSIG team
35
 * @version $Id$
36
 */
37
public class BusquedaCatastralLocator extends BaseLocator {
38

  
39
    private static final String LOCATOR_NAME = "BusquedaCatastral.locator";
40

  
41
    /**
42
     * WebMap manager name.
43
     */
44
    public static final String MANAGER_NAME = "BusquedaCatastral.manager";
45

  
46
    /**
47
     * WebMap manager description.
48
     */
49
    public static final String MANAGER_DESCRIPTION = "BusquedaCatastral Manager";
50

  
51

  
52
    /**
53
     * Unique instance.
54
     */
55
    private static final BusquedaCatastralLocator INSTANCE =
56
        new BusquedaCatastralLocator();
57

  
58
    /**
59
     * Return the singleton instance.
60
     *
61
     * @return the singleton instance
62
     */
63
    public static BusquedaCatastralLocator getInstance() {
64
        return INSTANCE;
65
    }
66

  
67
    /**
68
     * Return the Locator's name.
69
     *
70
     * @return a String with the Locator's name
71
     */
72
    public final String getLocatorName() {
73
        return LOCATOR_NAME;
74
    }
75

  
76
    /**
77
     * Return a reference to the Manager.
78
     *
79
     * @return a reference to the Manager
80
     * @throws LocatorException
81
     *             if there is no access to the class or the class cannot be
82
     *             instantiated
83
     * @see Locator#get(String)
84
     */
85
    public static BusquedaCatastralManager getManager() throws LocatorException {
86
        return (BusquedaCatastralManager) getInstance().get(MANAGER_NAME);
87
    }
88

  
89
    /**
90
     * Registers the Class implementing the WebMapManager interface.
91
     *
92
     * @param clazz
93
     *            implementing the WebMapManager interface
94
     */
95
    public static void registerManager(
96
        Class<? extends BusquedaCatastralManager> clazz) {
97
        getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
98
    }
99

  
100
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/BusquedaCatastralLibrary.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.api;
24

  
25
import org.gvsig.tools.library.AbstractLibrary;
26
import org.gvsig.tools.library.LibraryException;
27
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
28

  
29
/**
30
 * Library for search by catastral data initialization and configuration.
31
 *
32
 * @author gvSIG team
33
 * @version $Id$
34
 */
35
public class BusquedaCatastralLibrary extends AbstractLibrary {
36

  
37
    @Override
38
    public void doRegistration() {
39
        registerAsAPI(BusquedaCatastralLibrary.class);
40
    }
41

  
42
    @Override
43
    protected void doInitialize() throws LibraryException {
44
        // Do nothing
45
    }
46

  
47
    @Override
48
    protected void doPostInitialize() throws LibraryException {
49
        // Validate there is any implementation registered.
50
        BusquedaCatastralManager manager = BusquedaCatastralLocator.getManager();
51
        if (manager == null) {
52
            throw new ReferenceNotRegisteredException(
53
                BusquedaCatastralLocator.MANAGER_NAME, BusquedaCatastralLocator.getInstance());
54
        }
55
    }
56

  
57
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/exceptions/BusquedaCatastralGettingParamsException.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.api.exceptions;
24

  
25
public class BusquedaCatastralGettingParamsException extends BusquedaCatastralException {
26

  
27

  
28
    /**
29
     *
30
     */
31
    private static final long serialVersionUID = 8201868527295813900L;
32

  
33
    private static final String MESSAGE =
34
        "An error has been produced getting busqueda catastral parameters.";
35

  
36
    private static final String KEY = "_BusquedaCatastralGettingParametersException";
37

  
38
    public BusquedaCatastralGettingParamsException(Throwable ex) {
39
        super(MESSAGE, ex, KEY, serialVersionUID);
40
    }
41

  
42
    public BusquedaCatastralGettingParamsException(String message, Throwable ex) {
43
        super(message, ex, KEY, serialVersionUID);
44
    }
45

  
46
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/exceptions/BusquedaCatastralGettingDataException.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.api.exceptions;
24

  
25
public class BusquedaCatastralGettingDataException extends BusquedaCatastralException {
26

  
27

  
28
    /**
29
     *
30
     */
31
    private static final long serialVersionUID = 8201868527295813900L;
32

  
33
    private static final String MESSAGE =
34
        "An error has been produced getting busqueda catastral data.";
35

  
36
    private static final String KEY = "_BusquedaCatastralGettingDataException";
37

  
38
    public BusquedaCatastralGettingDataException(Throwable ex) {
39
        super(MESSAGE, ex, KEY, serialVersionUID);
40
    }
41

  
42
    public BusquedaCatastralGettingDataException(String message, Throwable ex) {
43
        super(message, ex, KEY, serialVersionUID);
44
    }
45

  
46
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/exceptions/BusquedaCatastralInvalidQueryException.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.api.exceptions;
24

  
25
public class BusquedaCatastralInvalidQueryException extends BusquedaCatastralException {
26

  
27

  
28
    /**
29
     *
30
     */
31
    private static final long serialVersionUID = 8201868527295813900L;
32

  
33
    private static final String MESSAGE =
34
        "Invalid query for busqueda catastral";
35

  
36
    private static final String KEY = "_BusquedaCatastralInvalidQueryException";
37

  
38
    public BusquedaCatastralInvalidQueryException(Throwable ex) {
39
        super(MESSAGE, ex, KEY, serialVersionUID);
40
    }
41

  
42
    public BusquedaCatastralInvalidQueryException(String message, Throwable ex) {
43
        super(message, ex, KEY, serialVersionUID);
44
    }
45

  
46
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/exceptions/BusquedaCatastralRemoteServiceException.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.api.exceptions;
24

  
25
public class BusquedaCatastralRemoteServiceException extends BusquedaCatastralException {
26

  
27
    /**
28
     *
29
     */
30
    private static final long serialVersionUID = 4675161371620871100L;
31

  
32
    private static final String MESSAGE =
33
        "An error has been produced accessing catastral server.";
34

  
35
    private static final String KEY = "BusquedaCatastralRemoteServiceException";
36

  
37
    public BusquedaCatastralRemoteServiceException(Throwable ex) {
38
        super(MESSAGE, ex, KEY, serialVersionUID);
39
    }
40

  
41
    public BusquedaCatastralRemoteServiceException(String message, Throwable ex) {
42
        super(message, ex, KEY, serialVersionUID);
43
    }
44

  
45
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/exceptions/BusquedaCatastralInvalidSRSException.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.api.exceptions;
24

  
25
public class BusquedaCatastralInvalidSRSException extends BusquedaCatastralException {
26

  
27

  
28
    /**
29
     *
30
     */
31
    private static final long serialVersionUID = 8201868527295813900L;
32

  
33
    private static final String MESSAGE =
34
        "An error has been produced using an invalid SRS for Busqueda Catastral.";
35

  
36
    private static final String KEY = "_BusquedaCatastralInvalidSRSException";
37

  
38
    public BusquedaCatastralInvalidSRSException(Throwable ex) {
39
        super(MESSAGE, ex, KEY, serialVersionUID);
40
    }
41

  
42
    public BusquedaCatastralInvalidSRSException(String message, Throwable ex) {
43
        super(message, ex, KEY, serialVersionUID);
44
    }
45

  
46
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/exceptions/BusquedaCatastralException.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.api.exceptions;
24

  
25

  
26
import org.gvsig.tools.exception.BaseException;
27

  
28
/**
29
 *
30
 * @author gvSIG team.
31
 *
32
 */
33
public class BusquedaCatastralException extends BaseException {
34

  
35
    /**
36
     *
37
     */
38
    private static final long serialVersionUID = -1043709801185809443L;
39

  
40
    private static final String MESSAGE =
41
        "An error has been produced in the Busqueda Catastral library";
42

  
43
    private static final String KEY = "_WasteException";
44

  
45
    /**
46
     * Constructor to be used in rare cases, usually you must create a new child
47
     * exception class for each case.
48
     * <strong>Don't use this constructor in child classes.</strong>
49
     */
50
    public BusquedaCatastralException() {
51
        super(MESSAGE, KEY, serialVersionUID);
52
    }
53

  
54
    /**
55
     * Constructor to be used in rare cases, usually you must create a new child
56
     * exception class for each case.
57
     * <p>
58
     * <strong>Don't use this constructor in child classes.</strong>
59
     * </p>
60
     *
61
     * @param cause
62
     *            the original cause of the exception
63
     */
64
    public BusquedaCatastralException(Exception cause) {
65
        super(MESSAGE, cause, KEY, serialVersionUID);
66
    }
67

  
68
    /**
69
     * @see BaseException#BaseException(String, String, long).
70
     * @param message
71
     *            the default messageFormat to describe the exception
72
     * @param key
73
     *            the key to use to search a localized messageFormnata
74
     * @param code
75
     *            the unique code to identify the exception
76
     */
77
    protected BusquedaCatastralException(String message, String key, long code) {
78
        super(message, key, code);
79
    }
80

  
81
    /**
82
     * @see BaseException#BaseException(String, Throwable, String, long).
83
     * @param message
84
     *            the default messageFormat to describe the exception
85
     * @param cause
86
     *            the original cause of the exception
87
     * @param key
88
     *            the key to use to search a localized messageFormnata
89
     * @param code
90
     *            the unique code to identify the exception
91
     */
92
    protected BusquedaCatastralException(String message, Throwable cause,
93
        String key, long code) {
94
        super(message, cause, key, code);
95
    }
96

  
97
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/ReferenciaCatastral.java
1
package org.gvsig.busquedacatastral.lib.api;
2

  
3

  
4
public interface ReferenciaCatastral {
5

  
6
    /**
7
     * Gets el codigo de la referencia catastral
8
     * @return
9
     */
10
    public String getRC();
11

  
12

  
13
    /**
14
     * Gets el codigo de la referencia catastral parcial
15
     * (Positions 1-14)
16
     * @return
17
     */
18
    public String getRCParcial();
19

  
20
    /**
21
     * Gets la localizaci?n (bloque/escalera/planta/puerta)
22
     * @return
23
     */
24
    public String getLocalizacion();
25
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.busquedacatastral.lib.api.BusquedaCatastralLibrary
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
 <modelVersion>4.0.0</modelVersion>
3
 <parent>
4
  <groupId>org.gvsig</groupId>
5
  <artifactId>org.gvsig.busquedacatastral.lib</artifactId>
6
  <version>1.0.61</version>
7
 </parent>
8

  
9

  
10
 <artifactId>org.gvsig.busquedacatastral.lib.api</artifactId>
11
 <name>${project.artifactId}</name>
12
 <description>API Library for busqueda catastral in gvSIG 2.1</description>
13

  
14
 <build>
15
  <plugins>
16
   <plugin>
17
    <groupId>org.apache.maven.plugins</groupId>
18
    <artifactId>maven-jar-plugin</artifactId>
19
    <configuration>
20
    </configuration>
21
    <executions>
22
     <!-- Generates a jar file only with the test classes -->
23
     <execution>
24
      <goals>
25
       <goal>test-jar</goal>
26
      </goals>
27
     </execution>
28
    </executions>
29
   </plugin>
30
  </plugins>
31
 </build>
32

  
33
 <dependencies>
34
  <dependency>
35
   <groupId>org.gvsig</groupId>
36
   <artifactId>org.gvsig.tools.lib</artifactId>
37
   <scope>compile</scope>
38
  </dependency>
39
    <dependency>
40
   <groupId>org.gvsig</groupId>
41
   <artifactId>org.gvsig.fmap.geometry.api</artifactId>
42
   <scope>compile</scope>
43
  </dependency>
44

  
45
 </dependencies>
46
</project>
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
  <modelVersion>4.0.0</modelVersion>
3
  <parent>
4
    <groupId>org.gvsig</groupId>
5
    <artifactId>org.gvsig.busquedacatastral</artifactId>
6
    <version>1.0.61</version>
7
  </parent>
8
  <artifactId>org.gvsig.busquedacatastral.lib</artifactId>
9
  <packaging>pom</packaging>
10
  <name>org.gvsig.busquedacatastral.lib</name>
11
  <modules>
12
   <module>org.gvsig.busquedacatastral.lib.api</module>
13
   <module>org.gvsig.busquedacatastral.lib.impl</module>
14
  </modules>
15
</project>
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.busquedacatastral.lib.impl.DefaultBusquedaCatastralLibrary
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/java/org/gvsig/busquedacatastral/lib/impl/ViasFactory.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.CallejeroWSResponse;
21
import org.gvsig.busquedacatastral.lib.impl.ws.classes.MunicipiosWSResponse;
22
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Callejero;
23
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaCallejero;
24
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaMunicipieror;
25
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Df;
26
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Muni;
27
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Municipiero;
28
import org.gvsig.fmap.dal.DataTypes;
29
import org.gvsig.fmap.dal.exception.DataException;
30
import org.gvsig.fmap.dal.feature.EditableFeature;
31
import org.gvsig.fmap.dal.feature.EditableFeatureType;
32
import org.gvsig.fmap.dal.feature.FeatureStore;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.dynobject.DynObject;
35
import org.gvsig.tools.exception.BaseException;
36
import org.gvsig.tools.i18n.I18nManager;
37

  
38
import org.slf4j.Logger;
39
import org.slf4j.LoggerFactory;
40

  
41
public class ViasFactory extends WSObjectsFactory{
42

  
43
    private static final Logger logger = LoggerFactory
44
        .getLogger(ViasFactory.class);
45

  
46
    private final static String VIAS_FILENAME="callejero.dbf";
47

  
48

  
49
    public ViasFactory(BusquedaCatastralManager manager){
50
        super(manager);
51
    }
52

  
53
    private Callejero callejero=null;
54
    private QueryCatastral query;
55
    private String filtro;
56
    public  List<DynObject> getVias(QueryCatastral query) throws BusquedaCatastralException{
57
        this.query=query;
58
        this.filtro=null;
59
        return getVias();
60
    }
61

  
62
    public  List<DynObject> getVias(QueryCatastral query, String filtro) throws BusquedaCatastralException{
63
        this.query=query;
64
        this.filtro=filtro;
65
        return getVias();
66
    }
67

  
68
    private List<DynObject>getVias() throws BusquedaCatastralException{
69
        File viasFile=null;
70

  
71
        try {
72
            if (query==null||query.getProvincia()==null){
73
                logger.error("Provincia no informada");
74
                I18nManager i18nManager = ToolsLocator.getI18nManager();
75
                throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_provincia_not_informed"), null);
76
            }
77
            if (query.getMunicipio()==null){
78
                logger.error("Municipio no informado");
79
                I18nManager i18nManager = ToolsLocator.getI18nManager();
80
                throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_municipio_not_informed"), null);
81
            }
82

  
83
            DynObject provincia=query.getProvincia();
84
            DynObject municipio=query.getMunicipio();
85
            String codProvincia=(String) provincia.getDynValue(BusquedaCatastralManager.CAMPO_PROVINCIA_CODIGO);
86
            String codMunicipio=(String) municipio.getDynValue(BusquedaCatastralManager.CAMPO_MUNICIPIO_MUNICIPIO_INE);
87
            File provinciaFolder=new File(manager.getCacheFolder(),codProvincia);
88
            if (!provinciaFolder.exists()){
89
                provinciaFolder.mkdirs();
90
            }
91
            File municipioFolder=new File(provinciaFolder,codMunicipio);
92
            if (!municipioFolder.exists()){
93
                municipioFolder.mkdirs();
94
            }
95
            viasFile = new File(municipioFolder,VIAS_FILENAME);
96
            if (!viasFile.exists()){
97
                createDBF(viasFile);
98
            }
99
            return this.getListFromDBF(viasFile);
100
        } catch ( BusquedaCatastralException e) {
101
            throw e;
102
        } catch ( Exception e) {
103
            logger.warn("Error getting vias from file '"+viasFile.getAbsolutePath()+"'.",e);
104
            throw new BusquedaCatastralGettingParamsException(e);
105
        }
106
    }
107

  
108
    @Override
109
    protected void defineType(EditableFeatureType type) throws BusquedaCatastralException {
110
        callejero=getCallejero(query);
111
        int maxCodProvINE=1;
112
        int maxCodMuniINE=1;
113
        int maxNombre=1;
114
        int maxTipoVia=1;
115
        int maxCodDGC=1;
116

  
117
        for( Df calle:callejero.getCalle()){
118
            if(StringUtils.isNotEmpty(calle.getLoine().getCp()) && calle.getLoine().getCp().length()>maxCodProvINE){
119
                maxCodProvINE=calle.getLoine().getCp().length();
120
            }
121
            if(StringUtils.isNotEmpty(calle.getLoine().getCm()) && calle.getLoine().getCm().length()>maxCodMuniINE){
122
                maxCodMuniINE=calle.getLoine().getCp().length();
123
            }
124
            if(StringUtils.isNotEmpty(calle.getDir().getNv()) && calle.getDir().getNv().length()>maxNombre){
125
                maxNombre=calle.getDir().getNv().length();
126
            }
127
            if(StringUtils.isNotEmpty(calle.getDir().getTv()) && calle.getDir().getTv().length()>maxTipoVia){
128
                maxTipoVia=calle.getDir().getTv().length();
129
            }
130
            if(StringUtils.isNotEmpty(calle.getDir().getCv()) && calle.getDir().getCv().length()>maxCodDGC){
131
                maxCodDGC=calle.getDir().getCv().length();
132
            }
133

  
134
        }
135
        type.add(BusquedaCatastralManager.CAMPO_VIA_PROV_INE, DataTypes.STRING,
136
            maxCodProvINE).setAllowNull(true);
137
        type.add(BusquedaCatastralManager.CAMPO_VIA_MUNI_INE, DataTypes.STRING,
138
            maxCodMuniINE).setAllowNull(true);
139
        type.add(BusquedaCatastralManager.CAMPO_VIA_NOMBRE, DataTypes.STRING,
140
            maxNombre);
141
        type.add(BusquedaCatastralManager.CAMPO_VIA_TIPOVIA, DataTypes.STRING,
142
            maxTipoVia).setAllowNull(true);
143
        type.add(BusquedaCatastralManager.CAMPO_VIA_COD_DGC, DataTypes.STRING,
144
            maxCodDGC).setAllowNull(true);
145
    }
146

  
147
    @Override
148
    protected void writeFileData(FeatureStore featureStore) throws BusquedaCatastralException, DataException {
149
        callejero=getCallejero(query);
150
        for( Df calle:callejero.getCalle()){
151
            EditableFeature ef;
152
            ef = featureStore.createNewFeature().getEditable();
153
            ef.set(BusquedaCatastralManager.CAMPO_VIA_PROV_INE, calle.getLoine().getCp());
154
            ef.set(BusquedaCatastralManager.CAMPO_VIA_MUNI_INE, calle.getLoine().getCm());
155
            ef.set(BusquedaCatastralManager.CAMPO_VIA_NOMBRE, calle.getDir().getNv());
156
            ef.set(BusquedaCatastralManager.CAMPO_VIA_TIPOVIA, calle.getDir().getTv());
157
            ef.set(BusquedaCatastralManager.CAMPO_VIA_COD_DGC, calle.getDir().getCv());
158
            featureStore.insert(ef);
159
        }
160
        callejero = null;
161
    }
162

  
163
    private Callejero getCallejero(QueryCatastral query) throws BusquedaCatastralException{
164
        if( callejero == null ) {
165
            try {
166
                DynObject provincia=query.getProvincia();
167
                DynObject municipio=query.getMunicipio();
168
                String nombreProvincia=(String) provincia.getDynValue(BusquedaCatastralManager.CAMPO_PROVINCIA_NOMBRE);
169
                String nombreMunicipio=(String) municipio.getDynValue(BusquedaCatastralManager.CAMPO_MUNICIPIO_NOMBRE);
170
                String codProvincia=(String) provincia.getDynValue(BusquedaCatastralManager.CAMPO_PROVINCIA_CODIGO);
171
                CallejeroWSResponse callejeroResponse =getCatastroWS().obtenerCallejero(nombreProvincia, nombreMunicipio, "", "");
172
                if (callejeroResponse!=null){
173
                    MessageElement[] any = callejeroResponse.get_any();
174
                    MessageElement me=any[0];
175
                    JAXBContext jaxbContext = JAXBContext.newInstance(ConsultaCallejero.class);
176

  
177
                    Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
178
                    InputStream input = new ByteArrayInputStream(me.getAsString().getBytes());
179
                    ConsultaCallejero cc = (ConsultaCallejero) jaxbUnmarshaller.unmarshal(input);
180

  
181
                    if (cc!=null && cc.getLerr()!=null){
182
                        webserviceErrors(cc.getLerr().getErr());
183
                    }
184

  
185
                    callejero =  cc.getCallejero();
186
                }else{
187
                    logger.error("Webservice response is empty");
188
                    I18nManager i18nManager = ToolsLocator.getI18nManager();
189
                    throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"),null);
190
                }
191

  
192
            } catch (RemoteException e) {
193
                logger.error("Error accesing webservice",e);
194
                I18nManager i18nManager = ToolsLocator.getI18nManager();
195
                throw new BusquedaCatastralRemoteServiceException(i18nManager.getTranslation("_error_obtaining_catastro_webservice"), e);
196
            } catch (Exception e) {
197
                logger.error("Error marshalling response from webservice",e);
198
                I18nManager i18nManager = ToolsLocator.getI18nManager();
199
                throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"), e);
200
            }
201
        }
202
        return callejero;
203
    }
204

  
205
    @Override
206
    protected String getExpressionQuery() {
207
        if (query.getTipoVia()!=null){
208
            StringBuilder strb=new StringBuilder();
209
            String tipoViaAbrev=query.getTipoVia().getAbrev();
210
            strb.append(BusquedaCatastralManager.CAMPO_VIA_TIPOVIA);
211
            strb.append(" like '");
212
            strb.append(tipoViaAbrev+"'");
213
            if (StringUtils.isNotEmpty(filtro)){
214
                strb.append(" and ");
215
                strb.append(BusquedaCatastralManager.CAMPO_VIA_NOMBRE);
216
                strb.append(" like '%");
217
                strb.append(filtro.toUpperCase()+"%'");
218
            }
219
            return strb.toString();
220
        }
221

  
222
        return null;
223
    }
224

  
225

  
226
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.61/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/java/org/gvsig/busquedacatastral/lib/impl/WSObjectsFactory.java
1
package org.gvsig.busquedacatastral.lib.impl;
2

  
3
import java.io.File;
4
import java.util.List;
5

  
6
import javax.xml.rpc.ServiceException;
7

  
8
import org.apache.commons.lang3.StringUtils;
9

  
10
import org.gvsig.busquedacatastral.lib.api.BusquedaCatastralManager;
11
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralException;
12
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException;
13
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralRemoteServiceException;
14
import org.gvsig.busquedacatastral.lib.impl.ws.CallejeroCatastroWSLocator;
15
import org.gvsig.busquedacatastral.lib.impl.ws.CallejeroCatastroWSSoap;
16
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Err;
17
import org.gvsig.fmap.dal.DALLocator;
18
import org.gvsig.fmap.dal.DataManager;
19
import org.gvsig.fmap.dal.DataServerExplorerParameters;
20
import org.gvsig.fmap.dal.DataStoreParameters;
21
import org.gvsig.fmap.dal.exception.DataException;
22
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
23
import org.gvsig.fmap.dal.feature.EditableFeatureType;
24
import org.gvsig.fmap.dal.feature.FeatureQuery;
25
import org.gvsig.fmap.dal.feature.FeatureSet;
26
import org.gvsig.fmap.dal.feature.FeatureStore;
27
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
28
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
29
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
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
import org.gvsig.tools.locator.LocatorException;
35

  
36
import org.slf4j.Logger;
37
import org.slf4j.LoggerFactory;
38

  
39

  
40
/**
41
 * Used for classes wich need data from the webservice.
42
 * Offers methods to manage webservice and cache files
43
 * @author dmartinezizquierdo
44
 *
45
 */
46
public  abstract class WSObjectsFactory {
47

  
48
    private static final Logger logger = LoggerFactory
49
        .getLogger(WSObjectsFactory.class);
50

  
51
    private final static String DBF_PROVIDER_NAME="DBF";
52

  
53
    protected BusquedaCatastralManager manager;
54

  
55
    protected WSObjectsFactory(BusquedaCatastralManager manager){
56
        this.manager=manager;
57
    }
58

  
59

  
60
    protected CallejeroCatastroWSSoap getCatastroWS() throws BusquedaCatastralException{
61
        try {
62
            CallejeroCatastroWSLocator locator=
63
                new CallejeroCatastroWSLocator();
64
            CallejeroCatastroWSSoap callejeroWS =
65
                locator.getCallejeroCatastroSoap();
66
            return callejeroWS;
67
        } catch (ServiceException e) {
68
            logger.error("Error obtaining webservice",e);
69
            I18nManager i18nManager = ToolsLocator.getI18nManager();
70
            throw new BusquedaCatastralRemoteServiceException(i18nManager.getTranslation("_error_obtaining_catastro_webservice"), e);
71
        }
72
    }
73

  
74
    protected void createDBF(File file)
75
        throws BusquedaCatastralException{
76

  
77
        FeatureStore dbfStore = null;
78
        try {
79
            if (!file.exists()) {
80
                File folder=file.getParentFile();
81
                if (!folder.exists()){
82
                    folder.mkdirs();
83
                }
84
            }
85

  
86
            DataManager datamanager = DALLocator.getDataManager();
87
            DataServerExplorerParameters explorerParameters =
88
                (DataServerExplorerParameters) datamanager
89
                    .createServerExplorerParameters(FilesystemServerExplorer.NAME);
90
            FilesystemServerExplorer explorer =
91
                (FilesystemServerExplorer) datamanager.openServerExplorer(
92
                    FilesystemServerExplorer.NAME, explorerParameters
93
                    );
94

  
95
            NewFeatureStoreParameters addParams = (NewFeatureStoreParameters) explorer.getAddParameters(DBF_PROVIDER_NAME);
96
            addParams.setDynValue("DbfFile",file);
97
            EditableFeatureType type = addParams.getDefaultFeatureType();
98
            defineType(type);
99
            explorer.add(DBF_PROVIDER_NAME, addParams, true);
100

  
101
            DataStoreParameters parameters = datamanager.createStoreParameters(DBF_PROVIDER_NAME);
102
            parameters.setDynValue("DbfFile", file);
103
            dbfStore =
104
                (FeatureStore) datamanager.openStore(DBF_PROVIDER_NAME, parameters);
105
            dbfStore.edit(FeatureStore.MODE_APPEND);
106
            writeFileData(dbfStore);
107

  
108
            dbfStore.finishEditing();
109
            dbfStore.dispose();
110
        } catch (BusquedaCatastralException  e) {
111
            logger.error("Error getting feature store");
112
            I18nManager i18nManager = ToolsLocator.getI18nManager();
113
            if(dbfStore!=null && dbfStore.isEditing()) {
114
                try {
115
                    dbfStore.cancelEditing();
116
                } catch (DataException e1) {
117
                    logger.error("Error cancelling edition of feature store");
118
                    throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_cancelling_edition_of_feature_store"),e);
119
                }
120
            }
121
            throw e;
122
        } catch (Exception  e) {
123
            logger.error("Error getting feature store");
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff