Revision 43739
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/ExpressionBuilderBase.java | ||
---|---|---|
13 | 13 |
import org.apache.commons.lang3.ObjectUtils; |
14 | 14 |
import org.apache.commons.lang3.StringUtils; |
15 | 15 |
import org.cresques.cts.IProjection; |
16 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
17 |
import org.gvsig.fmap.dal.DataTypes; |
|
16 | 18 |
import org.gvsig.fmap.dal.ExpressionBuilder; |
17 | 19 |
import org.gvsig.fmap.dal.ExpressionBuilder.BinaryOperator; |
18 | 20 |
import org.gvsig.fmap.dal.ExpressionBuilder.Config; |
... | ... | |
29 | 31 |
import org.gvsig.fmap.dal.ExpressionBuilder.Visitable; |
30 | 32 |
import org.gvsig.fmap.dal.ExpressionBuilder.Visitor; |
31 | 33 |
import org.gvsig.fmap.dal.ExpressionBuilder.VisitorFilter; |
34 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
32 | 36 |
import org.gvsig.fmap.geom.Geometry; |
33 | 37 |
import org.gvsig.fmap.geom.primitive.Envelope; |
34 | 38 |
|
... | ... | |
198 | 202 |
return MessageFormat.format(config.getString(Config.group), this.value.toString()); |
199 | 203 |
} |
200 | 204 |
} |
205 |
protected class ColumnDescriptorBase implements ColumnDescriptor { |
|
201 | 206 |
|
207 |
private String name; |
|
208 |
private int type; |
|
209 |
private int type_p; |
|
210 |
private int type_s; |
|
211 |
private boolean isPk; |
|
212 |
private boolean _allowNulls; |
|
213 |
private boolean _isAutomatic; |
|
214 |
private Object defaultValue; |
|
215 |
private int geom_type; |
|
216 |
private int geom_subtype; |
|
217 |
private Object geom_srsdbcode; |
|
218 |
private boolean _isIndexed; |
|
219 |
private DataStoreParameters parameters = null; |
|
220 |
|
|
221 |
public ColumnDescriptorBase(String name, int type, Object defaultValue) { |
|
222 |
this.name = name; |
|
223 |
this.type = type; |
|
224 |
this.type_p = -1; |
|
225 |
this.type_s = -1; |
|
226 |
this.isPk = false; |
|
227 |
this._allowNulls = true; |
|
228 |
this._isAutomatic = false; |
|
229 |
this.defaultValue = defaultValue; |
|
230 |
this.geom_type = Geometry.TYPES.GEOMETRY; |
|
231 |
this.geom_subtype = Geometry.SUBTYPES.GEOM2D; |
|
232 |
this.geom_srsdbcode = null; |
|
233 |
this._isIndexed = false; |
|
234 |
} |
|
235 |
|
|
236 |
public ColumnDescriptorBase(String name, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) { |
|
237 |
this.name = name; |
|
238 |
this.type = type; |
|
239 |
this.type_p = type_p; |
|
240 |
this.type_s = type_s; |
|
241 |
this.isPk = isPk; |
|
242 |
this._allowNulls = allowNulls; |
|
243 |
this._isAutomatic = isAutomatic; |
|
244 |
this.defaultValue = defaultValue; |
|
245 |
this.geom_type = Geometry.TYPES.GEOMETRY; |
|
246 |
this.geom_subtype = Geometry.SUBTYPES.GEOM2D; |
|
247 |
this.geom_srsdbcode = null; |
|
248 |
this._isIndexed = isIndexed; |
|
249 |
} |
|
250 |
|
|
251 |
public ColumnDescriptorBase(String name, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls) { |
|
252 |
this.name = name; |
|
253 |
this.type = DataTypes.GEOMETRY; |
|
254 |
this.type_p = 0; |
|
255 |
this.type_s = 0; |
|
256 |
this.isPk = false; |
|
257 |
this._allowNulls = allowNulls; |
|
258 |
this._isAutomatic = false; |
|
259 |
this.defaultValue = null; |
|
260 |
this.geom_type = geom_type; |
|
261 |
this.geom_subtype = geom_subtype; |
|
262 |
this.geom_srsdbcode = getSRSId(proj); |
|
263 |
this._isIndexed = isIndexed; |
|
264 |
} |
|
265 |
|
|
266 |
public ColumnDescriptorBase(String name, int geom_type, int geom_subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls) { |
|
267 |
this.name = name; |
|
268 |
this.type = DataTypes.GEOMETRY; |
|
269 |
this.type_p = 0; |
|
270 |
this.type_s = 0; |
|
271 |
this.isPk = false; |
|
272 |
this._allowNulls = allowNulls; |
|
273 |
this._isAutomatic = false; |
|
274 |
this.defaultValue = null; |
|
275 |
this.geom_type = geom_type; |
|
276 |
this.geom_subtype = geom_subtype; |
|
277 |
this.geom_srsdbcode = srsdbcode; |
|
278 |
this._isIndexed = isIndexed; |
|
279 |
} |
|
280 |
|
|
281 |
@Override |
|
282 |
public String getName() { |
|
283 |
return this.name; |
|
284 |
} |
|
285 |
|
|
286 |
@Override |
|
287 |
public void setName(String name) { |
|
288 |
this.name = name; |
|
289 |
} |
|
290 |
|
|
291 |
@Override |
|
292 |
public int getType() { |
|
293 |
return this.type; |
|
294 |
} |
|
295 |
|
|
296 |
@Override |
|
297 |
public void setType(int type) { |
|
298 |
this.type = type; |
|
299 |
} |
|
300 |
|
|
301 |
@Override |
|
302 |
public int getPrecision() { |
|
303 |
return type_p; |
|
304 |
} |
|
305 |
|
|
306 |
@Override |
|
307 |
public void setPrecision(int precision) { |
|
308 |
this.type_p = precision; |
|
309 |
} |
|
310 |
|
|
311 |
@Override |
|
312 |
public int getSize() { |
|
313 |
return type_s; |
|
314 |
} |
|
315 |
|
|
316 |
@Override |
|
317 |
public void setSize(int size) { |
|
318 |
this.type_s = size; |
|
319 |
} |
|
320 |
|
|
321 |
@Override |
|
322 |
public boolean isPrimaryKey() { |
|
323 |
return isPk; |
|
324 |
} |
|
325 |
|
|
326 |
@Override |
|
327 |
public void setIsPrimaryKey(boolean isPk) { |
|
328 |
this.isPk = isPk; |
|
329 |
} |
|
330 |
|
|
331 |
@Override |
|
332 |
public boolean allowNulls() { |
|
333 |
return _allowNulls; |
|
334 |
} |
|
335 |
|
|
336 |
@Override |
|
337 |
public void setAllowNulls(boolean allowNulls) { |
|
338 |
this._allowNulls = allowNulls; |
|
339 |
} |
|
340 |
|
|
341 |
@Override |
|
342 |
public boolean isAutomatic() { |
|
343 |
return _isAutomatic; |
|
344 |
} |
|
345 |
|
|
346 |
@Override |
|
347 |
public boolean isIndexed() { |
|
348 |
return _isIndexed; |
|
349 |
} |
|
350 |
|
|
351 |
@Override |
|
352 |
public void setIsAutomatic(boolean isAutomatic) { |
|
353 |
this._isAutomatic = isAutomatic; |
|
354 |
} |
|
355 |
|
|
356 |
@Override |
|
357 |
public Object getDefaultValue() { |
|
358 |
return defaultValue; |
|
359 |
} |
|
360 |
|
|
361 |
@Override |
|
362 |
public void setDefaultValue(Object defaultValue) { |
|
363 |
this.defaultValue = defaultValue; |
|
364 |
} |
|
365 |
|
|
366 |
@Override |
|
367 |
public int getGeometryType() { |
|
368 |
return geom_type; |
|
369 |
} |
|
370 |
|
|
371 |
@Override |
|
372 |
public void setGeometryType(int geom_type) { |
|
373 |
this.geom_type = geom_type; |
|
374 |
} |
|
375 |
|
|
376 |
@Override |
|
377 |
public int getGeometrySubtype() { |
|
378 |
return geom_subtype; |
|
379 |
} |
|
380 |
|
|
381 |
@Override |
|
382 |
public void setGeometrySubtype(int geom_subtype) { |
|
383 |
this.geom_subtype = geom_subtype; |
|
384 |
} |
|
385 |
|
|
386 |
@Override |
|
387 |
public Object getGeometrySRSId() { |
|
388 |
return geom_srsdbcode; |
|
389 |
} |
|
390 |
|
|
391 |
@Override |
|
392 |
public void setGeometrySRSId(Object geom_srsid) { |
|
393 |
this.geom_srsdbcode = geom_srsid; |
|
394 |
} |
|
395 |
|
|
396 |
@Override |
|
397 |
public boolean isGeometry() { |
|
398 |
return this.type == DataTypes.GEOMETRY; |
|
399 |
} |
|
400 |
|
|
401 |
private void setStoreParameters(DataStoreParameters parameters) { |
|
402 |
this.parameters = parameters; |
|
403 |
} |
|
404 |
|
|
405 |
@Override |
|
406 |
public DataStoreParameters getStoreParameters() { |
|
407 |
return this.parameters; |
|
408 |
} |
|
409 |
} |
|
410 |
|
|
202 | 411 |
public class VariableBase extends AbstractValue implements Variable { |
203 | 412 |
|
204 | 413 |
protected String name; |
414 |
protected ColumnDescriptor descriptor; |
|
205 | 415 |
|
416 |
public VariableBase(ColumnDescriptor descriptor) { |
|
417 |
this.descriptor = descriptor; |
|
418 |
this.name = descriptor.getName(); |
|
419 |
} |
|
420 |
|
|
206 | 421 |
public VariableBase(String name) { |
422 |
this.descriptor = null; |
|
207 | 423 |
this.name = name; |
208 | 424 |
} |
209 | 425 |
|
210 | 426 |
@Override |
427 |
public ColumnDescriptor getDescriptor() { |
|
428 |
return descriptor; |
|
429 |
} |
|
430 |
|
|
431 |
@Override |
|
211 | 432 |
public String getName() { |
212 | 433 |
return this.name; |
213 | 434 |
} |
... | ... | |
780 | 1001 |
public Variable column(String name) { |
781 | 1002 |
return new VariableBase(name); |
782 | 1003 |
} |
783 |
|
|
1004 |
|
|
784 | 1005 |
@Override |
1006 |
public Variable column(FeatureAttributeDescriptor fad) { |
|
1007 |
ColumnDescriptorBase descriptor; |
|
1008 |
if( fad.getType()==org.gvsig.fmap.geom.DataTypes.GEOMETRY ) { |
|
1009 |
descriptor = new ColumnDescriptorBase( |
|
1010 |
fad.getName(), |
|
1011 |
fad.getGeomType().getType(), |
|
1012 |
fad.getGeomType().getSubType(), |
|
1013 |
fad.getSRS(), |
|
1014 |
fad.isIndexed(), |
|
1015 |
fad.allowNull() |
|
1016 |
); |
|
1017 |
} else { |
|
1018 |
descriptor = new ColumnDescriptorBase( |
|
1019 |
fad.getName(), |
|
1020 |
fad.getType(), |
|
1021 |
fad.getSize(), |
|
1022 |
fad.getPrecision(), |
|
1023 |
fad.isPrimaryKey(), |
|
1024 |
fad.isIndexed(), |
|
1025 |
fad.allowNull(), |
|
1026 |
fad.isAutomatic(), |
|
1027 |
fad.getDefaultValue() |
|
1028 |
); |
|
1029 |
} |
|
1030 |
FeatureStore store = fad.getStore(); |
|
1031 |
if( store!=null ) { |
|
1032 |
descriptor.setStoreParameters(store.getParameters()); |
|
1033 |
} |
|
1034 |
return new VariableBase(descriptor); |
|
1035 |
} |
|
1036 |
|
|
1037 |
@Override |
|
785 | 1038 |
public Parameter parameter(String name) { |
786 | 1039 |
Parameters parameters = this.getParameters(); |
787 | 1040 |
Parameter parameter = parameters.get(name); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/SQLBuilderBase.java | ||
---|---|---|
31 | 31 |
import org.gvsig.fmap.dal.SQLBuilder.UpdateBuilder; |
32 | 32 |
import org.gvsig.fmap.dal.SQLBuilder.UpdateColumnBuilder; |
33 | 33 |
import org.gvsig.fmap.dal.SQLBuilder.UpdateTableStatisticsBuilder; |
34 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
34 | 35 |
import org.gvsig.fmap.dal.feature.spi.ExpressionBuilderBase.AbstractValue; |
35 | 36 |
import org.gvsig.fmap.geom.Geometry; |
36 | 37 |
import org.slf4j.Logger; |
... | ... | |
52 | 53 |
protected CreateIndexBuilder create_index; |
53 | 54 |
protected List<Parameter> parameters; |
54 | 55 |
|
55 |
protected class ColumnDescriptorBuilderBase implements ColumnDescriptorBuilder { |
|
56 |
|
|
57 |
private String name; |
|
58 |
private int type; |
|
59 |
private int type_p; |
|
60 |
private int type_s; |
|
61 |
private boolean isPk; |
|
62 |
private boolean _allowNulls; |
|
63 |
private boolean _isAutomatic; |
|
64 |
private Object defaultValue; |
|
65 |
private int geom_type; |
|
66 |
private int geom_subtype; |
|
67 |
private Object geom_srsdbcode; |
|
68 |
private boolean _isIndexed; |
|
69 |
|
|
70 |
public ColumnDescriptorBuilderBase(String name, int type, Object defaultValue) { |
|
71 |
this.name = name; |
|
72 |
this.type = type; |
|
73 |
this.type_p = -1; |
|
74 |
this.type_s = -1; |
|
75 |
this.isPk = false; |
|
76 |
this._allowNulls = true; |
|
77 |
this._isAutomatic = false; |
|
78 |
this.defaultValue = defaultValue; |
|
79 |
this.geom_type = Geometry.TYPES.GEOMETRY; |
|
80 |
this.geom_subtype = Geometry.SUBTYPES.GEOM2D; |
|
81 |
this.geom_srsdbcode = null; |
|
82 |
this._isIndexed = false; |
|
83 |
} |
|
84 |
|
|
85 |
public ColumnDescriptorBuilderBase(String name, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) { |
|
86 |
this.name = name; |
|
87 |
this.type = type; |
|
88 |
this.type_p = type_p; |
|
89 |
this.type_s = type_s; |
|
90 |
this.isPk = isPk; |
|
91 |
this._allowNulls = allowNulls; |
|
92 |
this._isAutomatic = isAutomatic; |
|
93 |
this.defaultValue = defaultValue; |
|
94 |
this.geom_type = Geometry.TYPES.GEOMETRY; |
|
95 |
this.geom_subtype = Geometry.SUBTYPES.GEOM2D; |
|
96 |
this.geom_srsdbcode = null; |
|
97 |
this._isIndexed = isIndexed; |
|
98 |
} |
|
99 |
|
|
100 |
public ColumnDescriptorBuilderBase(String name, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls) { |
|
101 |
this.name = name; |
|
102 |
this.type = DataTypes.GEOMETRY; |
|
103 |
this.type_p = 0; |
|
104 |
this.type_s = 0; |
|
105 |
this.isPk = false; |
|
106 |
this._allowNulls = allowNulls; |
|
107 |
this._isAutomatic = false; |
|
108 |
this.defaultValue = null; |
|
109 |
this.geom_type = geom_type; |
|
110 |
this.geom_subtype = geom_subtype; |
|
111 |
this.geom_srsdbcode = getSRSId(proj); |
|
112 |
this._isIndexed = isIndexed; |
|
113 |
} |
|
114 |
|
|
115 |
public ColumnDescriptorBuilderBase(String name, int geom_type, int geom_subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls) { |
|
116 |
this.name = name; |
|
117 |
this.type = DataTypes.GEOMETRY; |
|
118 |
this.type_p = 0; |
|
119 |
this.type_s = 0; |
|
120 |
this.isPk = false; |
|
121 |
this._allowNulls = allowNulls; |
|
122 |
this._isAutomatic = false; |
|
123 |
this.defaultValue = null; |
|
124 |
this.geom_type = geom_type; |
|
125 |
this.geom_subtype = geom_subtype; |
|
126 |
this.geom_srsdbcode = srsdbcode; |
|
127 |
this._isIndexed = isIndexed; |
|
128 |
} |
|
129 |
|
|
130 |
@Override |
|
131 |
public String getName() { |
|
132 |
return this.name; |
|
133 |
} |
|
134 |
|
|
135 |
@Override |
|
136 |
public void setName(String name) { |
|
137 |
this.name = name; |
|
138 |
} |
|
139 |
|
|
140 |
@Override |
|
141 |
public int getType() { |
|
142 |
return this.type; |
|
143 |
} |
|
144 |
|
|
145 |
@Override |
|
146 |
public void setType(int type) { |
|
147 |
this.type = type; |
|
148 |
} |
|
149 |
|
|
150 |
@Override |
|
151 |
public int getPrecision() { |
|
152 |
return type_p; |
|
153 |
} |
|
154 |
|
|
155 |
@Override |
|
156 |
public void setPrecision(int precision) { |
|
157 |
this.type_p = precision; |
|
158 |
} |
|
159 |
|
|
160 |
@Override |
|
161 |
public int getSize() { |
|
162 |
return type_s; |
|
163 |
} |
|
164 |
|
|
165 |
@Override |
|
166 |
public void setSize(int size) { |
|
167 |
this.type_s = size; |
|
168 |
} |
|
169 |
|
|
170 |
@Override |
|
171 |
public boolean isPrimaryKey() { |
|
172 |
return isPk; |
|
173 |
} |
|
174 |
|
|
175 |
@Override |
|
176 |
public void setIsPrimaryKey(boolean isPk) { |
|
177 |
this.isPk = isPk; |
|
178 |
} |
|
179 |
|
|
180 |
@Override |
|
181 |
public boolean allowNulls() { |
|
182 |
return _allowNulls; |
|
183 |
} |
|
184 |
|
|
185 |
@Override |
|
186 |
public void setAllowNulls(boolean allowNulls) { |
|
187 |
this._allowNulls = allowNulls; |
|
188 |
} |
|
189 |
|
|
190 |
@Override |
|
191 |
public boolean isAutomatic() { |
|
192 |
return _isAutomatic; |
|
193 |
} |
|
194 |
|
|
195 |
@Override |
|
196 |
public boolean isIndexed() { |
|
197 |
return _isIndexed; |
|
198 |
} |
|
199 |
|
|
200 |
@Override |
|
201 |
public void setIsAutomatic(boolean isAutomatic) { |
|
202 |
this._isAutomatic = isAutomatic; |
|
203 |
} |
|
204 |
|
|
205 |
@Override |
|
206 |
public Object getDefaultValue() { |
|
207 |
return defaultValue; |
|
208 |
} |
|
209 |
|
|
210 |
@Override |
|
211 |
public void setDefaultValue(Object defaultValue) { |
|
212 |
this.defaultValue = defaultValue; |
|
213 |
} |
|
214 |
|
|
215 |
@Override |
|
216 |
public int getGeometryType() { |
|
217 |
return geom_type; |
|
218 |
} |
|
219 |
|
|
220 |
@Override |
|
221 |
public void setGeometryType(int geom_type) { |
|
222 |
this.geom_type = geom_type; |
|
223 |
} |
|
224 |
|
|
225 |
@Override |
|
226 |
public int getGeometrySubtype() { |
|
227 |
return geom_subtype; |
|
228 |
} |
|
229 |
|
|
230 |
@Override |
|
231 |
public void setGeometrySubtype(int geom_subtype) { |
|
232 |
this.geom_subtype = geom_subtype; |
|
233 |
} |
|
234 |
|
|
235 |
@Override |
|
236 |
public Object getGeometrySRSId() { |
|
237 |
return geom_srsdbcode; |
|
238 |
} |
|
239 |
|
|
240 |
@Override |
|
241 |
public void setGeometrySRSId(Object geom_srsid) { |
|
242 |
this.geom_srsdbcode = geom_srsid; |
|
243 |
} |
|
244 |
|
|
245 |
@Override |
|
246 |
public boolean isGeometry() { |
|
247 |
return this.type == DataTypes.GEOMETRY; |
|
248 |
} |
|
249 |
|
|
250 |
} |
|
251 |
|
|
252 |
|
|
253 | 56 |
public class TableNameBuilderBase implements TableNameBuilder { |
254 | 57 |
|
255 | 58 |
public String tableName; |
... | ... | |
1309 | 1112 |
|
1310 | 1113 |
protected TableNameBuilder table; |
1311 | 1114 |
protected List<String> drops; |
1312 |
protected List<ColumnDescriptorBuilderBase> adds;
|
|
1313 |
protected List<ColumnDescriptorBuilderBase> alters;
|
|
1115 |
protected List<ColumnDescriptor> adds; |
|
1116 |
protected List<ColumnDescriptor> alters; |
|
1314 | 1117 |
protected List<Pair<String,String>> renames; |
1315 | 1118 |
|
1316 | 1119 |
public AlterTableBuilderBase() { |
... | ... | |
1351 | 1154 |
this.drops.add(columnName); |
1352 | 1155 |
return this; |
1353 | 1156 |
} |
1157 |
|
|
1158 |
@Override |
|
1159 |
public AlterTableBuilder add_column(FeatureAttributeDescriptor fad) { |
|
1160 |
this.adds.add(column(fad).getDescriptor()); |
|
1161 |
return this; |
|
1162 |
} |
|
1354 | 1163 |
|
1355 | 1164 |
@Override |
1356 | 1165 |
public AlterTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) { |
1357 | 1166 |
if (isPk || isAutomatic) { |
1358 | 1167 |
allowNulls = false; |
1359 | 1168 |
} |
1360 |
this.adds.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue));
|
|
1169 |
this.adds.add(new ColumnDescriptorBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue)); |
|
1361 | 1170 |
return this; |
1362 | 1171 |
} |
1363 | 1172 |
|
... | ... | |
1366 | 1175 |
if( StringUtils.isEmpty(columnName) ) { |
1367 | 1176 |
throw new IllegalArgumentException("Argument 'columnName' can't be empty."); |
1368 | 1177 |
} |
1369 |
this.adds.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, proj, isIndexed, allowNulls));
|
|
1178 |
this.adds.add(new ColumnDescriptorBase(columnName, type, subtype, proj, isIndexed, allowNulls)); |
|
1370 | 1179 |
return this; |
1371 | 1180 |
} |
1372 | 1181 |
|
... | ... | |
1375 | 1184 |
if( StringUtils.isEmpty(columnName) ) { |
1376 | 1185 |
throw new IllegalArgumentException("Argument 'columnName' can't be empty."); |
1377 | 1186 |
} |
1378 |
this.adds.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls));
|
|
1187 |
this.adds.add(new ColumnDescriptorBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls)); |
|
1379 | 1188 |
return this; |
1380 | 1189 |
} |
1381 |
|
|
1190 |
|
|
1382 | 1191 |
@Override |
1192 |
public AlterTableBuilder alter_column(FeatureAttributeDescriptor fad) { |
|
1193 |
this.alters.add(column(fad).getDescriptor()); |
|
1194 |
return this; |
|
1195 |
} |
|
1196 |
|
|
1197 |
@Override |
|
1383 | 1198 |
public AlterTableBuilder alter_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) { |
1384 | 1199 |
if (isPk || isAutomatic) { |
1385 | 1200 |
allowNulls = false; |
1386 | 1201 |
} |
1387 |
this.alters.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue));
|
|
1202 |
this.alters.add(new ColumnDescriptorBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue)); |
|
1388 | 1203 |
return this; |
1389 | 1204 |
} |
1390 | 1205 |
|
... | ... | |
1393 | 1208 |
if( StringUtils.isEmpty(columnName) ) { |
1394 | 1209 |
throw new IllegalArgumentException("Argument 'columnName' can't be empty."); |
1395 | 1210 |
} |
1396 |
this.alters.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, proj, isIndexed, allowNulls));
|
|
1211 |
this.alters.add(new ColumnDescriptorBase(columnName, type, subtype, proj, isIndexed, allowNulls)); |
|
1397 | 1212 |
return this; |
1398 | 1213 |
} |
1399 | 1214 |
|
... | ... | |
1402 | 1217 |
if( StringUtils.isEmpty(columnName) ) { |
1403 | 1218 |
throw new IllegalArgumentException("Argument 'columnName' can't be empty."); |
1404 | 1219 |
} |
1405 |
this.alters.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls));
|
|
1220 |
this.alters.add(new ColumnDescriptorBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls)); |
|
1406 | 1221 |
return this; |
1407 | 1222 |
} |
1408 | 1223 |
|
... | ... | |
1444 | 1259 |
builder.append(identifier(column)); |
1445 | 1260 |
sqls.add(builder.toString()); |
1446 | 1261 |
} |
1447 |
for (ColumnDescriptorBuilderBase column : adds) {
|
|
1262 |
for (ColumnDescriptor column : adds) { |
|
1448 | 1263 |
StringBuilder builder = new StringBuilder(); |
1449 | 1264 |
builder.append("ALTER TABLE "); |
1450 | 1265 |
builder.append(this.table.toString()); |
... | ... | |
1483 | 1298 |
} |
1484 | 1299 |
sqls.add(builder.toString()); |
1485 | 1300 |
} |
1486 |
for (ColumnDescriptorBuilderBase column : alters) {
|
|
1301 |
for (ColumnDescriptor column : alters) { |
|
1487 | 1302 |
StringBuilder builder = new StringBuilder(); |
1488 | 1303 |
builder.append("ALTER TABLE "); |
1489 | 1304 |
builder.append(this.table.toString()); |
... | ... | |
1534 | 1349 |
public class CreateTableBuilderBase implements CreateTableBuilder { |
1535 | 1350 |
|
1536 | 1351 |
protected TableNameBuilder table; |
1537 |
protected List<ColumnDescriptorBuilderBase> columns;
|
|
1352 |
protected List<ColumnDescriptor> columns; |
|
1538 | 1353 |
|
1539 | 1354 |
public CreateTableBuilderBase() { |
1540 | 1355 |
this.columns = new ArrayList<>(); |
... | ... | |
1559 | 1374 |
} |
1560 | 1375 |
|
1561 | 1376 |
@Override |
1377 |
public CreateTableBuilderBase add_column(FeatureAttributeDescriptor fad) { |
|
1378 |
this.columns.add(column(fad).getDescriptor()); |
|
1379 |
return this; |
|
1380 |
} |
|
1381 |
|
|
1382 |
@Override |
|
1562 | 1383 |
public CreateTableBuilderBase add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) { |
1563 | 1384 |
if( StringUtils.isEmpty(columnName) ) { |
1564 | 1385 |
throw new IllegalArgumentException("Argument 'columnName' can't be empty."); |
... | ... | |
1566 | 1387 |
if (isPk || isAutomatic) { |
1567 | 1388 |
allowNulls = false; |
1568 | 1389 |
} |
1569 |
this.columns.add(new ColumnDescriptorBuilderBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue));
|
|
1390 |
this.columns.add(new ColumnDescriptorBase(columnName, type, type_p, type_s, isPk, isIndexed, allowNulls, isAutomatic, defaultValue)); |
|
1570 | 1391 |
return this; |
1571 | 1392 |
} |
1572 | 1393 |
|
... | ... | |
1575 | 1396 |
if( StringUtils.isEmpty(columnName) ) { |
1576 | 1397 |
throw new IllegalArgumentException("Argument 'columnName' can't be empty."); |
1577 | 1398 |
} |
1578 |
this.columns.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, proj, isIndexed, allowNulls));
|
|
1399 |
this.columns.add(new ColumnDescriptorBase(columnName, type, subtype, proj, isIndexed, allowNulls)); |
|
1579 | 1400 |
return this; |
1580 | 1401 |
} |
1581 | 1402 |
|
... | ... | |
1584 | 1405 |
if( StringUtils.isEmpty(columnName) ) { |
1585 | 1406 |
throw new IllegalArgumentException("Argument 'columnName' can't be empty."); |
1586 | 1407 |
} |
1587 |
this.columns.add(new ColumnDescriptorBuilderBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls));
|
|
1408 |
this.columns.add(new ColumnDescriptorBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls)); |
|
1588 | 1409 |
return this; |
1589 | 1410 |
} |
1590 | 1411 |
|
1591 | 1412 |
@Override |
1592 |
public ColumnDescriptorBuilder getColumnDescriptor(String columnName) {
|
|
1413 |
public ColumnDescriptor getColumnDescriptor(String columnName) { |
|
1593 | 1414 |
if( StringUtils.isEmpty(columnName) ) { |
1594 | 1415 |
return null; |
1595 | 1416 |
} |
1596 |
for (ColumnDescriptorBuilderBase column : columns) {
|
|
1417 |
for (ColumnDescriptor column : columns) { |
|
1597 | 1418 |
if( columnName.equals(column.getName()) ) { |
1598 | 1419 |
return column; |
1599 | 1420 |
} |
... | ... | |
1653 | 1474 |
builder.append(this.table.toString()); |
1654 | 1475 |
builder.append(" ("); |
1655 | 1476 |
boolean first = true; |
1656 |
for (ColumnDescriptorBuilderBase column : columns) {
|
|
1477 |
for (ColumnDescriptor column : columns) { |
|
1657 | 1478 |
if (first) { |
1658 | 1479 |
first = false; |
1659 | 1480 |
} else { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultDataServerExplorerProviderServices.java | ||
---|---|---|
37 | 37 |
DataServerExplorerProviderServices { |
38 | 38 |
|
39 | 39 |
public EditableFeatureType createNewFeatureType() { |
40 |
return new DefaultEditableFeatureType(); |
|
40 |
return new DefaultEditableFeatureType(null);
|
|
41 | 41 |
} |
42 | 42 |
|
43 | 43 |
public Resource createResource(String name, Object[] params) |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultDataManager.java | ||
---|---|---|
711 | 711 |
|
712 | 712 |
@Override |
713 | 713 |
public EditableFeatureType createFeatureType() { |
714 |
return new DefaultEditableFeatureType(); |
|
714 |
return new DefaultEditableFeatureType(null);
|
|
715 | 715 |
} |
716 | 716 |
|
717 | 717 |
@Override |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java | ||
---|---|---|
2197 | 2197 |
|
2198 | 2198 |
@Override |
2199 | 2199 |
public EditableFeatureType createFeatureType() { |
2200 |
EditableFeatureType ftype = this.dataManager.createFeatureType();
|
|
2200 |
EditableFeatureType ftype = new DefaultEditableFeatureType(this);
|
|
2201 | 2201 |
return ftype; |
2202 | 2202 |
} |
2203 | 2203 |
|
2204 | 2204 |
@Override |
2205 | 2205 |
public EditableFeatureType createFeatureType(String id) { |
2206 |
DefaultEditableFeatureType ftype = new DefaultEditableFeatureType(id); |
|
2206 |
DefaultEditableFeatureType ftype = new DefaultEditableFeatureType(this, id);
|
|
2207 | 2207 |
return ftype; |
2208 | 2208 |
} |
2209 | 2209 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultEditableFeatureAttributeDescriptor.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
34 | 34 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
35 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
35 | 36 |
import org.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeIntegrityException; |
36 | 37 |
import org.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeSizeException; |
37 | 38 |
import org.gvsig.fmap.geom.Geometry; |
... | ... | |
64 | 65 |
hasStrongChanges = false; |
65 | 66 |
} |
66 | 67 |
|
67 |
public DefaultEditableFeatureAttributeDescriptor() { |
|
68 |
super(); |
|
68 |
public DefaultEditableFeatureAttributeDescriptor(FeatureType type) {
|
|
69 |
super(type);
|
|
69 | 70 |
this.source = null; |
70 | 71 |
hasStrongChanges = false; |
71 | 72 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureAttributeDescriptor.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.fmap.dal.feature.impl; |
24 | 24 |
|
25 |
import java.lang.ref.WeakReference; |
|
25 | 26 |
import java.text.DateFormat; |
26 | 27 |
import java.util.HashMap; |
27 | 28 |
import java.util.Iterator; |
... | ... | |
34 | 35 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
35 | 36 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
36 | 37 |
import org.gvsig.fmap.dal.feature.FeatureAttributeGetter; |
38 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
39 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
37 | 40 |
import org.gvsig.fmap.geom.Geometry; |
38 | 41 |
import org.gvsig.fmap.geom.GeometryException; |
39 | 42 |
import org.gvsig.fmap.geom.GeometryLocator; |
... | ... | |
103 | 106 |
protected Tags tags = new DefaultTags(); |
104 | 107 |
private DynMethod availableValuesMethod; |
105 | 108 |
private DynMethod calculateMethod; |
109 |
private WeakReference typeRef; |
|
106 | 110 |
|
107 |
protected DefaultFeatureAttributeDescriptor() { |
|
111 |
protected DefaultFeatureAttributeDescriptor(FeatureType type) { |
|
112 |
if( type == null ) { |
|
113 |
this.typeRef = null; |
|
114 |
} else { |
|
115 |
this.typeRef = new WeakReference(type); |
|
116 |
} |
|
108 | 117 |
this.allowNull = true; |
109 | 118 |
this.dataType = null; |
110 | 119 |
this.dateFormat = null; |
... | ... | |
128 | 137 |
} |
129 | 138 |
|
130 | 139 |
protected DefaultFeatureAttributeDescriptor( |
131 |
DefaultFeatureAttributeDescriptor other) { |
|
140 |
DefaultFeatureAttributeDescriptor other |
|
141 |
) { |
|
132 | 142 |
copyFrom(other); |
133 | 143 |
} |
134 | 144 |
|
... | ... | |
138 | 148 |
throw new IllegalArgumentException("Can't copy from a non DefaultFeatureAttributeDescriptor"); |
139 | 149 |
} |
140 | 150 |
DefaultFeatureAttributeDescriptor other = (DefaultFeatureAttributeDescriptor) other1; |
151 |
this.typeRef = other.typeRef; |
|
141 | 152 |
this.allowNull = other.allowNull; |
142 | 153 |
this.dataType = other.dataType; |
143 | 154 |
this.dateFormat = other.dateFormat; |
... | ... | |
502 | 513 |
* |
503 | 514 |
*/ |
504 | 515 |
|
516 |
@Override |
|
505 | 517 |
public Tags getTags() { |
506 | 518 |
return tags; |
507 | 519 |
} |
... | ... | |
963 | 975 |
} |
964 | 976 |
} |
965 | 977 |
|
978 |
@Override |
|
966 | 979 |
public boolean isComputed() { |
967 | 980 |
return featureAttributeEmulator!=null || evaluator!=null; |
968 | 981 |
} |
982 |
|
|
983 |
@Override |
|
984 |
public FeatureStore getStore() { |
|
985 |
FeatureType ftype = this.getFeatureType(); |
|
986 |
if( ftype == null ) { |
|
987 |
return null; |
|
988 |
} |
|
989 |
return ftype.getStore(); |
|
990 |
} |
|
991 |
|
|
992 |
@Override |
|
993 |
public FeatureType getFeatureType() { |
|
994 |
if( this.typeRef==null ) { |
|
995 |
return null; |
|
996 |
} |
|
997 |
return (FeatureType) this.typeRef.get(); |
|
998 |
} |
|
969 | 999 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultEditableFeatureType.java | ||
---|---|---|
25 | 25 |
import java.text.MessageFormat; |
26 | 26 |
|
27 | 27 |
import java.util.Iterator; |
28 |
import java.util.zip.CRC32; |
|
29 | 28 |
|
30 | 29 |
import org.gvsig.fmap.dal.DataTypes; |
31 | 30 |
import org.gvsig.fmap.dal.exception.DataListException; |
... | ... | |
33 | 32 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
34 | 33 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
35 | 34 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
35 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
36 | 36 |
import org.gvsig.fmap.dal.feature.FeatureType; |
37 | 37 |
import org.gvsig.fmap.dal.feature.exception.FeatureTypeIntegrityException; |
38 | 38 |
import org.gvsig.fmap.dal.feature.exception.UnsupportedDataTypeException; |
... | ... | |
50 | 50 |
private boolean hasStrongChanges; |
51 | 51 |
private DefaultFeatureType source; |
52 | 52 |
|
53 |
public DefaultEditableFeatureType() { |
|
54 |
super(); |
|
53 |
public DefaultEditableFeatureType(FeatureStore store) {
|
|
54 |
super(store);
|
|
55 | 55 |
this.hasStrongChanges = false; |
56 | 56 |
this.source = null; |
57 | 57 |
} |
58 | 58 |
|
59 |
public DefaultEditableFeatureType(String id) { |
|
60 |
super(id); |
|
59 |
public DefaultEditableFeatureType(FeatureStore store, String id) {
|
|
60 |
super(store, id);
|
|
61 | 61 |
this.hasStrongChanges = false; |
62 | 62 |
this.source = null; |
63 | 63 |
} |
... | ... | |
72 | 72 |
this.source = other; |
73 | 73 |
} |
74 | 74 |
|
75 |
@Override |
|
75 | 76 |
protected void intitalizeAddAttibute(DefaultFeatureAttributeDescriptor attr) { |
76 | 77 |
super.add(new DefaultEditableFeatureAttributeDescriptor(attr)); |
77 | 78 |
} |
... | ... | |
156 | 157 |
} |
157 | 158 |
|
158 | 159 |
private EditableFeatureAttributeDescriptor add(String name, int type, boolean updateHasStrongChanges) { |
159 |
DefaultEditableFeatureAttributeDescriptor attr = new DefaultEditableFeatureAttributeDescriptor(); |
|
160 |
DefaultEditableFeatureAttributeDescriptor attr = new DefaultEditableFeatureAttributeDescriptor(this);
|
|
160 | 161 |
Iterator iter = this.iterator(); |
161 | 162 |
while (iter.hasNext()) { |
162 | 163 |
EditableFeatureAttributeDescriptor descriptor = (EditableFeatureAttributeDescriptor) iter.next(); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureType.java | ||
---|---|---|
42 | 42 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
43 | 43 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
44 | 44 |
import org.gvsig.fmap.dal.feature.FeatureRules; |
45 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
45 | 46 |
import org.gvsig.fmap.dal.feature.FeatureType; |
46 | 47 |
import org.gvsig.tools.dynobject.DynClass; |
47 | 48 |
import org.gvsig.tools.dynobject.DynField; |
... | ... | |
73 | 74 |
protected String internalID = null; |
74 | 75 |
|
75 | 76 |
private List srsList = null; |
77 |
private WeakReference storeRef; |
|
76 | 78 |
|
77 |
protected DefaultFeatureType(String id) { |
|
78 |
if( StringUtils.isEmpty(id) ) { |
|
79 |
id = "default"; |
|
80 |
} |
|
81 |
this.internalID = Integer.toHexString((int) (Math.random()*100000)).toUpperCase(); |
|
82 |
this.id = id; |
|
83 |
this.rules = new DefaultFeatureRules(); |
|
84 |
this.hasEvaluators = false; |
|
85 |
this.hasEmulators = false; |
|
86 |
this.defaultGeometryAttributeName = null; |
|
87 |
this.defaultGeometryAttributeIndex = -1; |
|
88 |
this.defaultTimeAttributeIndex = -1; |
|
89 |
this.allowAtomaticValues = false; |
|
79 |
protected DefaultFeatureType(FeatureStore store, String id) { |
|
80 |
if (StringUtils.isEmpty(id)) { |
|
81 |
id = "default"; |
|
82 |
} |
|
83 |
if( store == null ) { |
|
84 |
this.storeRef = null; |
|
85 |
} else { |
|
86 |
this.storeRef = new WeakReference(store); |
|
87 |
} |
|
88 |
this.internalID = Integer.toHexString((int) (Math.random() * 100000)).toUpperCase(); |
|
89 |
this.id = id; |
|
90 |
this.rules = new DefaultFeatureRules(); |
|
91 |
this.hasEvaluators = false; |
|
92 |
this.hasEmulators = false; |
|
93 |
this.defaultGeometryAttributeName = null; |
|
94 |
this.defaultGeometryAttributeIndex = -1; |
|
95 |
this.defaultTimeAttributeIndex = -1; |
|
96 |
this.allowAtomaticValues = false; |
|
90 | 97 |
} |
91 | 98 |
|
92 |
protected DefaultFeatureType() { |
|
93 |
this((String)null); |
|
99 |
protected DefaultFeatureType(FeatureStore store) {
|
|
100 |
this(store, (String)null);
|
|
94 | 101 |
} |
95 | 102 |
|
96 | 103 |
protected DefaultFeatureType(DefaultFeatureType other) { |
97 |
this((String)null); |
|
104 |
this(other.getStore(), (String)null);
|
|
98 | 105 |
initialize(other, true); |
99 | 106 |
} |
100 | 107 |
|
101 | 108 |
protected DefaultFeatureType(DefaultFeatureType other, |
102 | 109 |
boolean copyAttributes) { |
103 |
this((String)null); |
|
110 |
this(other.getStore(), (String)null);
|
|
104 | 111 |
initialize(other, copyAttributes); |
105 | 112 |
} |
106 | 113 |
|
... | ... | |
835 | 842 |
crc.update(data); |
836 | 843 |
return crc.getValue(); |
837 | 844 |
} |
845 |
|
|
846 |
@Override |
|
847 |
public FeatureStore getStore() { |
|
848 |
if( this.storeRef == null ) { |
|
849 |
return null; |
|
850 |
} |
|
851 |
return (FeatureStore) this.storeRef.get(); |
|
852 |
} |
|
853 |
|
|
838 | 854 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialSQLBuilder.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.dal.store.h2; |
2 | 2 |
|
3 | 3 |
import java.sql.PreparedStatement; |
4 |
import java.sql.SQLException; |
|
5 | 4 |
import java.text.MessageFormat; |
6 | 5 |
import java.util.ArrayList; |
7 | 6 |
import java.util.Date; |
... | ... | |
146 | 145 |
builder.append(identifier(column)); |
147 | 146 |
sqls.add(builder.toString()); |
148 | 147 |
} |
149 |
for (ColumnDescriptorBuilderBase column : adds) {
|
|
148 |
for (ColumnDescriptor column : adds) { |
|
150 | 149 |
StringBuilder builder = new StringBuilder(); |
151 | 150 |
builder.append("ALTER TABLE "); |
152 | 151 |
builder.append(this.table.toString()); |
... | ... | |
198 | 197 |
sqls.add(sql); |
199 | 198 |
} |
200 | 199 |
} |
201 |
for (ColumnDescriptorBuilderBase column : alters) {
|
|
200 |
for (ColumnDescriptor column : alters) { |
|
202 | 201 |
StringBuilder builder = new StringBuilder(); |
203 | 202 |
builder.append("ALTER TABLE "); |
204 | 203 |
builder.append(this.table.toString()); |
... | ... | |
267 | 266 |
builder.append(this.table.toString()); |
268 | 267 |
builder.append(" ("); |
269 | 268 |
boolean first = true; |
270 |
for (ColumnDescriptorBuilder column : columns) {
|
|
269 |
for (ColumnDescriptor column : columns) { |
|
271 | 270 |
|
272 | 271 |
if (first) { |
273 | 272 |
first = false; |
... | ... | |
315 | 314 |
} |
316 | 315 |
builder.append(" )"); |
317 | 316 |
sqls.add(builder.toString()); |
318 |
for (ColumnDescriptorBuilderBase column : columns) {
|
|
317 |
for (ColumnDescriptor column : columns) { |
|
319 | 318 |
if( column.isGeometry() ) { |
320 | 319 |
String sql; |
321 | 320 |
String constraint_name = "constraint_" + this.table().getName() + "_" + column.getName()+"_dim"; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.swing/org.gvsig.fmap.dal.swing.impl/src/main/java/org/gvsig/fmap/dal/swing/impl/featuretable/table/DynFieldFacadeOfAFeatureAttributeDescriptor.java | ||
---|---|---|
7 | 7 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
8 | 8 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator; |
9 | 9 |
import org.gvsig.fmap.dal.feature.FeatureAttributeGetter; |
10 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
11 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
10 | 12 |
import org.gvsig.fmap.geom.Geometry; |
11 | 13 |
import org.gvsig.fmap.geom.type.GeometryType; |
12 | 14 |
import org.gvsig.tools.dataTypes.CoercionException; |
... | ... | |
384 | 386 |
} |
385 | 387 |
return false; |
386 | 388 |
} |
389 |
|
|
390 |
@Override |
|
391 |
public FeatureStore getStore() { |
|
392 |
return null; |
|
393 |
} |
|
394 |
|
|
395 |
@Override |
|
396 |
public FeatureType getFeatureType() { |
|
397 |
return null; |
|
398 |
} |
|
387 | 399 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/test/java/org/gvsig/fmap/dal/feature/DummyFeatureType.java | ||
---|---|---|
387 | 387 |
return null; |
388 | 388 |
} |
389 | 389 |
|
390 |
@Override |
|
391 |
public FeatureStore getStore() { |
|
392 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
393 |
} |
|
394 |
|
|
390 | 395 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/test/java/org/gvsig/fmap/dal/feature/DummyFeatureAttributeDescriptor.java | ||
---|---|---|
372 | 372 |
return false; |
373 | 373 |
} |
374 | 374 |
|
375 |
@Override |
|
376 |
public FeatureStore getStore() { |
|
377 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
378 |
} |
|
379 |
|
|
380 |
@Override |
|
381 |
public FeatureType getFeatureType() { |
|
382 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
|
383 |
} |
|
384 |
|
|
375 | 385 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/SQLBuilder.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.List; |
4 | 4 |
import org.cresques.cts.IProjection; |
5 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
5 | 6 |
|
6 | 7 |
public interface SQLBuilder extends ExpressionBuilder { |
7 | 8 |
|
... | ... | |
216 | 217 |
public interface AlterTableBuilder extends Statement { |
217 | 218 |
public TableNameBuilder table(); |
218 | 219 |
public AlterTableBuilder drop_column(String columnName); |
219 |
public AlterTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue); |
|
220 |
public AlterTableBuilder add_column(FeatureAttributeDescriptor fad); |
|
221 |
public AlterTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue); |
|
220 | 222 |
public AlterTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls); |
221 | 223 |
public AlterTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls); |
224 |
public AlterTableBuilder alter_column(FeatureAttributeDescriptor fad); |
|
222 | 225 |
public AlterTableBuilder alter_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue); |
223 | 226 |
public AlterTableBuilder alter_geometry_column(String columnName, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls); |
224 | 227 |
public AlterTableBuilder alter_geometry_column(String columnName, int geom_type, int geom_subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls); |
... | ... | |
229 | 232 |
|
230 | 233 |
public interface CreateTableBuilder extends Statement { |
231 | 234 |
public TableNameBuilder table(); |
235 |
public CreateTableBuilder add_column(FeatureAttributeDescriptor fad); |
|
232 | 236 |
public CreateTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue); |
233 | 237 |
public CreateTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls); |
234 | 238 |
public CreateTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls); |
235 |
public ColumnDescriptorBuilder getColumnDescriptor(String columnName);
|
|
239 |
public ColumnDescriptor getColumnDescriptor(String columnName); |
|
236 | 240 |
public List<String> toStrings(); |
237 | 241 |
} |
238 | 242 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureAttributeDescriptor.java | ||
---|---|---|
240 | 240 |
*/ |
241 | 241 |
public boolean isComputed(); |
242 | 242 |
|
243 |
/** |
|
244 |
* Return the store associated to this attribute descriptor. |
|
245 |
* |
|
246 |
* @return the FeatureStore of the attribute descriptor. |
|
247 |
*/ |
|
248 |
public FeatureStore getStore(); |
|
249 |
|
|
250 |
public FeatureType getFeatureType(); |
|
251 |
|
|
243 | 252 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureType.java | ||
---|---|---|
290 | 290 |
*/ |
291 | 291 |
public FeatureAttributeDescriptor getDefaultTimeAttribute(); |
292 | 292 |
|
293 |
/** |
|
294 |
* Return the store associated to this type. |
|
295 |
* |
|
296 |
* @return the FeatureStore of the type. |
|
297 |
*/ |
|
298 |
public FeatureStore getStore(); |
|
293 | 299 |
|
294 | 300 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/ExpressionBuilder.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.List; |
4 | 4 |
import org.cresques.cts.IProjection; |
5 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
5 | 7 |
import org.gvsig.fmap.geom.Geometry; |
6 | 8 |
import org.gvsig.fmap.geom.primitive.Envelope; |
7 | 9 |
|
... | ... | |
120 | 122 |
public IProjection getSRS(); |
121 | 123 |
} |
122 | 124 |
|
125 |
public interface ColumnDescriptor { |
|
126 |
public String getName(); |
|
127 |
public int getType(); |
|
128 |
public int getSize(); |
|
129 |
public int getPrecision(); |
|
130 |
public boolean isPrimaryKey(); |
|
131 |
public boolean isIndexed(); |
|
132 |
public boolean isAutomatic(); |
|
133 |
boolean allowNulls(); |
|
134 |
public Object getDefaultValue(); |
|
135 |
public int getGeometryType(); |
|
136 |
public int getGeometrySubtype(); |
|
137 |
public Object getGeometrySRSId(); |
|
138 |
public boolean isGeometry(); |
|
139 |
|
|
140 |
public DataStoreParameters getStoreParameters(); |
|
141 |
|
|
142 |
public void setName(String name); |
|
143 |
public void setType(int type); |
|
144 |
public void setSize(int size); |
|
145 |
public void setPrecision(int precision); |
|
146 |
public void setIsPrimaryKey(boolean isPk); |
|
147 |
public void setIsAutomatic(boolean isAutomatic); |
|
148 |
public void setAllowNulls(boolean allowNulls); |
|
149 |
public void setDefaultValue(Object defaultValue); |
|
150 |
public void setGeometryType(int geom_type); |
|
151 |
public void setGeometrySubtype(int geom_subtype); |
|
152 |
public void setGeometrySRSId(Object geom_srsid); |
|
153 |
} |
|
154 |
|
|
123 | 155 |
public interface Variable extends Value, Comparable<Variable> { |
124 | 156 |
public String getName(); |
157 |
public ColumnDescriptor getDescriptor(); |
|
125 | 158 |
} |
126 | 159 |
|
127 | 160 |
public interface Parameter extends Value { |
... | ... | |
186 | 219 |
public Variable variable(String name); |
187 | 220 |
|
188 | 221 |
public Variable column(String name); // Alias for variable(name) |
222 |
public Variable column(FeatureAttributeDescriptor fad); |
|
189 | 223 |
|
190 | 224 |
public Parameter parameter(String name); |
191 | 225 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/CrossesGeometryEvaluator.java | ||
---|---|---|
41 | 41 |
private final boolean isDefault; |
42 | 42 |
private final ExpressionBuilder builder; |
43 | 43 |
private final IProjection projection; |
44 |
private final FeatureAttributeDescriptor fad; |
|
44 | 45 |
|
45 | 46 |
/** |
46 | 47 |
* @param geometry |
... | ... | |
71 | 72 |
String geomName, |
72 | 73 |
ExpressionBuilder builder |
73 | 74 |
) { |
74 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType |
|
75 |
.get(geomName); |
|
75 |
fad = (FeatureAttributeDescriptor) featureType.get(geomName); |
|
76 | 76 |
this.projection = projection; |
77 | 77 |
this.builder = builder; |
78 | 78 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName); |
... | ... | |
126 | 126 |
return this.builder.set( |
127 | 127 |
builder.ST_Crosses( |
128 | 128 |
builder.geometry(geometry, projection), |
129 |
builder.column(geomName)
|
|
129 |
builder.column(fad)
|
|
130 | 130 |
) |
131 | 131 |
).toString(); |
132 | 132 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/DisjointGeometryEvaluator.java | ||
---|---|---|
42 | 42 |
private final boolean isDefault; |
43 | 43 |
private final ExpressionBuilder builder; |
44 | 44 |
private final IProjection projection; |
45 |
private final FeatureAttributeDescriptor fad; |
|
45 | 46 |
|
46 | 47 |
/** |
47 | 48 |
* @param geometry |
... | ... | |
72 | 73 |
String geomName, |
73 | 74 |
ExpressionBuilder builder |
74 | 75 |
) { |
75 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType |
|
76 |
.get(geomName); |
|
76 |
fad = (FeatureAttributeDescriptor) featureType.get(geomName); |
|
77 | 77 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName); |
78 | 78 |
this.geometry = geometry; |
79 | 79 |
this.geometryTrans = geometry.cloneGeometry(); |
... | ... | |
127 | 127 |
return this.builder.set( |
128 | 128 |
builder.ST_Disjoint( |
129 | 129 |
builder.geometry(geometry, projection), |
130 |
builder.column(geomName)
|
|
130 |
builder.column(fad)
|
|
131 | 131 |
) |
132 | 132 |
).toString(); |
133 | 133 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/IntersectsGeometryEvaluator.java | ||
---|---|---|
41 | 41 |
private final boolean isDefault; |
42 | 42 |
private final ExpressionBuilder builder; |
43 | 43 |
private final IProjection projection; |
44 |
|
|
44 |
private final FeatureAttributeDescriptor fad; |
|
45 |
|
|
45 | 46 |
/** |
46 | 47 |
* @param geometry |
47 | 48 |
* @param projection |
... | ... | |
71 | 72 |
String geomName, |
72 | 73 |
ExpressionBuilder builder |
73 | 74 |
) { |
74 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
|
|
75 |
fad = (FeatureAttributeDescriptor) featureType |
|
75 | 76 |
.get(geomName); |
76 | 77 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName); |
77 | 78 |
this.geometry = geometry; |
... | ... | |
123 | 124 |
return builder.set( |
124 | 125 |
builder.ST_Intersects( |
125 | 126 |
builder.geometry(geometry, this.projection), |
126 |
builder.column(geomName)
|
|
127 |
builder.column(this.fad)
|
|
127 | 128 |
) |
128 | 129 |
).toString(); |
129 | 130 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/EqualsGeometryEvaluator.java | ||
---|---|---|
41 | 41 |
private final boolean isDefault; |
42 | 42 |
private final ExpressionBuilder builder; |
43 | 43 |
private final IProjection projection; |
44 |
private final FeatureAttributeDescriptor fad; |
|
44 | 45 |
|
45 | 46 |
/** |
46 | 47 |
* @param geometry |
... | ... | |
73 | 74 |
) { |
74 | 75 |
this.builder = builder; |
75 | 76 |
this.projection = projection; |
76 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType |
|
77 |
.get(geomName); |
|
77 |
fad = (FeatureAttributeDescriptor) featureType.get(geomName); |
|
78 | 78 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName); |
79 | 79 |
this.geometry = geometry; |
80 | 80 |
this.geometryTrans = geometry.cloneGeometry(); |
... | ... | |
126 | 126 |
return this.builder.set( |
127 | 127 |
builder.ST_Equals( |
128 | 128 |
builder.geometry(geometry, projection), |
129 |
builder.column(geomName)
|
|
129 |
builder.column(fad)
|
|
130 | 130 |
) |
131 | 131 |
).toString(); |
132 | 132 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/OverlapsGeometryEvaluator.java | ||
---|---|---|
46 | 46 |
private final boolean isDefault; |
47 | 47 |
private final ExpressionBuilder builder; |
48 | 48 |
private final IProjection projection; |
49 |
private final FeatureAttributeDescriptor fad; |
|
49 | 50 |
|
50 | 51 |
/** |
51 | 52 |
* @param geometry |
... | ... | |
76 | 77 |
String geomName, |
77 | 78 |
ExpressionBuilder builder |
78 | 79 |
) { |
79 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType |
|
80 |
.get(geomName); |
|
80 |
fad = (FeatureAttributeDescriptor) featureType.get(geomName); |
|
81 | 81 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName); |
82 | 82 |
this.geometry = geometry; |
83 | 83 |
this.geometryTrans = geometry.cloneGeometry(); |
... | ... | |
132 | 132 |
return this.builder.set( |
133 | 133 |
builder.ST_Overlaps( |
134 | 134 |
builder.geometry(geometry, projection), |
135 |
builder.column(geomName)
|
|
135 |
builder.column(fad)
|
|
136 | 136 |
) |
137 | 137 |
).toString(); |
138 | 138 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/ContainsEnvelopeEvaluator.java | ||
---|---|---|
42 | 42 |
private final boolean isDefault; |
43 | 43 |
private final ExpressionBuilder builder; |
44 | 44 |
private final IProjection projection; |
45 |
|
|
45 |
private final FeatureAttributeDescriptor fad; |
|
46 |
|
|
46 | 47 |
/** |
47 | 48 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
48 | 49 |
* @param envelope |
... | ... | |
72 | 73 |
String geomName, |
73 | 74 |
ExpressionBuilder builder |
74 | 75 |
) { |
75 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType |
|
76 |
.get(geomName); |
|
76 |
fad = (FeatureAttributeDescriptor) featureType.get(geomName); |
|
77 | 77 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName); |
78 | 78 |
this.projection = envelopeProjection; |
79 | 79 |
this.builder = builder; |
... | ... | |
122 | 122 |
return this.builder.set( |
123 | 123 |
builder.ST_Contains( |
124 | 124 |
builder.envelope(envelope, projection), |
125 |
builder.column(geomName)
|
|
125 |
builder.column(fad)
|
|
126 | 126 |
) |
127 | 127 |
).toString(); |
128 | 128 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/WithinGeometryEvaluator.java | ||
---|---|---|
41 | 41 |
private final boolean isDefault; |
42 | 42 |
private final ExpressionBuilder builder; |
43 | 43 |
private final IProjection projection; |
44 |
private final FeatureAttributeDescriptor fad; |
|
44 | 45 |
|
45 | 46 |
/** |
46 | 47 |
* @param geometry |
... | ... | |
71 | 72 |
String geomName, |
72 | 73 |
ExpressionBuilder builder |
73 | 74 |
) { |
74 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType |
|
75 |
.get(geomName); |
|
76 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals( |
|
77 |
geomName); |
|
75 |
fad = (FeatureAttributeDescriptor) featureType.get(geomName); |
|
76 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName); |
|
78 | 77 |
this.geometry = geometry; |
79 | 78 |
this.geometryTrans = geometry.cloneGeometry(); |
80 | 79 |
this.projection = projection; |
... | ... | |
127 | 126 |
return this.builder.set( |
128 | 127 |
builder.ST_Within( |
129 | 128 |
builder.geometry(geometry, projection), |
130 |
builder.column(geomName)
|
|
129 |
builder.column(fad)
|
|
131 | 130 |
) |
132 | 131 |
).toString(); |
133 | 132 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/IntersectsEnvelopeEvaluator.java | ||
---|---|---|
42 | 42 |
private final String defaultGeometryAttributeName; |
43 | 43 |
private final IProjection projection; |
44 | 44 |
private final ExpressionBuilder builder; |
45 |
FeatureAttributeDescriptor fad; |
|
45 | 46 |
|
46 | 47 |
/** |
47 | 48 |
* @param envelope |
... | ... | |
72 | 73 |
String geomName, |
73 | 74 |
ExpressionBuilder builder |
74 | 75 |
) { |
75 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType.get(geomName);
|
|
76 |
fad = (FeatureAttributeDescriptor) featureType.get(geomName); |
|
76 | 77 |
defaultGeometryAttributeName = featureType.getDefaultGeometryAttributeName(); |
77 | 78 |
this.isDefault = defaultGeometryAttributeName.equals(geomName); |
78 | 79 |
this.envelope = envelope; |
... | ... | |
116 | 117 |
builder.ST_Intersects( |
117 | 118 |
builder.geometry(envelope.getGeometry(), this.projection), |
118 | 119 |
// builder.ST_Envelope(builder.column(geomName)) |
119 |
builder.column(geomName)
|
|
120 |
builder.column(fad)
|
|
120 | 121 |
) |
121 | 122 |
).toString(); |
122 | 123 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/OutGeometryEvaluator.java | ||
---|---|---|
41 | 41 |
private final boolean isDefault; |
42 | 42 |
private final ExpressionBuilder builder; |
43 | 43 |
private final IProjection projection; |
44 |
private final FeatureAttributeDescriptor fad; |
|
44 | 45 |
|
45 | 46 |
/** |
46 | 47 |
* @param geometry |
... | ... | |
71 | 72 |
String geomName, |
72 | 73 |
ExpressionBuilder builder |
73 | 74 |
) { |
74 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType |
|
75 |
.get(geomName); |
|
75 |
fad = (FeatureAttributeDescriptor) featureType.get(geomName); |
|
76 | 76 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName); |
Also available in: Unified diff