svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extOracleSpatial / src / org / gvsig / oraclespatial / utils / OraEpsgTableLoader.java @ 29563
History | View | Annotate | Download (2.92 KB)
1 | 29563 | vsanjaime | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
4 | * of the Valencian Government (CIT)
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | */
|
||
22 | |||
23 | /*
|
||
24 | * AUTHORS (In addition to CIT):
|
||
25 | * 2009 Prodevelop S.L. main development
|
||
26 | */
|
||
27 | |||
28 | package org.gvsig.oraclespatial.utils; |
||
29 | |||
30 | import java.io.File; |
||
31 | |||
32 | import org.gvsig.fmap.dal.DALLocator; |
||
33 | import org.gvsig.fmap.dal.DataManager; |
||
34 | import org.gvsig.fmap.dal.exception.InitializeException; |
||
35 | import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
||
36 | import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
||
37 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
38 | import org.gvsig.fmap.dal.store.dbf.DBFStoreParameters; |
||
39 | import org.gvsig.fmap.dal.store.dbf.DBFStoreProvider; |
||
40 | import org.slf4j.Logger; |
||
41 | import org.slf4j.LoggerFactory; |
||
42 | |||
43 | import com.iver.andami.PluginServices; |
||
44 | |||
45 | /**
|
||
46 | * Oracle EPSG table loader
|
||
47 | *
|
||
48 | * @author jldominguez, vsanjaime
|
||
49 | *
|
||
50 | */
|
||
51 | |||
52 | public class OraEpsgTableLoader { |
||
53 | |||
54 | private static Logger logger = LoggerFactory |
||
55 | .getLogger(OraEpsgTableLoader.class); |
||
56 | public static final String ORACLE_EPSG_FILE_NAME = "ORA_EPSG.DBF"; |
||
57 | |||
58 | /**
|
||
59 | * create and load in the library the Oracle Epsg data store
|
||
60 | *
|
||
61 | * @return srsStore
|
||
62 | * @throws ProviderNotRegisteredException
|
||
63 | * @throws InitializeException
|
||
64 | * @throws ValidateDataParametersException
|
||
65 | */
|
||
66 | public FeatureStore createOracleEpsgTable() throws InitializeException, |
||
67 | ProviderNotRegisteredException, ValidateDataParametersException { |
||
68 | |||
69 | DataManager manager = DALLocator.getDataManager(); |
||
70 | |||
71 | FeatureStore srsStore = null;
|
||
72 | |||
73 | PluginServices ps = PluginServices.getPluginServices(this);
|
||
74 | String baseDir = ps.getClassLoader().getBaseDir();
|
||
75 | String sfile = baseDir + File.separator + "dbf" + File.separator |
||
76 | + ORACLE_EPSG_FILE_NAME; |
||
77 | |||
78 | File file = new File(sfile); |
||
79 | |||
80 | if (file == null) { |
||
81 | logger.error("Error getting the SRS Oracle file......");
|
||
82 | } else {
|
||
83 | |||
84 | DBFStoreParameters dbfParams = null;
|
||
85 | |||
86 | dbfParams = (DBFStoreParameters) manager |
||
87 | .createStoreParameters(DBFStoreProvider.NAME); |
||
88 | dbfParams.setDBFFile(file); |
||
89 | |||
90 | srsStore = (FeatureStore) manager.createStore(dbfParams); |
||
91 | } |
||
92 | |||
93 | return srsStore;
|
||
94 | } |
||
95 | |||
96 | } |