svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.db / org.gvsig.fmap.dal.db.lib / src / main / java / org / gvsig / fmap / dal / store / db / DBNewStoreParameters.java @ 46338
History | View | Annotate | Download (5.23 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.fmap.dal.store.db; |
25 |
|
26 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
27 |
import org.gvsig.fmap.dal.feature.FeatureType; |
28 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
29 |
import org.gvsig.fmap.dal.serverexplorer.db.DBConnectionParameter; |
30 |
import org.gvsig.fmap.dal.spi.AbstractDataStoreParameters; |
31 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
32 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
33 |
|
34 |
|
35 |
/**
|
36 |
* Abstract Data base Store Parameters
|
37 |
*
|
38 |
* @author jmvivo
|
39 |
*
|
40 |
*/
|
41 |
public abstract class DBNewStoreParameters extends AbstractDataStoreParameters |
42 |
implements NewFeatureStoreParameters, DBConnectionParameter {
|
43 |
|
44 |
public static final String PARAMETERS_DEFINITION_NAME = "DBNewStoreParameters"; |
45 |
|
46 |
|
47 |
/**
|
48 |
* Parameter name for the name of <code>table</code><br>
|
49 |
*
|
50 |
* @see #getTable()
|
51 |
* @see #setTable(String)
|
52 |
*/
|
53 |
public static final String TABLE_PARAMTER_NAME = "Table"; |
54 |
|
55 |
/**
|
56 |
* This instance contains the value of the current parameters.
|
57 |
*/
|
58 |
private DelegatedDynObject parameters;
|
59 |
|
60 |
public DBNewStoreParameters(String parametersDefinitionName, String providerName) { |
61 |
this.parameters = (DelegatedDynObject) DBHelper.newParameters(parametersDefinitionName);
|
62 |
this.setDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME, providerName);
|
63 |
} |
64 |
|
65 |
protected DelegatedDynObject getDelegatedDynObject() {
|
66 |
return parameters;
|
67 |
} |
68 |
|
69 |
public String getDataStoreName() { |
70 |
return (String) this.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME); |
71 |
} |
72 |
|
73 |
public String getDescription() { |
74 |
return this.getDynClass().getDescription(); |
75 |
} |
76 |
|
77 |
public boolean isValid() { |
78 |
return this.getHost() != null; |
79 |
} |
80 |
|
81 |
public String getHost() { |
82 |
return (String) this.getDynValue(HOST_PARAMTER_NAME); |
83 |
} |
84 |
|
85 |
public Integer getPort() { |
86 |
return (Integer) this.getDynValue(PORT_PARAMTER_NAME); |
87 |
} |
88 |
|
89 |
public String getDBName() { |
90 |
return (String) this.getDynValue(DBNAME_PARAMTER_NAME); |
91 |
} |
92 |
|
93 |
public String getUser() { |
94 |
return (String) this.getDynValue(USER_PARAMTER_NAME); |
95 |
} |
96 |
|
97 |
public String getPassword() { |
98 |
return (String) this.getDynValue(PASSWORD_PARAMTER_NAME); |
99 |
} |
100 |
|
101 |
public void setHost(String host) { |
102 |
this.setDynValue(HOST_PARAMTER_NAME, host);
|
103 |
} |
104 |
|
105 |
public void setPort(int port) { |
106 |
this.setDynValue(PORT_PARAMTER_NAME, new Integer(port)); |
107 |
} |
108 |
|
109 |
/**
|
110 |
* Set <code>port/code> parameter value
|
111 |
*
|
112 |
* @param port
|
113 |
*/
|
114 |
public void setPort(Integer port) { |
115 |
this.setDynValue(PORT_PARAMTER_NAME, port);
|
116 |
} |
117 |
|
118 |
/**
|
119 |
* Set <code>data base name/code> parameter value
|
120 |
*
|
121 |
* @param data
|
122 |
* base name
|
123 |
*/
|
124 |
public void setDBName(String dbName) { |
125 |
this.setDynValue(DBNAME_PARAMTER_NAME, dbName);
|
126 |
} |
127 |
|
128 |
/**
|
129 |
* Set <code>user/code> parameter value
|
130 |
*
|
131 |
* @param user
|
132 |
*/
|
133 |
public void setUser(String user) { |
134 |
this.setDynValue(USER_PARAMTER_NAME, user);
|
135 |
} |
136 |
|
137 |
/**
|
138 |
* Set <code>password/code> parameter value
|
139 |
*
|
140 |
* @param password
|
141 |
*/
|
142 |
public void setPassword(String password) { |
143 |
this.setDynValue(PASSWORD_PARAMTER_NAME, password);
|
144 |
} |
145 |
|
146 |
@Override
|
147 |
public EditableFeatureType getDefaultFeatureType() {
|
148 |
return (EditableFeatureType) this.getDynValue(FEATURETYPE_PARAMTER_NAME); |
149 |
} |
150 |
|
151 |
@Override
|
152 |
public void setDefaultFeatureType(FeatureType featureType) { |
153 |
if( !(featureType instanceof EditableFeatureType) ) { |
154 |
this.setDynValue(FEATURETYPE_PARAMTER_NAME, featureType.getEditable());
|
155 |
} else {
|
156 |
this.setDynValue(FEATURETYPE_PARAMTER_NAME, featureType);
|
157 |
} |
158 |
} |
159 |
|
160 |
/**
|
161 |
* Get <code>table</code> parameter value<br>
|
162 |
* <br>
|
163 |
*
|
164 |
* This parameters describes what table we want to create.<br>
|
165 |
*
|
166 |
* @see #setTable(String)
|
167 |
*/
|
168 |
public String getTable() { |
169 |
return (String) this.getDynValue(TABLE_PARAMTER_NAME); |
170 |
} |
171 |
|
172 |
/**
|
173 |
* Set <code>table</code> parameter value<br>
|
174 |
* <br>
|
175 |
*
|
176 |
* This parameters describes what table we want to create.<br>
|
177 |
*
|
178 |
* @param table
|
179 |
*
|
180 |
* @see #getTable(String)
|
181 |
*/
|
182 |
public void setTable(String table) { |
183 |
this.setDynValue(TABLE_PARAMTER_NAME, table);
|
184 |
} |
185 |
} |