Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.oracle / src / org / gvsig / oracle / utils / OraEpsgTableLoader.java @ 29865

History | View | Annotate | Download (2.92 KB)

1
/* 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.oracle.utils;
29

    
30
import java.io.File;
31

    
32

    
33
import org.gvsig.andami.PluginServices;
34
import org.gvsig.fmap.dal.DALLocator;
35
import org.gvsig.fmap.dal.DataManager;
36
import org.gvsig.fmap.dal.exception.InitializeException;
37
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
38
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
39
import org.gvsig.fmap.dal.feature.FeatureStore;
40
import org.gvsig.fmap.dal.store.dbf.DBFStoreParameters;
41
import org.gvsig.fmap.dal.store.dbf.DBFStoreProvider;
42
import org.slf4j.Logger;
43
import org.slf4j.LoggerFactory;
44

    
45

    
46
/**
47
 * Oracle EPSG table loader
48
 * 
49
 * @author jldominguez, vsanjaime
50
 * 
51
 */
52

    
53
public class OraEpsgTableLoader {
54

    
55
        private static Logger logger = LoggerFactory
56
                        .getLogger(OraEpsgTableLoader.class);
57
        public static final String ORACLE_EPSG_FILE_NAME = "ORA_EPSG.DBF";
58

    
59
        /**
60
         * create and load in the library the Oracle Epsg data store
61
         * 
62
         * @return srsStore
63
         * @throws ProviderNotRegisteredException
64
         * @throws InitializeException
65
         * @throws ValidateDataParametersException
66
         */
67
        public FeatureStore createOracleEpsgTable() throws InitializeException,
68
                        ProviderNotRegisteredException, ValidateDataParametersException {
69

    
70
                DataManager manager = DALLocator.getDataManager();
71

    
72
                FeatureStore srsStore = null;
73

    
74
                PluginServices ps = PluginServices.getPluginServices(this);
75
                String baseDir = ps.getClassLoader().getBaseDir();
76
                String sfile = baseDir + File.separator + "sridOra" + File.separator
77
                                + ORACLE_EPSG_FILE_NAME;
78

    
79
                File file = new File(sfile);
80

    
81
                if (file == null) {
82
                        logger.error("Error getting the SRS Oracle file......");
83
                } else {
84

    
85
                        DBFStoreParameters dbfParams = null;
86

    
87
                        dbfParams = (DBFStoreParameters) manager
88
                                        .createStoreParameters(DBFStoreProvider.NAME);
89
                        dbfParams.setDBFFile(file);
90

    
91
                        srsStore = (FeatureStore) manager.createStore(dbfParams);
92
                }
93

    
94
                return srsStore;
95
        }
96

    
97
}