Statistics
| Revision:

gvsig-raster / org.gvsig.raster.postgis / trunk / org.gvsig.raster.postgis / org.gvsig.raster.postgis.io / src / main / java / org / gvsig / raster / postgis / io / PostGISRasterDataParameters.java @ 956

History | View | Annotate | Download (5.6 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
package org.gvsig.raster.postgis.io;
24

    
25
import org.gvsig.fmap.dal.DataParameters;
26
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer;
27
import org.gvsig.raster.impl.store.AbstractRasterDataParameters;
28
import org.gvsig.tools.ToolsLocator;
29
import org.gvsig.tools.dynobject.DelegatedDynObject;
30
import org.gvsig.tools.dynobject.DynClass;
31
import org.gvsig.tools.dynobject.DynField;
32
import org.gvsig.tools.dynobject.DynObjectManager;
33
import org.gvsig.tools.dynobject.DynStruct;
34
import org.gvsig.tools.persistence.PersistenceManager;
35
import org.gvsig.tools.persistence.PersistentState;
36
import org.gvsig.tools.persistence.exception.PersistenceException;
37

    
38
/**
39
 * Parameters for the PostGIS provider
40
 * @author Nacho Brodin (nachobrodin@gmail.com)
41
 */
42
public class PostGISRasterDataParameters extends AbstractRasterDataParameters {
43
        public static final String         DYNCLASS_NAME                = "PostGISRasterDataParameters";
44
        protected DelegatedDynObject       delegatedDynObject           = null;
45
        private static DynClass            DYNCLASS                     = null;
46
        public static final String         FIELD_DBPARAMS               = "DBPARAMS";
47
        public static final String         FIELD_DBEXPLORER             = "DBEXPLORER";
48
        protected static final String      FIELD_BLOCKS                 = "BLOCKS";
49
        
50
        public static void registerDynClass() {
51
                DynObjectManager dynman = ToolsLocator.getDynObjectManager();
52
                DynClass dynClass;
53
                DynField field;
54
                
55
                if(dynman == null)
56
                        return;
57
                
58
                if (DYNCLASS == null) {
59
                        dynClass = AbstractRasterDataParameters.registerDynClass(DYNCLASS_NAME);
60
                        
61
                        field = dynClass.addDynFieldObject(FIELD_DBPARAMS);
62
                        field.setDescription("Parameters for the selected table");
63
                        field.setClassOfValue(Object.class);
64
                        field.setMandatory(false);
65
                        
66
                        field = dynClass.addDynFieldObject(FIELD_DBEXPLORER);
67
                        field.setDescription("Explorer for databases");
68
                        field.setClassOfValue(Object.class);
69
                        field.setMandatory(false);
70
                        
71
                        field = dynClass.addDynFieldLong(FIELD_BLOCKS);
72
                        field.setDescription("Number of blocks of the selected table.");
73
                        field.setClassOfValue(Long.class);
74
                        field.setMandatory(true);
75
                        
76
                        DYNCLASS = dynClass;
77
                }
78
        }
79
        
80
        public PostGISRasterDataParameters() {
81
                super();
82
                initialize();
83
        }
84
        
85
        protected void initialize() {
86
                this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
87
                                .getDynObjectManager().createDynObject(
88
                                                DYNCLASS);
89
        }
90
        
91
        /*
92
         * (non-Javadoc)
93
         * @see org.gvsig.fmap.dal.DataStoreParameters#getDataStoreName()
94
         */
95
        public String getDataStoreName() {
96
                return PostGISRasterProvider.NAME;
97
        }
98

    
99
        /*
100
         * (non-Javadoc)
101
         * @see org.gvsig.fmap.dal.DataStoreParameters#getDescription()
102
         */
103
        public String getDescription() {
104
                return PostGISRasterProvider.DESCRIPTION;
105
        }
106

    
107
        /*
108
         * (non-Javadoc)
109
         * @see org.gvsig.raster.impl.store.AbstractRasterDataParameters#loadFromState(org.gvsig.tools.persistence.PersistentState)
110
         */
111
        public void loadFromState(PersistentState state)
112
        throws PersistenceException {
113
                super.loadFromState(state);
114
        }
115

    
116
        /*
117
         * (non-Javadoc)
118
         * @see org.gvsig.raster.impl.store.AbstractRasterDataParameters#saveToState(org.gvsig.tools.persistence.PersistentState)
119
         */
120
        public void saveToState(PersistentState state) throws PersistenceException {
121
                super.saveToState(state);
122
        }        
123

    
124
        public static void registerPersistence() {
125
                PersistenceManager manager = ToolsLocator.getPersistenceManager();
126
                DynStruct definition = manager.getDefinition("PostGISRasterDataParameters_Persistent");
127
                if( definition == null ) {
128
                        definition = manager.addDefinition(
129
                                        PostGISRasterDataParameters.class,
130
                                        "PostGISRasterDataParameters_Persistent",
131
                                        "PostGISRasterDataParameters Persistent",
132
                                        null, 
133
                                        null
134
                        );
135
                        AbstractRasterDataParameters.registerPersistence(definition);
136
                }
137
        }
138

    
139
        @Override
140
        protected DelegatedDynObject getDelegatedDynObject() {
141
                return delegatedDynObject;
142
        }
143

    
144
        public boolean isOverridingHost() {
145
                return false;
146
        }
147

    
148
        public void setOverrideHost(boolean over) {
149
                
150
        }
151
        
152
        public DataParameters getDBStoreParameters() {
153
                return (DataParameters) this.getDynValue(FIELD_DBPARAMS);
154
        }
155
        
156
        public void setDBStoreParameters(DataParameters dbStoreParameters) {
157
                this.setDynValue(FIELD_DBPARAMS, dbStoreParameters);
158
        }
159
        
160
        public DBServerExplorer getDBExplorer() {
161
                return (DBServerExplorer) this.getDynValue(FIELD_DBEXPLORER);
162
        }
163
        
164
        public void setDBExplorer(DBServerExplorer dbStoreParameters) {
165
                this.setDynValue(FIELD_DBEXPLORER, dbStoreParameters);
166
        }
167
        
168
        /**
169
         * Gets the number of blocks of the selected table
170
         * @return
171
         */
172
        public long getNumberOfBlocks() {
173
                return (Long) this.getDynValue(FIELD_BLOCKS);
174
        }
175

    
176
        /**
177
         * Gets the number of blocks of the selected table
178
         * @param host
179
         */
180
        public void setNumberOfBlocks(long blocks) {
181
                this.setDynValue(FIELD_BLOCKS, blocks);
182
        }
183
}