Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / DALLibrary.java @ 30580

History | View | Annotate | Download (3.21 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
 * 2008 IVER T.I. S.A.   {{Task}}
26
 */
27
package org.gvsig.fmap.dal;
28

    
29
import org.gvsig.fmap.dal.feature.FeatureStore;
30
import org.gvsig.fmap.dal.resource.ResourceManager;
31
import org.gvsig.tools.ToolsLibrary;
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.dynobject.DynClass;
34
import org.gvsig.tools.dynobject.DynField;
35
import org.gvsig.tools.dynobject.DynObjectManager;
36
import org.gvsig.tools.library.LibraryException;
37
import org.gvsig.tools.library.impl.BaseLibrary;
38
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
39

    
40
/**
41
 * Initializes gvSIG's desktop DAL by registering the default implementation for {@link DataManager}
42
 * and {@link ResourceManager}.
43
 *
44
 */
45
public class DALLibrary extends BaseLibrary {
46

    
47
        protected void doInitialize() throws LibraryException {
48
        }
49

    
50
        protected void doPostInitialize() throws LibraryException {
51
                // Validate there is any implementation registered.
52
                DataManager dataManager = DALLocator.getDataManager();
53
                if (dataManager == null) {
54
                        throw new ReferenceNotRegisteredException(
55
                                        DALLocator.DATA_MANAGER_NAME, DALLocator.getInstance());
56
                }
57

    
58
                ResourceManager resourceManager = DALLocator.getResourceManager();
59
                if (resourceManager == null) {
60
                        throw new ReferenceNotRegisteredException(
61
                                        DALLocator.RESOURCE_MANAGER_NAME, DALLocator.getInstance());
62
                }
63
                
64
                DynObjectManager dynManager = ToolsLocator.getDynObjectManager();
65

    
66
                DynField field;
67
                DynClass dataStoreDynClass = dynManager.get(DataStore.DYNCLASS_NAME);
68

    
69
                if (dataStoreDynClass == null) {
70
                        dataStoreDynClass = dynManager.add(DataStore.DYNCLASS_NAME);
71

    
72
                        field = dataStoreDynClass.addDynField("DefaultSRS");
73
                        field.setType(DataTypes.SRS);
74
                        field.setDescription("Spatial Referencing System");
75

    
76
                        field = dataStoreDynClass.addDynField("Envelope");
77
                        field.setType(DataTypes.OBJECT); // FIXME ???
78
                        field.setDescription("Envelope");
79
                }
80

    
81
                DynClass featureStoreDynClass = dynManager
82
                                .get(FeatureStore.DYNCLASS_NAME);
83

    
84
                if (featureStoreDynClass == null) {
85
                        featureStoreDynClass = dynManager.add(FeatureStore.DYNCLASS_NAME);
86

    
87
                        featureStoreDynClass.extend(dataStoreDynClass);
88

    
89
                        //                        XXX ???
90
                        //                        field = featureStoreDynClass.addDynField("nativeGeometrySupported");
91
                        //                        field.setType(DataTypes.STRING);
92
                        //                        field.setDescription("Goemtry data type is supported natively");
93
                }
94
        }
95
}