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

View differences:

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);

Also available in: Unified diff