Revision 45473
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 | ||
---|---|---|
1588 | 1588 |
|
1589 | 1589 |
switch (this.mode){ |
1590 | 1590 |
case MODE_PASS_THROUGH: |
1591 |
// this.provider.passThroughUpdate(parameters, filter); |
|
1592 |
// break; |
|
1591 |
this.provider.passThroughUpdate( |
|
1592 |
// this.getName(), |
|
1593 |
parameters, |
|
1594 |
filter); |
|
1595 |
break; |
|
1593 | 1596 |
case MODE_FULLEDIT: |
1594 | 1597 |
FeatureSet set = this.getFeatureSet(filter); |
1595 | 1598 |
DisposableIterator it = set.fastIterator(); |
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/OperationsFactory.java | ||
---|---|---|
27 | 27 |
import java.util.List; |
28 | 28 |
import org.apache.commons.lang3.tuple.Pair; |
29 | 29 |
import org.cresques.cts.IProjection; |
30 |
import org.gvsig.expressionevaluator.Expression; |
|
31 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
30 | 32 |
import org.gvsig.fmap.dal.exception.DataException; |
31 | 33 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
32 | 34 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
33 | 35 |
import org.gvsig.fmap.dal.feature.FeatureType; |
34 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
35 | 36 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
36 | 37 |
import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters; |
37 | 38 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
... | ... | |
40 | 41 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CalculateEnvelopeOfColumnOperation; |
41 | 42 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CanCreateTablesOperation; |
42 | 43 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CanModifyTableOperation; |
44 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CountOperation; |
|
43 | 45 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CreateTableOperation; |
46 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.DeletePassThroughOperation; |
|
47 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.DropTableOperation; |
|
48 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ExecuteOperation; |
|
44 | 49 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureProviderByReferenceOperation; |
45 | 50 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation; |
46 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.TableIsEmptyOperation; |
|
47 | 51 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ListTablesOperation; |
48 | 52 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.PerformChangesOperation; |
49 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.DropTableOperation; |
|
50 | 53 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ResultSetForSetProviderOperation; |
51 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CountOperation;
|
|
52 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ExecuteOperation;
|
|
54 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.TableIsEmptyOperation;
|
|
55 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.UpdatePassThroughOperation;
|
|
53 | 56 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.UpdateTableStatisticsOperation; |
54 | 57 |
import org.gvsig.fmap.geom.primitive.Envelope; |
55 | 58 |
|
... | ... | |
168 | 171 |
|
169 | 172 |
public ExecuteOperation createExecute(String sql); |
170 | 173 |
|
174 |
public UpdatePassThroughOperation createUpdatePassThroughOperation( |
|
175 |
TableReference table, |
|
176 |
Object[] parameters, |
|
177 |
Expression filter |
|
178 |
); |
|
179 |
|
|
180 |
public DeletePassThroughOperation createDeletePassThroughOperation( |
|
181 |
TableReference table, |
|
182 |
Expression filter |
|
183 |
); |
|
184 |
|
|
185 |
|
|
171 | 186 |
} |
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/operations/UpdatePassThroughOperation.java | ||
---|---|---|
1 |
/** |
|
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 |
package org.gvsig.fmap.dal.store.jdbc2.spi.operations; |
|
25 |
|
|
26 |
import java.sql.Connection; |
|
27 |
import java.sql.Statement; |
|
28 |
import org.gvsig.expressionevaluator.Expression; |
|
29 |
import org.gvsig.fmap.dal.exception.DataException; |
|
30 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
31 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
|
32 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
33 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
34 |
|
|
35 |
public class UpdatePassThroughOperation extends AbstractConnectionOperation { |
|
36 |
|
|
37 |
private final Object[] parameters; |
|
38 |
private final Expression filter; |
|
39 |
private final TableReference table; |
|
40 |
|
|
41 |
|
|
42 |
public UpdatePassThroughOperation( |
|
43 |
JDBCHelper helper, |
|
44 |
TableReference table, |
|
45 |
Object[] parameters, |
|
46 |
Expression filter |
|
47 |
) { |
|
48 |
super(helper); |
|
49 |
this.table = table; |
|
50 |
this.parameters = parameters; |
|
51 |
this.filter = filter; |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public final Object perform(Connection conn) throws DataException { |
|
56 |
return execute(this.table, this.parameters, this.filter); |
|
57 |
} |
|
58 |
|
|
59 |
public Object execute( |
|
60 |
TableReference table, |
|
61 |
Object[] parameters, |
|
62 |
Expression filter |
|
63 |
) { |
|
64 |
Statement st = null; |
|
65 |
String sql = getSQL(table, parameters, filter); |
|
66 |
try { |
|
67 |
st = this.getConnection().createStatement(); |
|
68 |
JDBCUtils.executeUpdate(st, sql); |
|
69 |
JDBCUtils.closeQuietly(st); |
|
70 |
return null; |
|
71 |
} catch (Exception ex) { |
|
72 |
JDBCUtils.closeQuietly(st); |
|
73 |
throw new RuntimeException("Can't execute query ["+sql+"].",ex); |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
public String getSQL( |
|
78 |
TableReference table, |
|
79 |
Object[] parameters, |
|
80 |
Expression filter) { |
|
81 |
|
|
82 |
JDBCSQLBuilderBase sqlbuilder = createSQLBuilder(); |
|
83 |
|
|
84 |
sqlbuilder.update().table() |
|
85 |
.database(this.table.getDatabase()) |
|
86 |
.schema(this.table.getSchema()) |
|
87 |
.name(this.table.getTable()); |
|
88 |
|
|
89 |
|
|
90 |
for (int i = 0; i < parameters.length-1; i+=2){ |
|
91 |
String field = (String) parameters[i]; |
|
92 |
sqlbuilder.update().column().name(field).with_value(sqlbuilder.expression().constant(parameters[i+1])); |
|
93 |
} |
|
94 |
|
|
95 |
if(filter != null ){ |
|
96 |
sqlbuilder.update().where().set(filter.getCode().toValue()); |
|
97 |
} |
|
98 |
|
|
99 |
String sql = sqlbuilder.update().toString(); |
|
100 |
return sql; |
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
} |
|
106 |
|
|
107 |
} |
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/operations/OperationsFactoryBase.java | ||
---|---|---|
28 | 28 |
import org.apache.commons.lang3.StringUtils; |
29 | 29 |
import org.apache.commons.lang3.tuple.Pair; |
30 | 30 |
import org.cresques.cts.IProjection; |
31 |
import org.gvsig.expressionevaluator.Expression; |
|
32 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
31 | 33 |
import org.gvsig.fmap.dal.exception.DataException; |
32 | 34 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
33 | 35 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
34 | 36 |
import org.gvsig.fmap.dal.feature.FeatureType; |
35 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
36 | 37 |
import org.gvsig.fmap.dal.feature.spi.FeatureReferenceProviderServices; |
37 | 38 |
import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters; |
38 | 39 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
... | ... | |
301 | 302 |
public ExecuteOperation createExecute(String sql) { |
302 | 303 |
return new ExecuteOperation(helper, sql); |
303 | 304 |
} |
305 |
|
|
306 |
@Override |
|
307 |
public UpdatePassThroughOperation createUpdatePassThroughOperation( |
|
308 |
TableReference table, |
|
309 |
Object[] parameters, |
|
310 |
Expression filter |
|
311 |
) { |
|
312 |
return new UpdatePassThroughOperation(helper, table, parameters, filter); |
|
313 |
} |
|
314 |
|
|
315 |
@Override |
|
316 |
public DeletePassThroughOperation createDeletePassThroughOperation( |
|
317 |
TableReference table, |
|
318 |
Expression filter |
|
319 |
) { |
|
320 |
return new DeletePassThroughOperation(helper, table, filter); |
|
321 |
} |
|
322 |
|
|
323 |
|
|
304 | 324 |
|
305 | 325 |
} |
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/operations/DeletePassThroughOperation.java | ||
---|---|---|
1 |
/** |
|
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 |
package org.gvsig.fmap.dal.store.jdbc2.spi.operations; |
|
25 |
|
|
26 |
import java.sql.Connection; |
|
27 |
import java.sql.Statement; |
|
28 |
import org.gvsig.expressionevaluator.Expression; |
|
29 |
import org.gvsig.fmap.dal.exception.DataException; |
|
30 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
31 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
|
32 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
33 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
34 |
|
|
35 |
public class DeletePassThroughOperation extends AbstractConnectionOperation { |
|
36 |
|
|
37 |
private final Expression filter; |
|
38 |
private final TableReference table; |
|
39 |
|
|
40 |
|
|
41 |
public DeletePassThroughOperation( |
|
42 |
JDBCHelper helper, |
|
43 |
TableReference table, |
|
44 |
Expression filter |
|
45 |
) { |
|
46 |
super(helper); |
|
47 |
this.table = table; |
|
48 |
this.filter = filter; |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public final Object perform(Connection conn) throws DataException { |
|
53 |
return execute(this.table, this.filter); |
|
54 |
} |
|
55 |
|
|
56 |
public Object execute( |
|
57 |
TableReference table, |
|
58 |
Expression filter |
|
59 |
) { |
|
60 |
Statement st = null; |
|
61 |
String sql = getSQL(table, filter); |
|
62 |
try { |
|
63 |
st = this.getConnection().createStatement(); |
|
64 |
JDBCUtils.executeUpdate(st, sql); |
|
65 |
JDBCUtils.closeQuietly(st); |
|
66 |
return null; |
|
67 |
} catch (Exception ex) { |
|
68 |
JDBCUtils.closeQuietly(st); |
|
69 |
throw new RuntimeException("Can't execute query ["+sql+"].",ex); |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
public String getSQL( |
|
74 |
TableReference table, |
|
75 |
Expression filter) { |
|
76 |
|
|
77 |
JDBCSQLBuilderBase sqlbuilder = createSQLBuilder(); |
|
78 |
|
|
79 |
sqlbuilder.delete().table() |
|
80 |
.database(this.table.getDatabase()) |
|
81 |
.schema(this.table.getSchema()) |
|
82 |
.name(this.table.getTable()); |
|
83 |
|
|
84 |
|
|
85 |
if(filter != null ){ |
|
86 |
sqlbuilder.delete().where().set(filter.getCode().toValue()); |
|
87 |
} |
|
88 |
|
|
89 |
String sql = sqlbuilder.delete().toString(); |
|
90 |
return sql; |
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
} |
|
96 |
|
|
97 |
} |
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 | ||
---|---|---|
72 | 72 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CalculateEnvelopeOfColumnOperation; |
73 | 73 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CanModifyTableOperation; |
74 | 74 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CountOperation; |
75 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.DeletePassThroughOperation; |
|
75 | 76 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureProviderByReferenceOperation; |
76 | 77 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation; |
77 | 78 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.PerformChangesOperation; |
79 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.UpdatePassThroughOperation; |
|
78 | 80 |
import org.gvsig.fmap.geom.Geometry; |
79 | 81 |
import org.gvsig.fmap.geom.primitive.Envelope; |
80 | 82 |
import org.gvsig.tools.dynobject.DynField; |
... | ... | |
647 | 649 |
performChanges.perform(); |
648 | 650 |
} |
649 | 651 |
|
652 |
@Override |
|
650 | 653 |
public void passThroughUpdate(Object[] parameters, Expression filter){ |
651 |
//TODO: |
|
654 |
JDBCStoreParameters params = this.getParameters(); |
|
655 |
UpdatePassThroughOperation operation = this.getOperations().createUpdatePassThroughOperation( |
|
656 |
this.getOperations().createTableReference(params), |
|
657 |
parameters, |
|
658 |
filter |
|
659 |
); |
|
660 |
operation.perform(); |
|
652 | 661 |
} |
653 | 662 |
|
654 | 663 |
@Override |
... | ... | |
667 | 676 |
} |
668 | 677 |
|
669 | 678 |
public void passThroughDelete(Expression expression) throws DataException { |
670 |
//TODO: |
|
679 |
JDBCStoreParameters params = this.getParameters(); |
|
680 |
DeletePassThroughOperation operation = this.getOperations().createDeletePassThroughOperation( |
|
681 |
this.getOperations().createTableReference(params), |
|
682 |
expression |
|
683 |
); |
|
684 |
operation.perform(); |
|
671 | 685 |
} |
672 | 686 |
} |
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/FeatureStoreProvider.java | ||
---|---|---|
25 | 25 |
package org.gvsig.fmap.dal.feature.spi; |
26 | 26 |
|
27 | 27 |
import java.util.Iterator; |
28 |
import org.gvsig.expressionevaluator.Expression; |
|
28 | 29 |
import org.gvsig.fmap.dal.DataStoreParameters; |
29 | 30 |
import org.gvsig.fmap.dal.DataTypes; |
30 | 31 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
269 | 270 |
|
270 | 271 |
public void passThroughDelete(FeatureReferenceProviderServices featureReference) throws DataException; |
271 | 272 |
|
273 |
public void passThroughUpdate(Object[] parameters, Expression filter); |
|
274 |
|
|
275 |
// ++++ |
|
276 |
|
|
277 |
|
|
272 | 278 |
} |
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/AbstractFeatureStoreProvider.java | ||
---|---|---|
31 | 31 |
import org.apache.commons.io.FilenameUtils; |
32 | 32 |
import org.cresques.cts.ICRSFactory; |
33 | 33 |
import org.cresques.cts.IProjection; |
34 |
import org.gvsig.expressionevaluator.Expression; |
|
34 | 35 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
35 | 36 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
36 | 37 |
import org.gvsig.fmap.dal.DALLocator; |
... | ... | |
613 | 614 |
public void passThroughDelete(FeatureReferenceProviderServices featureReference) throws DataException { |
614 | 615 |
throw new UnsupportedOperationException(); |
615 | 616 |
} |
617 |
|
|
618 |
@Override |
|
619 |
public void passThroughUpdate(Object[] parameters, Expression filter){ |
|
620 |
throw new UnsupportedOperationException(); |
|
621 |
} |
|
616 | 622 |
|
617 | 623 |
} |
Also available in: Unified diff