gvsig-raster / org.gvsig.raster.postgis / branches / org.gvsig.raster.postgis_dataaccess_refactoring / org.gvsig.raster.postgis.io / src / main / java / org / gvsig / raster / postgis / io / PostGISRasterDataParameters.java @ 2322
History | View | Annotate | Download (5.58 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.DALLocator; |
26 |
import org.gvsig.fmap.dal.DataManager; |
27 |
import org.gvsig.fmap.dal.DataParameters; |
28 |
import org.gvsig.fmap.dal.exception.InitializeException; |
29 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
30 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
31 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer; |
32 |
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters; |
33 |
import org.gvsig.fmap.dal.store.db.DBStoreParameters; |
34 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
35 |
import org.gvsig.tools.ToolsLocator; |
36 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
37 |
import org.gvsig.tools.dynobject.DynStruct; |
38 |
import org.gvsig.tools.persistence.PersistenceManager; |
39 |
import org.gvsig.tools.persistence.PersistentState; |
40 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
41 |
|
42 |
/**
|
43 |
* Parameters for the PostGIS provider
|
44 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
45 |
*/
|
46 |
public class PostGISRasterDataParameters extends AbstractRasterDataParameters { |
47 |
public static final String DYNCLASS_NAME = "PostGISRasterDataParameters"; |
48 |
protected DelegatedDynObject delegatedDynObject = null; |
49 |
private DBServerExplorer dbServerExplorer = null; |
50 |
|
51 |
public static final String FIELD_DBPARAMS = "DBPARAMS"; |
52 |
public static final String FIELD_DBEXPLORER_PARAMS = "DBEXPLORERPARAMS"; |
53 |
protected static final String FIELD_BLOCKS = "BLOCKS"; |
54 |
|
55 |
public static DynStruct registerDynClass() { |
56 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
57 |
DynStruct definition = manager.getDefinition("PostGISRasterDataParameters_Persistent");
|
58 |
if( definition == null ) { |
59 |
definition = manager.addDefinition( |
60 |
PostGISRasterDataParameters.class, |
61 |
"PostGISRasterDataParameters_Persistent",
|
62 |
"PostGISRasterDataParameters Persistent",
|
63 |
null,
|
64 |
null
|
65 |
); |
66 |
} |
67 |
AbstractRasterDataParameters.registerDynClass(definition); |
68 |
|
69 |
definition.addDynFieldLong(FIELD_BLOCKS) |
70 |
.setDescription("Number of blocks")
|
71 |
.setMandatory(false);
|
72 |
|
73 |
definition.addDynFieldObject(FIELD_DBPARAMS) |
74 |
.setDescription("PostGIS data parameters")
|
75 |
.setClassOfValue(DataParameters.class) |
76 |
.setMandatory(false);
|
77 |
|
78 |
definition.addDynFieldObject(FIELD_DBEXPLORER_PARAMS) |
79 |
.setDescription("PostGIS explorer data parameters")
|
80 |
.setClassOfValue(DataParameters.class) |
81 |
.setMandatory(false);
|
82 |
|
83 |
return definition;
|
84 |
} |
85 |
|
86 |
public void saveToState(PersistentState state) throws PersistenceException { |
87 |
super.saveToState(state);
|
88 |
} |
89 |
|
90 |
public void loadFromState(PersistentState state) throws PersistenceException { |
91 |
super.loadFromState(state);
|
92 |
DataManager dm = DALLocator.getDataManager(); |
93 |
try {
|
94 |
dbServerExplorer = (DBServerExplorer) dm.openServerExplorer( |
95 |
getDBExplorerParameters().getExplorerName(), getDBExplorerParameters()); |
96 |
} catch (ValidateDataParametersException e) {
|
97 |
} catch (InitializeException e) {
|
98 |
} catch (ProviderNotRegisteredException e) {
|
99 |
} |
100 |
} |
101 |
|
102 |
public PostGISRasterDataParameters() {
|
103 |
super();
|
104 |
initialize(); |
105 |
} |
106 |
|
107 |
protected void initialize() { |
108 |
this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
|
109 |
.getDynObjectManager().createDynObject( |
110 |
registerDynClass()); |
111 |
} |
112 |
|
113 |
public String getDataStoreName() { |
114 |
return PostGISRasterProvider.NAME;
|
115 |
} |
116 |
|
117 |
public String getDescription() { |
118 |
return PostGISRasterProvider.DESCRIPTION;
|
119 |
} |
120 |
|
121 |
@Override
|
122 |
protected DelegatedDynObject getDelegatedDynObject() {
|
123 |
return delegatedDynObject;
|
124 |
} |
125 |
|
126 |
public boolean isOverridingHost() { |
127 |
return false; |
128 |
} |
129 |
|
130 |
public void setOverrideHost(boolean over) { |
131 |
|
132 |
} |
133 |
|
134 |
public DBServerExplorerParameters getDBExplorerParameters() {
|
135 |
return (DBServerExplorerParameters) this.getDynValue(FIELD_DBEXPLORER_PARAMS); |
136 |
} |
137 |
|
138 |
public void setDBExplorerParameters(DBServerExplorerParameters dbExplorerParameters) { |
139 |
this.setDynValue(FIELD_DBEXPLORER_PARAMS, dbExplorerParameters);
|
140 |
} |
141 |
|
142 |
public DBStoreParameters getDBStoreParameters() {
|
143 |
return (DBStoreParameters) this.getDynValue(FIELD_DBPARAMS); |
144 |
} |
145 |
|
146 |
public void setDBStoreParameters(DBStoreParameters dbStoreParameters) { |
147 |
this.setDynValue(FIELD_DBPARAMS, dbStoreParameters);
|
148 |
} |
149 |
|
150 |
public DBServerExplorer getDBExplorer() {
|
151 |
return this.dbServerExplorer; |
152 |
} |
153 |
|
154 |
public void setDBExplorer(DBServerExplorer dbServerExplorer) { |
155 |
this.dbServerExplorer = dbServerExplorer;
|
156 |
} |
157 |
|
158 |
/**
|
159 |
* Gets the number of blocks of the selected table
|
160 |
* @return
|
161 |
*/
|
162 |
public long getNumberOfBlocks() { |
163 |
return (Long) this.getDynValue(FIELD_BLOCKS); |
164 |
} |
165 |
|
166 |
/**
|
167 |
* Gets the number of blocks of the selected table
|
168 |
* @param host
|
169 |
*/
|
170 |
public void setNumberOfBlocks(long blocks) { |
171 |
this.setDynValue(FIELD_BLOCKS, blocks);
|
172 |
} |
173 |
} |