Revision 202

View differences:

org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.1/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.BusquedaCatastralGettingDataException;
30
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException;
31
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralInvalidSRSException;
32
import org.gvsig.fmap.geom.primitive.Point;
33
import org.gvsig.tools.dynobject.DynObject;
34

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

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

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

  
66

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

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

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

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

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

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

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

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

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

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

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

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

  
150
       /**
151
        * Devuelve los datos catastrales de la parcela en el punto indicado
152
        * @param p
153
        * @return DynObject
154
        */
155
       public DynObject getDatosCatastrales(Point p, SRSCatastro srs)throws BusquedaCatastralGettingDataException, BusquedaCatastralInvalidSRSException;
156

  
157
       /**
158
        * Devuelve los datos catastrales del codigo de la referencia catastral
159
        * @param rc
160
        * @return DynObject
161
        */
162
       public DynObject getDatosCatastrales(String rc)throws BusquedaCatastralGettingDataException;
163

  
164
       public File getCacheFolder();
165

  
166
       public void setCacheFolder(File cacheFolder);
167
}
168

  
169

  
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.1/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.1/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.1/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.1</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.1/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.1</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.1/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.1/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.1/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
import org.gvsig.busquedacatastral.lib.api.BusquedaCatastralManager;
16
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException;
17
import org.gvsig.busquedacatastral.lib.impl.ws.classes.ProvinciasWSResponse;
18
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaProvincieror;
19
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Err;
20
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Prov;
21
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Provinciero;
22
import org.gvsig.fmap.dal.DataTypes;
23
import org.gvsig.fmap.dal.exception.DataException;
24
import org.gvsig.fmap.dal.feature.EditableFeature;
25
import org.gvsig.fmap.dal.feature.EditableFeatureType;
26
import org.gvsig.fmap.dal.feature.FeatureStore;
27
import org.gvsig.tools.ToolsLocator;
28
import org.gvsig.tools.dynobject.DynObject;
29
import org.gvsig.tools.exception.BaseException;
30
import org.gvsig.tools.i18n.I18nManager;
31
import org.slf4j.Logger;
32
import org.slf4j.LoggerFactory;
33

  
34
public class ProvinciasFactory extends WSObjectsFactory{
35

  
36
    private static final Logger logger = LoggerFactory
37
        .getLogger(ProvinciasFactory.class);
38

  
39
    private final static String PROVINCIAS_FILENAME="provincias.dbf";
40

  
41

  
42
    public ProvinciasFactory(BusquedaCatastralManager manager){
43
        super(manager);
44
    }
45

  
46
    private Provinciero provinciero=null;
47
    public  List<DynObject> getProvincias() throws BusquedaCatastralGettingParamsException{
48
        //TODO
49
        //1.-Ver si existe fichero en tmp
50
        //2.- Si no existe
51
        //  2.1.- consulta web para obtener provinciero
52
        //  2.2.- generar archivo a partir de provinciero
53
        //3.-Leer fichero con listado de provincias
54
        //  3.1.- Por cada registro en provincia, construir un DynObject
55
        //4.-Devolver listado de DynObject
56

  
57
        File provinciasFile=null;
58

  
59
        try {
60
            provinciasFile = new File(manager.getCacheFolder(),PROVINCIAS_FILENAME);
61
            if (!provinciasFile.exists()){
62
                createDBF(provinciasFile);
63
            }
64
            return this.getListFromDBF(provinciasFile);
65
        } catch ( BaseException e) {
66
            logger.warn("Error getting provincias from file '"+provinciasFile.getAbsolutePath()+"'.",e);
67
            throw new BusquedaCatastralGettingParamsException(e);
68
        }
69
    }
70

  
71

  
72
    @Override
73
    protected void defineType(EditableFeatureType type) throws BusquedaCatastralGettingParamsException {
74
        provinciero=getProvinciero();
75
        int maxNombre=0;
76
        int maxCodigo=0;
77
        for(Prov prov:provinciero.getProv()){
78
            if(StringUtils.isNotEmpty(prov.getNp()) && prov.getNp().length()>maxNombre){
79
                maxNombre=prov.getNp().length();
80
            }
81
            if(StringUtils.isNotEmpty(prov.getCpine()) && prov.getCpine().length()>maxCodigo){
82
                maxCodigo=prov.getCpine().length();
83
            }
84
        }
85
        type.add(BusquedaCatastralManager.CAMPO_PROVINCIA_NOMBRE, DataTypes.STRING,
86
            maxNombre);
87
        type.add(BusquedaCatastralManager.CAMPO_PROVINCIA_CODIGO, DataTypes.STRING,
88
            maxCodigo);
89
    }
90

  
91
    @Override
92
    protected void writeFileData(FeatureStore featureStore) throws BusquedaCatastralGettingParamsException, DataException {
93
        provinciero=getProvinciero();
94
        for(Prov prov:provinciero.getProv()){
95
            EditableFeature ef;
96
            ef = featureStore.createNewFeature().getEditable();
97
            ef.set(BusquedaCatastralManager.CAMPO_PROVINCIA_NOMBRE, prov.getNp());
98
            ef.set(BusquedaCatastralManager.CAMPO_PROVINCIA_CODIGO, prov.getCpine());
99
            featureStore.insert(ef);
100
        }
101
        provinciero = null;
102
    }
103

  
104
    private Provinciero getProvinciero() throws BusquedaCatastralGettingParamsException{
105
        if( provinciero == null ) {
106
            try {
107
                ProvinciasWSResponse provincias = getCatastroWS().obtenerProvincias();
108
                if (provincias!=null){
109
                    MessageElement[] any = provincias.get_any();
110
                    MessageElement me=any[0];
111
                    JAXBContext jaxbContext = JAXBContext.newInstance(ConsultaProvincieror.class);
112

  
113
                    Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
114
                    InputStream input = new ByteArrayInputStream(me.getAsString().getBytes());
115
                    ConsultaProvincieror cp = (ConsultaProvincieror) jaxbUnmarshaller.unmarshal(input);
116

  
117
                    if (cp!=null && cp.getLerr()!=null){
118
                        webserviceErrors(cp.getLerr().getErr());
119
                    }
120

  
121
                    provinciero =  cp.getProvinciero();
122
                }else{
123
                    logger.error("Webservice response is empty");
124
                    I18nManager i18nManager = ToolsLocator.getI18nManager();
125
                    throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"),null);
126
                }
127

  
128
            } catch (RemoteException e) {
129
                logger.error("Error accesing webservice",e);
130
                I18nManager i18nManager = ToolsLocator.getI18nManager();
131
                throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_obtaining_catastro_webservice"), e);
132
            } catch (Exception e) {
133
                logger.error("Error marshalling response from webservice",e);
134
                I18nManager i18nManager = ToolsLocator.getI18nManager();
135
                throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"), e);
136
            }
137
        }
138
        return provinciero;
139
    }
140

  
141

  
142
    @Override
143
    protected String getExpressionQuery() {
144
        return null;
145
    }
146

  
147

  
148
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.1/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
import org.gvsig.busquedacatastral.lib.api.BusquedaCatastralManager;
17
import org.gvsig.busquedacatastral.lib.api.QueryCatastral;
18
import org.gvsig.busquedacatastral.lib.api.QueryCatastral.TipoParcela;
19
import org.gvsig.busquedacatastral.lib.api.QueryCatastral.TipoQuery;
20
import org.gvsig.busquedacatastral.lib.api.ReferenciaCatastral;
21
import org.gvsig.busquedacatastral.lib.api.TipoVia;
22
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException;
23
import org.gvsig.busquedacatastral.lib.impl.ws.classes.ConsultaDNPPPWSResponse;
24
import org.gvsig.busquedacatastral.lib.impl.ws.classes.ConsultaDNPWSResponse;
25
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Bico;
26
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaDnp;
27
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Dt;
28
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Lors;
29
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Lorus;
30
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Lourb;
31
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Lous;
32
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Lrcdnp;
33
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Rc;
34
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Rcdnp;
35
import org.gvsig.fmap.dal.exception.DataException;
36
import org.gvsig.fmap.dal.feature.EditableFeatureType;
37
import org.gvsig.fmap.dal.feature.FeatureStore;
38
import org.gvsig.tools.ToolsLocator;
39
import org.gvsig.tools.dynobject.DynObject;
40
import org.gvsig.tools.i18n.I18nManager;
41
import org.slf4j.Logger;
42
import org.slf4j.LoggerFactory;
43

  
44
public class ReferenciasCatastralesFactory extends WSObjectsFactory{
45

  
46
    private static final Logger logger = LoggerFactory
47
        .getLogger(ReferenciasCatastralesFactory.class);
48

  
49

  
50
    public ReferenciasCatastralesFactory(BusquedaCatastralManager manager){
51
        super(manager);
52
    }
53

  
54

  
55
    public List<ReferenciaCatastral> getReferencias(QueryCatastral query) throws BusquedaCatastralGettingParamsException{
56
        ConsultaDnp consultaDatosNoPrivados=null;
57

  
58
        if (query==null){
59
            logger.error("Query no valida");
60
            I18nManager i18nManager = ToolsLocator.getI18nManager();
61
            throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_invalid_query"), null);
62
        }else{
63
            if ( TipoQuery.POR_RC.equals(query.getTipoQuery()) ){
64
                consultaDatosNoPrivados =getReferenciasByRC(query.getReferenciaCatastral());
65
            }else if( TipoQuery.POR_LOCALIZACION.equals(query.getTipoQuery()) ){
66
                if (TipoParcela.URBANA.equals(query.getTipoParcela())){
67
                    consultaDatosNoPrivados =getReferenciasUrbanas(query);
68
                }else if (TipoParcela.RUSTICA.equals(query.getTipoParcela())){
69
                    consultaDatosNoPrivados =getReferenciasRusticas(query);
70
                }else{
71
                    logger.error("Tipo parcela invalido");
72
                    I18nManager i18nManager = ToolsLocator.getI18nManager();
73
                    throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_tipo_parcela_not_informed"), null);
74
                }
75
            } else{
76
                logger.error("Tipo query invalido");
77
                I18nManager i18nManager = ToolsLocator.getI18nManager();
78
                throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_tipo_query_not_informed"), null);
79
            }
80

  
81
            if (consultaDatosNoPrivados!=null && consultaDatosNoPrivados.getLerr()!=null){
82
                webserviceErrors(consultaDatosNoPrivados.getLerr().getErr());
83
            }
84

  
85
            return  new ArrayList( createReferenciasCatastrales( consultaDatosNoPrivados) );
86

  
87
        }
88
    }
89

  
90
    private Set<ReferenciaCatastral> createReferenciasCatastrales(ConsultaDnp consultaDatosNoPrivados){
91
        Set<ReferenciaCatastral> results=new HashSet<ReferenciaCatastral>();
92
        if ( consultaDatosNoPrivados.getLrcdnp()!=null ){
93
            getReferenciasCatastralesFrom(consultaDatosNoPrivados.getLrcdnp());
94
            results.addAll( getReferenciasCatastralesFrom(consultaDatosNoPrivados.getLrcdnp()) );
95
        }
96
        if ( consultaDatosNoPrivados.getBico()!=null ){
97
            DefaultReferenciaCatastral refCatastral=getReferenciaCatastralFrom(consultaDatosNoPrivados.getBico());
98
            if (refCatastral!=null){
99
                results.add(refCatastral);
100
            }
101
        }
102
        return results;
103
    }
104

  
105
    private DefaultReferenciaCatastral getReferenciaCatastralFrom(Bico bico){
106
        if ( bico!=null ){
107
            DefaultReferenciaCatastral refCatastral=new DefaultReferenciaCatastral();
108
            if (bico.getBi()!=null){
109
                if( bico.getBi().getIdbi()!=null ){
110
                    fillReferenciaCatastralFrom(bico.getBi().getIdbi().getRc(), refCatastral);
111
                }
112
                if ( bico.getBi().getDt()!=null ){
113
                    fillReferenciaCatastralFrom(bico.getBi().getDt(), refCatastral);
114
                }
115
            }
116
            return refCatastral;
117
        }else{
118
            return null;
119
        }
120
    }
121

  
122
    private Set<ReferenciaCatastral> getReferenciasCatastralesFrom(Lrcdnp lrcdnp){
123
        Set<ReferenciaCatastral> results=new HashSet<ReferenciaCatastral>();
124
        for ( Rcdnp rcdnp:lrcdnp.getRcdnp()){
125
            if(rcdnp!=null){
126
                DefaultReferenciaCatastral refCatastral=new DefaultReferenciaCatastral();
127
                if (rcdnp.getRc()!=null){
128
                    fillReferenciaCatastralFrom(rcdnp.getRc(), refCatastral);
129
                }
130
                if (rcdnp.getDt()!=null){
131
                    fillReferenciaCatastralFrom(rcdnp.getDt(), refCatastral);
132
                }
133
            results.add(refCatastral);
134
            }
135
        }
136
        return results;
137
    }
138

  
139
    private void fillReferenciaCatastralFrom(Rc rc, DefaultReferenciaCatastral refCatastral){
140
        if (rc!=null){
141
            refCatastral.setPc1(rc.getPc1());
142
            refCatastral.setPc2(rc.getPc2());
143
            refCatastral.setCar(rc.getCar());
144
            refCatastral.setDc1(rc.getCc1());
145
            refCatastral.setDc2(rc.getCc2());
146
        }
147
    }
148

  
149
    private void fillReferenciaCatastralFrom(Dt dt, DefaultReferenciaCatastral refCatastral){
150
        if (dt!=null){
151
            refCatastral.setProvincia(dt.getNp());
152
            refCatastral.setMunicipio(dt.getNm());
153
            if (dt.getLocs()!=null){
154
                if (dt.getLocs().getLous()!=null){
155
                    Lous lous=dt.getLocs().getLous();
156
                    if (lous.getLourb()!=null){
157
                        //Urbana
158
                        Lourb lourb=lous.getLourb();
159
                        fillReferenciaCatastralFrom(lourb, refCatastral);
160
                    }
161
                    if(lous.getLorus()!=null && lous.getLorus().getCpp()!=null){
162
                        Lorus lorus=lous.getLorus();
163
                        fillReferenciaCatastralFrom(lorus, refCatastral);;
164
                    }
165
                }
166
                if (dt.getLocs().getLors()!=null){
167
                    Lors lors=dt.getLocs().getLors();
168
                    if (lors.getLourb()!=null){
169
                        //Urbana
170
                        Lourb lourb=lors.getLourb();
171
                        fillReferenciaCatastralFrom(lourb, refCatastral);
172
                    }
173
                    if(lors.getLorus()!=null && lors.getLorus().getCpp()!=null){
174
                        Lorus lorus=lors.getLorus();
175
                        fillReferenciaCatastralFrom(lorus, refCatastral);
176
                    }
177
                }
178
            }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff