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.jdbc / src / main / java / org / gvsig / fmap / dal / store / jdbc / JDBCNewStoreParameters.java @ 45507
History | View | Annotate | Download (6.19 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 modify it under
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
9 |
* version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
14 |
* details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License along with
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
21 |
* gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.fmap.dal.store.jdbc; |
24 |
|
25 |
import org.apache.commons.lang3.StringUtils; |
26 |
import org.gvsig.fmap.dal.store.db.DBNewStoreParameters; |
27 |
|
28 |
import static org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters.CATALOG_PARAMTER_NAME; |
29 |
import static org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters.JDBC_DRIVER_CLASS_PARAMTER_NAME; |
30 |
import static org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters.SCHEMA_PARAMTER_NAME; |
31 |
|
32 |
public class JDBCNewStoreParameters extends DBNewStoreParameters implements |
33 |
JDBCConnectionParameters { |
34 |
|
35 |
public static final String PARAMETERS_DEFINITION_NAME = "JDBCNewStoreParameters"; |
36 |
|
37 |
public JDBCNewStoreParameters() {
|
38 |
super(PARAMETERS_DEFINITION_NAME, JDBCStoreProvider.NAME);
|
39 |
} |
40 |
|
41 |
protected JDBCNewStoreParameters(String parametersDefinitionName, String providerName) { |
42 |
super(parametersDefinitionName, providerName);
|
43 |
} |
44 |
|
45 |
/**
|
46 |
* Set <code>JDBC Driver class name</code> parameter
|
47 |
*
|
48 |
* @param className
|
49 |
*/
|
50 |
public void setJDBCDriverClassName(String className) { |
51 |
this.setDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME, className);
|
52 |
} |
53 |
|
54 |
public String getJDBCDriverClassName() { |
55 |
return (String) this.getDynValue(JDBC_DRIVER_CLASS_PARAMTER_NAME); |
56 |
} |
57 |
|
58 |
public String getCatalog() { |
59 |
return (String) this.getDynValue(CATALOG_PARAMTER_NAME); |
60 |
} |
61 |
|
62 |
/**
|
63 |
* Set <code>catalog</code> parameter
|
64 |
*
|
65 |
* @param className
|
66 |
*/
|
67 |
public void setCatalog(String catalog) { |
68 |
this.setDynValue(CATALOG_PARAMTER_NAME, catalog);
|
69 |
} |
70 |
|
71 |
public String getSchema() { |
72 |
return (String) this.getDynValue(SCHEMA_PARAMTER_NAME); |
73 |
} |
74 |
|
75 |
/**
|
76 |
* Set <code>schema</code> parameter
|
77 |
*
|
78 |
* @param className
|
79 |
*/
|
80 |
public void setSchema(String schema) { |
81 |
this.setDynValue(SCHEMA_PARAMTER_NAME, schema);
|
82 |
} |
83 |
|
84 |
public String getUrl() { |
85 |
return (String) this.getDynValue(URL_PARAMTER_NAME); |
86 |
} |
87 |
|
88 |
@Override
|
89 |
public int getBatchSize() { |
90 |
try {
|
91 |
return (int) this.getDynValue(BATCH_SIZE_PARAMETER_NAME); |
92 |
} catch(Exception ex) { |
93 |
return DEFAULT_BATCH_SIZE;
|
94 |
} |
95 |
} |
96 |
|
97 |
/**
|
98 |
* Set <code>JDBC connection url</code> parameter
|
99 |
*
|
100 |
* @param url
|
101 |
*/
|
102 |
public void setUrl(String url) { |
103 |
this.setDynValue(URL_PARAMTER_NAME, url);
|
104 |
} |
105 |
|
106 |
/**
|
107 |
* Return table <code>name</code> or <code>schema.tableName</code> if
|
108 |
* <code>schema</code> parameter is set.
|
109 |
*
|
110 |
* @return
|
111 |
*/
|
112 |
public String tableID() { |
113 |
if (this.getSchema() == null || this.getSchema() == "") { |
114 |
return escapeName(this.getTable()); |
115 |
} |
116 |
return escapeName(this.getSchema()) + "." + escapeName(this.getTable()); |
117 |
} |
118 |
|
119 |
protected String escapeName(String name) { |
120 |
return "\"".concat(name).concat("\""); |
121 |
} |
122 |
|
123 |
public String getSelectRole() { |
124 |
String value = (String) this.getDynValue("SelectRole"); |
125 |
return StringUtils.defaultIfBlank(value, null); |
126 |
} |
127 |
|
128 |
public String getInsertRole() { |
129 |
String value = (String) this.getDynValue("InsertRole"); |
130 |
return StringUtils.defaultIfBlank(value, null); |
131 |
} |
132 |
|
133 |
|
134 |
public String getUpdateRole() { |
135 |
String value = (String) this.getDynValue("UpdateRole"); |
136 |
return StringUtils.defaultIfBlank(value, null); |
137 |
} |
138 |
|
139 |
|
140 |
public String getDeleteRole() { |
141 |
String value = (String) this.getDynValue("DeleteRole"); |
142 |
return StringUtils.defaultIfBlank(value, null); |
143 |
} |
144 |
|
145 |
|
146 |
public String getTruncateRole() { |
147 |
String value = (String) this.getDynValue("TruncateRole"); |
148 |
return StringUtils.defaultIfBlank(value, null); |
149 |
} |
150 |
|
151 |
|
152 |
public String getReferenceRole() { |
153 |
String value = (String) this.getDynValue("ReferenceRole"); |
154 |
return StringUtils.defaultIfBlank(value, null); |
155 |
} |
156 |
|
157 |
|
158 |
public String getTriggerRole() { |
159 |
String value = (String) this.getDynValue("TriggerRole"); |
160 |
return StringUtils.defaultIfBlank(value, null); |
161 |
} |
162 |
|
163 |
|
164 |
public String getAllRole() { |
165 |
String value = (String) this.getDynValue("AllRole"); |
166 |
return StringUtils.defaultIfBlank(value, null); |
167 |
} |
168 |
|
169 |
|
170 |
public String getPostCreatingStatement() { |
171 |
String value = (String) this.getDynValue("PostCreatingStatement"); |
172 |
return StringUtils.defaultIfBlank(value, null); |
173 |
} |
174 |
|
175 |
|
176 |
public void setSelectRole(String role) { |
177 |
this.setDynValue("SelectRole", role); |
178 |
} |
179 |
|
180 |
public void setInsertRole(String role) { |
181 |
this.setDynValue("InsertRole", role); |
182 |
} |
183 |
|
184 |
public void setUpdateRole(String role) { |
185 |
this.setDynValue("UpdateRole", role); |
186 |
} |
187 |
|
188 |
public void setDeleteRole(String role) { |
189 |
this.setDynValue("DeleteRole", role); |
190 |
} |
191 |
|
192 |
public void setTruncateRole(String role) { |
193 |
this.setDynValue("TruncateRole", role); |
194 |
} |
195 |
|
196 |
public void setReferenceRole(String role) { |
197 |
this.setDynValue("ReferenceRole", role); |
198 |
} |
199 |
|
200 |
public void setTriggerRole(String role) { |
201 |
this.setDynValue("TriggerRole", role); |
202 |
} |
203 |
|
204 |
public void setAllRole(String role) { |
205 |
this.setDynValue("AllRole", role); |
206 |
} |
207 |
|
208 |
public void setPostCreatingStatement(String statement) { |
209 |
this.setDynValue("PostCreatingStatement", statement); |
210 |
} |
211 |
} |