Statistics
| Revision:

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 / jdbc2 / spi / JDBCStoreProviderBase.java @ 45534

History | View | Annotate | Download (24.2 KB)

1 45065 jjdelcerro
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2020 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 43020 jjdelcerro
package org.gvsig.fmap.dal.store.jdbc2.spi;
25
26 43409 jjdelcerro
import java.text.MessageFormat;
27 43020 jjdelcerro
import org.gvsig.fmap.dal.store.jdbc2.JDBCStoreProvider;
28
import java.util.Arrays;
29
import java.util.Collections;
30
import java.util.Iterator;
31
import java.util.List;
32 43361 jjdelcerro
import org.apache.commons.lang3.BooleanUtils;
33
import org.apache.commons.lang3.StringUtils;
34 43020 jjdelcerro
import org.cresques.cts.IProjection;
35 45425 jjdelcerro
import org.gvsig.expressionevaluator.Expression;
36 43020 jjdelcerro
import org.gvsig.fmap.dal.DALLocator;
37
import org.gvsig.fmap.dal.DataManager;
38
import org.gvsig.fmap.dal.DataServerExplorer;
39
import org.gvsig.fmap.dal.DataStore;
40
import org.gvsig.fmap.dal.DataStoreNotification;
41
import org.gvsig.fmap.dal.DataTypes;
42
import org.gvsig.fmap.dal.exception.CloseException;
43
import org.gvsig.fmap.dal.exception.DataException;
44
import org.gvsig.fmap.dal.exception.InitializeException;
45
import org.gvsig.fmap.dal.exception.OpenException;
46
import org.gvsig.fmap.dal.exception.ReadException;
47 43420 jjdelcerro
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
48 43020 jjdelcerro
import org.gvsig.fmap.dal.feature.EditableFeatureType;
49
import org.gvsig.fmap.dal.feature.FeatureQuery;
50
import org.gvsig.fmap.dal.feature.FeatureRule;
51
import org.gvsig.fmap.dal.feature.FeatureRules;
52
import org.gvsig.fmap.dal.feature.FeatureType;
53
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider;
54
import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
55
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices;
56
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider;
57 43409 jjdelcerro
import org.gvsig.fmap.dal.resource.ResourceParameters;
58
import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
59
import org.gvsig.fmap.dal.resource.exception.ResourceException;
60
import org.gvsig.fmap.dal.resource.spi.AbstractResource;
61 43020 jjdelcerro
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
62
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
63
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
64
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
65
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
66
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
67
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
68
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory;
69
import org.gvsig.fmap.dal.store.jdbc2.ResulSetControler;
70
import org.gvsig.fmap.dal.store.jdbc2.impl.JDBCSetProvider;
71
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.AppendOperation;
72
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CalculateEnvelopeOfColumnOperation;
73
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CanModifyTableOperation;
74
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CountOperation;
75 45473 fdiaz
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.DeletePassThroughOperation;
76 43020 jjdelcerro
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureProviderByReferenceOperation;
77
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation;
78
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.PerformChangesOperation;
79 45473 fdiaz
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.UpdatePassThroughOperation;
80 43420 jjdelcerro
import org.gvsig.fmap.geom.Geometry;
81 43020 jjdelcerro
import org.gvsig.fmap.geom.primitive.Envelope;
82 44185 jjdelcerro
import org.gvsig.tools.dynobject.DynField;
83 43020 jjdelcerro
import org.gvsig.tools.dynobject.DynObject;
84
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
85
import org.gvsig.tools.exception.BaseException;
86
import org.slf4j.Logger;
87
import org.slf4j.LoggerFactory;
88
89 44058 jjdelcerro
@SuppressWarnings("UseSpecificCatch")
90 43020 jjdelcerro
public class JDBCStoreProviderBase
91
        extends AbstractFeatureStoreProvider
92
        implements ResourceConsumer, JDBCStoreProvider {
93
94 44058 jjdelcerro
    final static private Logger LOGGER = LoggerFactory.getLogger(JDBCStoreProviderBase.class);
95 43020 jjdelcerro
96
    public class CountValue implements CalculatedValue<Long> {
97
98
        private Long value = null;
99
100
        @Override
101
        public void calculate() {
102 44376 jjdelcerro
            try {
103
                JDBCStoreParameters params = getParameters();
104
                CountOperation count = getOperations().createCount(
105
                        getFeatureStore().getDefaultFeatureType(),
106
                        getOperations().createTableReference(params),
107
                        params.getBaseFilter(),
108
                        null
109
                );
110
                this.value = (Long) count.perform();
111
            } catch (DataException ex) {
112
                throw new RuntimeException("Can't calculate count",ex);
113
            }
114 43020 jjdelcerro
        }
115
116
        @Override
117
        public void reset() {
118
            this.value = null;
119
        }
120
121
        @Override
122
        public Long get() {
123
            if( this.value == null ) {
124
                this.calculate();
125
            }
126
            return this.value;
127
        }
128
    }
129
130
    public class EnvelopeValue implements CalculatedValue<Envelope> {
131
132
        private Envelope value = null;
133 43163 jjdelcerro
        private boolean needCalculate = true;
134 43020 jjdelcerro
135
        @Override
136
        public void calculate() {
137
            try {
138 43163 jjdelcerro
                value = null;
139 43020 jjdelcerro
                String columnName = getFeatureStore()
140
                        .getDefaultFeatureType()
141
                        .getDefaultGeometryAttributeName();
142 43163 jjdelcerro
                if( columnName==null ) {
143
                    return;
144
                }
145 43020 jjdelcerro
                IProjection crs = getFeatureStore()
146
                        .getDefaultFeatureType()
147
                        .getDefaultSRS();
148
                JDBCStoreParameters params = getParameters();
149
                CalculateEnvelopeOfColumnOperation calculateEnvelopeOfColumn =
150
                    getOperations().createCalculateEnvelopeOfColumn(
151 44376 jjdelcerro
                        getFeatureStore().getDefaultFeatureType(),
152 44058 jjdelcerro
                        getOperations().createTableReference(params),
153 43020 jjdelcerro
                        columnName,
154
                        params.getBaseFilter(),
155
                        params.getWorkingArea(),
156
                        crs
157
                    );
158
                value = (Envelope) calculateEnvelopeOfColumn.perform();
159 43163 jjdelcerro
160 43020 jjdelcerro
            } catch(Exception ex) {
161
                throw new RuntimeException("Can't calculate envelope.", ex);
162 43163 jjdelcerro
            } finally {
163
               needCalculate = false;
164 43020 jjdelcerro
            }
165
        }
166
167
        @Override
168
        public void reset() {
169
            this.value = null;
170 43163 jjdelcerro
            this.needCalculate = true;
171 43020 jjdelcerro
        }
172
173
        @Override
174 43361 jjdelcerro
        public synchronized Envelope get() {
175 43163 jjdelcerro
            if( needCalculate ) {
176 43020 jjdelcerro
                this.calculate();
177
            }
178
            return this.value;
179
        }
180
    }
181 43163 jjdelcerro
182 43020 jjdelcerro
    public class AllowWriteValue implements CalculatedValue<Boolean> {
183
184
        private Boolean value = null;
185
186
        @Override
187
        public void calculate() {
188
            try {
189
                JDBCStoreParameters params = getParameters();
190
                CanModifyTableOperation canModifyTable =
191
                    getOperations().createCanModifyTableOperation(
192 44058 jjdelcerro
                        getOperations().createTableReference(params)
193 43020 jjdelcerro
                    );
194
                this.value = (boolean) canModifyTable.perform();
195
            } catch(Exception ex) {
196
                throw new RuntimeException("Can't determine if allow write.", ex);
197
            }
198
        }
199
200
        @Override
201
        public void reset() {
202
            this.value = null;
203
        }
204
205
        @Override
206
        public Boolean get() {
207
            if( this.value == null ) {
208
                this.calculate();
209
            }
210
            return this.value;
211
        }
212
    }
213
214
    protected final JDBCHelper helper;
215
216
    protected CalculatedValue<Long> count = null;
217
218
    protected CalculatedValue<Envelope> envelope = null;
219
220
    protected CalculatedValue<Boolean> allowWrite = null;
221
222
    protected AppendOperation appendOperation = null;
223
224 44058 jjdelcerro
    @SuppressWarnings({"OverridableMethodCallInConstructor", "CallToThreadStartDuringObjectConstruction"})
225 43020 jjdelcerro
    protected JDBCStoreProviderBase(
226
            JDBCStoreParameters params,
227
            DataStoreProviderServices storeServices,
228
            DynObject metadata,
229
            JDBCHelper helper
230
    ) throws InitializeException {
231
        super(params, storeServices, metadata);
232
        this.helper = helper;
233
        this.initializeFeatureType();
234 43361 jjdelcerro
        try {
235
            if( BooleanUtils.isTrue((Boolean) params.getDynValue("precalculateEnvelope"))  ) {
236
                FeatureType featureType = this.getStoreServices().getDefaultFeatureType();
237
                if( !StringUtils.isEmpty(featureType.getDefaultGeometryAttributeName()) ) {
238 45065 jjdelcerro
                    Thread thread = new Thread(() -> {
239
                        LOGGER.trace("Precalculating envelope of '"+getSourceId()+"'.");
240
                        getEnvelopeValue().get();
241 43361 jjdelcerro
                    }, "PrecalculateEnvelopeOfDBTable");
242
                    thread.start();
243
                    Thread.sleep(1);
244
                }
245
           }
246
        } catch(Exception ex) {
247 44058 jjdelcerro
            LOGGER.warn("Probems precalculating the envelope of table '"+this.getSourceId()+"'.", ex);
248 43361 jjdelcerro
        }
249 43020 jjdelcerro
    }
250
251
    @Override
252
    public JDBCStoreParameters getParameters() {
253
        return (JDBCStoreParameters) super.getParameters();
254
    }
255
256
    @Override
257
    public JDBCHelper getHelper() {
258
        return helper;
259
    }
260
261
    public OperationsFactory getOperations() {
262
        return this.getHelper().getOperations();
263
    }
264
265
    @Override
266
    public String getProviderName() {
267
        return this.getHelper().getProviderName();
268
    }
269
270
    @Override
271
    public int getOIDType() {
272
        return DataTypes.UNKNOWN;
273
    }
274
275
    @Override
276
    public Object createNewOID() {
277
        return null;
278
    }
279
280
    @Override
281
    public boolean allowAutomaticValues() {
282
        return this.getHelper().allowAutomaticValues();
283
    }
284
285
    @Override
286
    public boolean allowWrite() {
287
        return this.getAllowWriteValue().get();
288
    }
289
290
    @Override
291
    public Object getDynValue(String name) throws DynFieldNotFoundException {
292
        try {
293
            if (DataStore.METADATA_ENVELOPE.equalsIgnoreCase(name)) {
294
                Envelope env = this.getEnvelope();
295
                if (env != null) {
296
                    return env;
297
                }
298
            } else if (DataStore.METADATA_CRS.equalsIgnoreCase(name)) {
299
                IProjection proj;
300
                proj = this.getFeatureStore().getDefaultFeatureType().getDefaultSRS();
301
                if (proj != null) {
302
                    return proj;
303
                }
304
            }
305
        } catch (DataException e) {
306
            throw new RuntimeException(e);
307
        }
308
        return super.getDynValue(name);
309
    }
310
311
    @Override
312
    public CalculatedValue<Long> getCountValue() {
313
        if( this.count == null ) {
314
            this.count = new CountValue();
315
        }
316
        return this.count;
317
    }
318
319
    @Override
320
    public CalculatedValue<Envelope> getEnvelopeValue() {
321
        if( this.envelope == null ) {
322
            this.envelope = new EnvelopeValue();
323
        }
324
        return this.envelope;
325
    }
326
327
    @Override
328
    public CalculatedValue<Boolean> getAllowWriteValue() {
329
        if( this.allowWrite == null ) {
330
            this.allowWrite = new AllowWriteValue();
331
        }
332
        return this.allowWrite;
333
    }
334
335
    @Override
336
    public long getFeatureCount() throws DataException {
337
        return this.getCountValue().get();
338
    }
339
340
    @Override
341
    public boolean closeResourceRequested(ResourceProvider resource) {
342
        ResulSetControler resulSetControler = this.getHelper().getResulSetControler();
343
        resulSetControler.pack();
344
        return resulSetControler.getOpenCount() == 0;
345
    }
346
347
    @Override
348
    public void close() throws CloseException {
349
        JDBCUtils.closeQuietly(this.getHelper());
350
    }
351
352
    @Override
353
    public void resourceChanged(ResourceProvider resource) {
354
        this.getStoreServices().notifyChange(
355
                DataStoreNotification.RESOURCE_CHANGED,
356
                resource
357
        );
358
    }
359
360
    @Override
361
    public DataServerExplorer getExplorer() throws ReadException {
362
        DataManager manager = DALLocator.getDataManager();
363
        JDBCServerExplorerParameters exParams;
364
        JDBCStoreParameters params = getParameters();
365
        try {
366
            exParams = this.getHelper().createServerExplorerParameters();
367 44185 jjdelcerro
            DynField[] fields = exParams.getDynClass().getDynFields();
368
            for (DynField field : fields) {
369
                try {
370
                    exParams.setDynValue(field.getName(), params.getDynValue(field.getName()));
371
                } catch(Exception ex) {
372
                    // Ignore
373
                }
374
            }
375 43020 jjdelcerro
            exParams.setHost(params.getHost());
376
            exParams.setPort(params.getPort());
377
            exParams.setDBName(params.getDBName());
378
            exParams.setUser(params.getUser());
379
            exParams.setPassword(params.getPassword());
380
            exParams.setUrl(params.getUrl());
381
            exParams.setCatalog(params.getCatalog());
382
            exParams.setSchema(params.getSchema());
383
            exParams.setJDBCDriverClassName(params.getJDBCDriverClassName());
384
385
            return manager.openServerExplorer(exParams.getExplorerName(), exParams);
386
        } catch (Exception e) {
387
            throw new ReadException(this.getProviderName(), e);
388
        }
389
    }
390
391
    @Override
392
    protected void doDispose() throws BaseException {
393
        this.close();
394
        this.getHelper().dispose();
395
        super.doDispose();
396
    }
397
398
    @Override
399
    public String getSourceId() {
400 43361 jjdelcerro
        try {
401
            return this.getHelper().getSourceId(this.getParameters());
402
        } catch(Exception ex) {
403
            return "unknow";
404
        }
405 43020 jjdelcerro
    }
406
407
    @Override
408
    public String getName() {
409 43397 jjdelcerro
        return this.getParameters().getTable();
410 43020 jjdelcerro
    }
411
412
    @Override
413
    public String getFullName() {
414
        return this.getHelper().getSourceId(this.getParameters());
415
    }
416
417 43409 jjdelcerro
    private static class DummyResource extends AbstractResource {
418
419
        private final String name;
420
421
        DummyResource(String name) throws InitializeException {
422
            super((ResourceParameters)null);
423
            this.name = name;
424
        }
425
426
        @Override
427
        public String getName() throws AccessResourceException {
428
            return MessageFormat.format("DummyResource({0})",
429
                                new Object[] { this.name });
430
        }
431
432
        @Override
433
        public Object get() throws AccessResourceException {
434
            return null;
435
        }
436
437
        @Override
438
        public boolean isThis(ResourceParameters parameters) throws ResourceException {
439
            return true;
440
        }
441
442
    }
443
444 43020 jjdelcerro
    @Override
445
    public ResourceProvider getResource() {
446 43409 jjdelcerro
        ResourceProvider r = getHelper().getResource();
447
        if( r == null ) {
448
            try {
449
                r = new DummyResource(this.getName());
450
            } catch (InitializeException ex) {
451 44058 jjdelcerro
                LOGGER.warn("Can't create DummyResource",ex);
452 43409 jjdelcerro
                // Do nothing
453
            }
454
        }
455
        return r;
456 43020 jjdelcerro
    }
457
458
    @Override
459
    public void open() throws OpenException {
460
461
    }
462
463
    @Override
464
    public FeatureSetProvider createSet(
465
            FeatureQuery query,
466
            FeatureType featureType
467
        ) throws DataException {
468
469
        FeatureSetProvider set = new JDBCSetProvider(
470
                this,
471
                this.getHelper(),
472
                query,
473
                featureType
474
        );
475
476
        return set;
477
    }
478
479
    protected void initializeFeatureType() {
480
        EditableFeatureType type = this.getStoreServices().createFeatureType(getName());
481
        JDBCStoreParameters params = this.getParameters();
482
        List<String> primaryKeys = null;
483
        if( params.getPkFields() != null ) {
484
            primaryKeys = Arrays.asList(params.getPkFields());
485
        }
486
        FetchFeatureTypeOperation fetchFeatureType =
487
             this.getOperations().createFetchFeatureType(
488
                type,
489 44058 jjdelcerro
                this.getOperations().createTableReference(params),
490 43020 jjdelcerro
                primaryKeys,
491
                params.getDefaultGeometryField(),
492
                params.getCRS()
493
            );
494
        fetchFeatureType.perform();
495
496 45008 omartinez
        if (!StringUtils.isBlank(params.getDefaultGeometryField())) {
497
            if (!params.getDefaultGeometryField().equalsIgnoreCase(type.getDefaultGeometryAttributeName())) {
498
                if (type.getAttributeDescriptor(params.getDefaultGeometryField()) != null) {
499
                    type.setDefaultGeometryAttributeName(params.getDefaultGeometryField());
500
                } else {
501
                    type.setDefaultGeometryAttributeName(null);
502
                }
503
                if (type.getDefaultGeometryAttribute() != null) {
504
                    EditableFeatureAttributeDescriptor attr = (EditableFeatureAttributeDescriptor) type.getDefaultGeometryAttribute();
505
                    attr.setGeometryType(Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM2D);
506
                }
507
            } else {
508
                type.setDefaultGeometryAttributeName(null);
509 43420 jjdelcerro
            }
510
        }
511 45008 omartinez
512 43020 jjdelcerro
        FeatureType defaultType = type.getNotEditableCopy();
513 45152 fdiaz
        this.getHelper().setProviderFeatureType(defaultType);
514 43020 jjdelcerro
        List<FeatureType> types = Collections.singletonList(defaultType);
515
        this.getStoreServices().setFeatureTypes(types, defaultType);
516
    }
517
518
    @Override
519
    protected FeatureProvider internalGetFeatureProviderByReference(
520
            FeatureReferenceProviderServices reference,
521
            FeatureType featureType
522
        ) throws DataException {
523
        JDBCStoreParameters params = this.getParameters();
524
        FetchFeatureProviderByReferenceOperation fetchFeatureProviderByReference =
525
            this.getOperations().createFetchFeatureProviderByReference(
526
                reference,
527
                featureType,
528 44058 jjdelcerro
                this.getOperations().createTableReference(params)
529 43020 jjdelcerro
            );
530
        FeatureProvider feature = (FeatureProvider) fetchFeatureProviderByReference.perform();
531
        return feature;
532
    }
533
534
    @Override
535
    public Envelope getEnvelope() throws DataException {
536
        return this.getEnvelopeValue().get();
537
    }
538
539
    @Override
540
    public void performChanges(Iterator deleteds, Iterator inserteds,
541
                    Iterator updateds, Iterator featureTypesChanged)
542
                    throws DataException {
543
544
        FeatureType type = this.getFeatureStore().getDefaultFeatureType();
545
        JDBCStoreParameters params = this.getParameters();
546
        PerformChangesOperation performChanges = this.getOperations().createPerformChanges(
547 44058 jjdelcerro
                this.getOperations().createTableReference(params),
548 43020 jjdelcerro
                type,
549
                deleteds,
550
                inserteds,
551
                updateds,
552
                featureTypesChanged
553
        );
554
        performChanges.perform();
555
        if( performChanges.isTypeChanged() ) {
556
            // Get rules before initializing feature type
557
            FeatureRules saved_rules = getFeatureStore().getDefaultFeatureType().getRules();
558
559
             // This initialization loses the feature type rules
560
            this.initializeFeatureType();
561
562
            // Get new feature type, clear rules and add the ones saved previously
563
            FeatureType featureType = getFeatureStore().getDefaultFeatureType();
564
            FeatureRules rules = featureType.getRules();
565
            rules.clear();
566
            for (FeatureRule rule : saved_rules) {
567
                rules.add(rule);
568
            }
569
        }
570
        this.getCountValue().reset();
571
        this.getEnvelopeValue().reset();
572
    }
573
574
    @Override
575
    public boolean supportsAppendMode() {
576
        return true;
577
    }
578
579
    protected AppendOperation getAppendOperation() throws DataException {
580
        if( this.appendOperation == null ) {
581
            FeatureType type = this.getFeatureStore().getDefaultFeatureType();
582
            JDBCStoreParameters params = this.getParameters();
583
            this.appendOperation = this.getOperations().createAppend(
584 44058 jjdelcerro
                this.getOperations().createTableReference(params),
585 43020 jjdelcerro
                type
586
            );
587
        }
588
        return this.appendOperation;
589
    }
590
591
    @Override
592
    public void endAppend() throws DataException {
593
        this.getAppendOperation().end();
594
    }
595
596
    @Override
597 43408 jjdelcerro
    public void abortAppend() throws DataException {
598
        this.getAppendOperation().abort();
599
    }
600
601
    @Override
602 43020 jjdelcerro
    public void beginAppend() throws DataException {
603
        this.getAppendOperation().begin();
604
    }
605
606
    @Override
607
    public void append(final FeatureProvider featureProvider) throws DataException {
608
        this.getAppendOperation().append(featureProvider);
609
    }
610
611
    @Override
612
    public boolean canWriteGeometry(int geometryType, int geometrySubtype)
613
            throws DataException {
614
        return this.getHelper().canWriteGeometry(geometryType,geometrySubtype);
615
    }
616 45425 jjdelcerro
617
    @Override
618
    public boolean supportsPassThroughMode() {
619
        return true;
620
    }
621
622
    @Override
623
    public void passThroughInsert(FeatureProvider featureProvider) throws DataException {
624
        FeatureType type = this.getFeatureStore().getDefaultFeatureType();
625
        JDBCStoreParameters params = this.getParameters();
626
        PerformChangesOperation performChanges = this.getOperations().createPerformChanges(
627
                this.getOperations().createTableReference(params),
628
                type,
629
                Collections.emptyIterator(),
630
                Collections.singletonList(featureProvider).iterator(),
631
                Collections.emptyIterator(),
632
                Collections.emptyIterator()
633
        );
634
        performChanges.perform();
635
    }
636
637
    @Override
638
    public void passThroughUpdate(FeatureProvider featureProvider) throws DataException {
639
        FeatureType type = this.getFeatureStore().getDefaultFeatureType();
640
        JDBCStoreParameters params = this.getParameters();
641
        PerformChangesOperation performChanges = this.getOperations().createPerformChanges(
642
                this.getOperations().createTableReference(params),
643
                type,
644
                Collections.emptyIterator(),
645
                Collections.emptyIterator(),
646
                Collections.singletonList(featureProvider).iterator(),
647
                Collections.emptyIterator()
648
        );
649
        performChanges.perform();
650
    }
651
652 45473 fdiaz
    @Override
653 45425 jjdelcerro
    public void passThroughUpdate(Object[] parameters, Expression filter){
654 45473 fdiaz
        JDBCStoreParameters params = this.getParameters();
655
        UpdatePassThroughOperation operation = this.getOperations().createUpdatePassThroughOperation(
656
                this.getOperations().createTableReference(params),
657
                parameters,
658
                filter
659
        );
660
        operation.perform();
661 45425 jjdelcerro
    }
662
663
    @Override
664
    public void passThroughDelete(FeatureReferenceProviderServices featureReference) throws DataException {
665
        FeatureType type = this.getFeatureStore().getDefaultFeatureType();
666
        JDBCStoreParameters params = this.getParameters();
667
        PerformChangesOperation performChanges = this.getOperations().createPerformChanges(
668
                this.getOperations().createTableReference(params),
669
                type,
670
                Collections.singletonList(featureReference).iterator(),
671
                Collections.emptyIterator(),
672
                Collections.emptyIterator(),
673
                Collections.emptyIterator()
674
        );
675
        performChanges.perform();
676
    }
677
678
    public void passThroughDelete(Expression expression) throws DataException {
679 45473 fdiaz
        JDBCStoreParameters params = this.getParameters();
680
        DeletePassThroughOperation operation = this.getOperations().createDeletePassThroughOperation(
681
                this.getOperations().createTableReference(params),
682
                expression
683
        );
684
        operation.perform();
685 45425 jjdelcerro
    }
686 43020 jjdelcerro
}