Revision 46277
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/DummyFetureStore.java | ||
---|---|---|
957 | 957 |
public List<FeatureReference> getEditedFeaturesNotValidated() { |
958 | 958 |
return Collections.EMPTY_LIST; |
959 | 959 |
} |
960 |
|
|
961 |
@Override |
|
962 |
public boolean isFeatureSelectionEmpty() { |
|
963 |
return false; |
|
964 |
} |
|
965 |
|
|
966 |
@Override |
|
967 |
public boolean isFeatureSelectionAvailable() { |
|
968 |
return true; |
|
969 |
} |
|
960 | 970 |
|
961 | 971 |
} |
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/FeatureQuery.java | ||
---|---|---|
355 | 355 |
*/ |
356 | 356 |
public void setVar(String name, Object value); |
357 | 357 |
|
358 |
public boolean hasLimit(); |
|
358 | 359 |
} |
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/FeatureStore.java | ||
---|---|---|
1395 | 1395 |
public List<FeatureReference> getEditedFeatures(); |
1396 | 1396 |
|
1397 | 1397 |
public List<FeatureReference> getEditedFeaturesNotValidated(); |
1398 |
|
|
1399 |
public boolean isFeatureSelectionEmpty(); |
|
1398 | 1400 |
|
1401 |
public boolean isFeatureSelectionAvailable(); |
|
1399 | 1402 |
} |
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 | ||
---|---|---|
1208 | 1208 |
@Override |
1209 | 1209 |
public SelectBuilder limit(Long limit) { |
1210 | 1210 |
if (limit == null) { |
1211 |
this.limit = 0;
|
|
1211 |
this.limit = -1;
|
|
1212 | 1212 |
} else { |
1213 | 1213 |
this.limit = limit; |
1214 | 1214 |
} |
... | ... | |
1217 | 1217 |
|
1218 | 1218 |
@Override |
1219 | 1219 |
public boolean has_limit() { |
1220 |
return this.limit > 0; |
|
1220 |
return this.limit >= 0;
|
|
1221 | 1221 |
} |
1222 | 1222 |
|
1223 | 1223 |
@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 | ||
---|---|---|
126 | 126 |
import org.gvsig.fmap.dal.feature.impl.editing.memory.FeatureTypeManager; |
127 | 127 |
import org.gvsig.fmap.dal.feature.impl.editing.memory.SpatialManager; |
128 | 128 |
import org.gvsig.fmap.dal.feature.impl.featurereference.FeatureReferenceFactory; |
129 |
import org.gvsig.fmap.dal.feature.impl.featurereference.FeatureReferenceIteratorToFeatureIterator; |
|
129 | 130 |
import org.gvsig.fmap.dal.feature.impl.featureset.DefaultFeatureSet; |
130 | 131 |
import org.gvsig.fmap.dal.feature.impl.undo.DefaultFeatureCommandsStack; |
131 | 132 |
import org.gvsig.fmap.dal.feature.impl.undo.FeatureCommandsStack; |
... | ... | |
951 | 952 |
return selection; |
952 | 953 |
} |
953 | 954 |
|
955 |
@Override |
|
956 |
public boolean isFeatureSelectionEmpty() { |
|
957 |
if( selection == null ) { |
|
958 |
return true; |
|
959 |
} |
|
960 |
return selection.isEmpty(); |
|
961 |
} |
|
962 |
|
|
954 | 963 |
// |
955 | 964 |
// ==================================================================== |
956 | 965 |
// Gestion de notificaciones |
... | ... | |
3825 | 3834 |
|
3826 | 3835 |
} |
3827 | 3836 |
|
3837 |
public Iterator<Feature> getFeaturesIterator(Iterator<FeatureReference> references) { |
|
3838 |
return new FeatureReferenceIteratorToFeatureIterator(this, references); |
|
3839 |
} |
|
3840 |
|
|
3841 |
public boolean isFeatureSelectionAvailable() { |
|
3842 |
try { |
|
3843 |
FeatureType type = this.getDefaultFeatureType(); |
|
3844 |
return type.supportReferences(); |
|
3845 |
} catch (DataException ex) { |
|
3846 |
return false; |
|
3847 |
} |
|
3848 |
} |
|
3828 | 3849 |
} |
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/DefaultFeatureQuery.java | ||
---|---|---|
127 | 127 |
public DefaultFeatureQuery() { |
128 | 128 |
super(); |
129 | 129 |
this.useSubquery = true; // true for backwards compatibility. |
130 |
this.limit = -1; |
|
130 | 131 |
} |
131 | 132 |
|
132 | 133 |
public DefaultFeatureQuery(String storeName) { |
... | ... | |
493 | 494 |
} |
494 | 495 |
|
495 | 496 |
@Override |
497 |
public boolean hasLimit() { |
|
498 |
return this.limit>-1; |
|
499 |
} |
|
500 |
|
|
501 |
@Override |
|
496 | 502 |
public boolean hasOrder() { |
497 | 503 |
return this.order != null && this.order.size() > 0; |
498 | 504 |
} |
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/featureset/DefaultFeatureSet.java | ||
---|---|---|
246 | 246 |
} |
247 | 247 |
|
248 | 248 |
private long calculateSize() throws DataException { |
249 |
boolean hasLimit = this.query.hasLimit(); |
|
249 | 250 |
long limit = this.query.getLimit(); |
250 | 251 |
long mySize = 0; |
251 | 252 |
|
... | ... | |
258 | 259 |
return 0; |
259 | 260 |
} |
260 | 261 |
mySize = provider.getSize(); |
261 |
return (limit>0 && mySize>limit)? limit:mySize;
|
|
262 |
return (hasLimit && mySize>limit)? limit:mySize;
|
|
262 | 263 |
|
263 | 264 |
case FILTERED: |
264 | 265 |
case ORDERED_FILTERED: |
265 | 266 |
try { |
266 | 267 |
iter = this.fastIterator(); |
267 |
while ((limit>0 && (mySize<limit)) || limit==0 ) {
|
|
268 |
while ((hasLimit && (mySize<limit)) || !hasLimit ) {
|
|
268 | 269 |
iter.next(); |
269 | 270 |
mySize++; |
270 | 271 |
} |
... | ... | |
273 | 274 |
} finally { |
274 | 275 |
DisposeUtils.disposeQuietly(iter); |
275 | 276 |
} |
276 |
return (limit>0 && mySize>limit)? limit:mySize; |
|
277 |
return (limit>=0 && mySize>limit)? limit:mySize;
|
|
277 | 278 |
|
278 | 279 |
case EDITED: |
279 | 280 |
case ORDERD_EDITED: |
280 | 281 |
mySize = provider.getSize() |
281 | 282 |
+ store.getFeatureManager().getDeltaSize(); |
282 |
return (limit>0 && mySize>limit)? limit:mySize;
|
|
283 |
return (hasLimit && mySize>limit)? limit:mySize;
|
|
283 | 284 |
|
284 | 285 |
case EDITED_FILTERED: |
285 | 286 |
case ORDERED_EDITED_FILTER: |
286 | 287 |
try { |
287 | 288 |
iter = this.fastIterator(); |
288 |
while ((limit>0 && (mySize<limit)) || limit==0 ) {
|
|
289 |
while ((hasLimit && (mySize<limit)) || !hasLimit ) {
|
|
289 | 290 |
iter.next(); |
290 | 291 |
mySize++; |
291 | 292 |
} |
... | ... | |
294 | 295 |
} finally { |
295 | 296 |
DisposeUtils.disposeQuietly(iter); |
296 | 297 |
} |
297 |
return (limit>0 && mySize>limit)? limit:mySize;
|
|
298 |
return (hasLimit && mySize>limit)? limit:mySize;
|
|
298 | 299 |
|
299 | 300 |
default: |
300 | 301 |
throw new IllegalArgumentException(); |
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 | ||
---|---|---|
51 | 51 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ListTablesOperation; |
52 | 52 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.PerformChangesOperation; |
53 | 53 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ResultSetForSetProviderOperation; |
54 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.RetrieveValueOperation; |
|
54 | 55 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.TableIsEmptyOperation; |
55 | 56 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.UpdatePassThroughOperation; |
56 | 57 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.UpdateTableStatisticsOperation; |
... | ... | |
194 | 195 |
Expression filter |
195 | 196 |
); |
196 | 197 |
|
198 |
public RetrieveValueOperation createRetrieveValue( |
|
199 |
TableReference createTableReference, |
|
200 |
String filter, |
|
201 |
String order, |
|
202 |
String fieldname |
|
203 |
); |
|
197 | 204 |
|
205 |
|
|
198 | 206 |
} |
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/RetrieveValueOperation.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.io.IOException; |
|
27 |
import java.sql.Blob; |
|
28 |
import java.sql.Clob; |
|
29 |
import java.sql.Connection; |
|
30 |
import java.sql.ResultSet; |
|
31 |
import java.sql.SQLException; |
|
32 |
import java.sql.Statement; |
|
33 |
import org.apache.commons.io.IOUtils; |
|
34 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
|
35 |
import org.gvsig.fmap.dal.SQLBuilder.SelectBuilder; |
|
36 |
import org.gvsig.fmap.dal.exception.DataException; |
|
37 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
38 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
39 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException; |
|
40 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
|
41 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
42 |
|
|
43 |
public class RetrieveValueOperation extends AbstractConnectionOperation { |
|
44 |
|
|
45 |
private final TableReference table; |
|
46 |
private final String filter; |
|
47 |
private final String order; |
|
48 |
private final String fieldname; |
|
49 |
|
|
50 |
public RetrieveValueOperation( |
|
51 |
JDBCHelper helper |
|
52 |
) { |
|
53 |
this(helper, null, null, null, null); |
|
54 |
} |
|
55 |
|
|
56 |
public RetrieveValueOperation( |
|
57 |
JDBCHelper helper, |
|
58 |
TableReference table, |
|
59 |
String filter, |
|
60 |
String order, |
|
61 |
String fieldname |
|
62 |
) { |
|
63 |
super(helper); |
|
64 |
this.table = table; |
|
65 |
this.filter = filter; |
|
66 |
this.order = order; |
|
67 |
this.fieldname = fieldname; |
|
68 |
} |
|
69 |
|
|
70 |
@Override |
|
71 |
public final Object perform(Connection conn) throws DataException { |
|
72 |
return this.retrieveValue(conn); |
|
73 |
} |
|
74 |
|
|
75 |
public String getSQL() { |
|
76 |
JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder(); |
|
77 |
ExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
78 |
|
|
79 |
SelectBuilder select = sqlbuilder.select(); |
|
80 |
select.column().name(this.fieldname); |
|
81 |
select.where().set(expbuilder.toValue(this.filter)); |
|
82 |
// FIXME: Falta por ver de poner el order. |
|
83 |
select.from().table() |
|
84 |
.database(this.table.getDatabase()) |
|
85 |
.schema(this.table.getSchema()) |
|
86 |
.name(this.table.getTable()); |
|
87 |
String sql = select.toString(); |
|
88 |
return sql; |
|
89 |
} |
|
90 |
|
|
91 |
public Object retrieveValue(Connection conn) throws DataException { |
|
92 |
|
|
93 |
String sql = this.getSQL(); |
|
94 |
Statement st = null; |
|
95 |
ResultSet rs = null; |
|
96 |
try { |
|
97 |
st = conn.createStatement(); |
|
98 |
rs = JDBCUtils.executeQuery(st, sql); |
|
99 |
if (!rs.next()) { |
|
100 |
return null; |
|
101 |
} |
|
102 |
Object value = rs.getObject(1); |
|
103 |
if (value instanceof Blob) { |
|
104 |
Blob blob = (Blob) value; |
|
105 |
value = blob.getBytes(1, (int) blob.length()); |
|
106 |
blob.free(); |
|
107 |
} else if (value instanceof Clob) { |
|
108 |
Clob clob = (Clob) value; |
|
109 |
value = new String(IOUtils.toCharArray(clob.getCharacterStream())); |
|
110 |
clob.free(); |
|
111 |
} |
|
112 |
return value; |
|
113 |
|
|
114 |
} catch (SQLException ex) { |
|
115 |
throw new JDBCSQLException(ex,sql); |
|
116 |
} catch (IOException ex) { |
|
117 |
throw new JDBCSQLException(ex,sql); |
|
118 |
} finally { |
|
119 |
JDBCUtils.closeQuietly(st); |
|
120 |
JDBCUtils.closeQuietly(rs); |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
} |
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 | ||
---|---|---|
334 | 334 |
return new DeletePassThroughOperation(helper, table, filter); |
335 | 335 |
} |
336 | 336 |
|
337 |
@Override |
|
338 |
public RetrieveValueOperation createRetrieveValue( |
|
339 |
TableReference createTableReference, |
|
340 |
String filter, |
|
341 |
String order, |
|
342 |
String fieldname) { |
|
343 |
return new RetrieveValueOperation(helper, createTableReference, filter, order, fieldname); |
|
344 |
} |
|
337 | 345 |
|
346 |
|
|
338 | 347 |
|
348 |
|
|
339 | 349 |
} |
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/FetchFeatureTypeOperation.java | ||
---|---|---|
131 | 131 |
} |
132 | 132 |
st = conn.createStatement(); |
133 | 133 |
st.setFetchSize(1); |
134 |
rs = JDBCUtils.executeQuery(st, this.getSQLToRetrieveFirstRowOfTable());
|
|
134 |
rs = JDBCUtils.executeQuery(st, this.getSQLToRetrieveMetadataOfTable());
|
|
135 | 135 |
ResultSetMetaData rsMetadata = rs.getMetaData(); |
136 | 136 |
|
137 | 137 |
fetchFeatureTypeFromMetadata(conn, rsMetadata, pks); |
... | ... | |
144 | 144 |
} |
145 | 145 |
} |
146 | 146 |
|
147 |
public String getSQLToRetrieveFirstRowOfTable() {
|
|
147 |
public String getSQLToRetrieveMetadataOfTable() {
|
|
148 | 148 |
JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder(); |
149 | 149 |
sqlbuilder.select().column().all(); |
150 | 150 |
sqlbuilder.select().from().table() |
... | ... | |
152 | 152 |
.schema(this.table.getSchema()) |
153 | 153 |
.name(this.table.getTable()); |
154 | 154 |
// sqlbuilder.select().from().subquery(this.table.getSubquery()); |
155 |
sqlbuilder.select().limit(1);
|
|
155 |
sqlbuilder.select().limit(0);
|
|
156 | 156 |
|
157 | 157 |
String sql = sqlbuilder.toString(); |
158 | 158 |
return sql; |
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/JDBCServerExplorerBase.java | ||
---|---|---|
719 | 719 |
String theTableName = params.getTable(); |
720 | 720 |
if (StringUtils.equals(theTableName, resourcesTablename)) { |
721 | 721 |
defaultResourcesStorage = new JDBCResourcesStorage( |
722 |
this.helper, |
|
722 | 723 |
alternateResourcesStorage, |
723 | 724 |
params, |
724 | 725 |
storeName |
... | ... | |
736 | 737 |
JDBCStoreParameters params = this.getOpenParameters(); |
737 | 738 |
params.setTable(resourcesTablename); |
738 | 739 |
customResourcesStorage = new JDBCResourcesStorage( |
740 |
this.helper, |
|
739 | 741 |
alternateResourcesStorage, |
740 | 742 |
params, |
741 | 743 |
storeName, |
... | ... | |
759 | 761 |
params = this.getOpenParameters(); |
760 | 762 |
params.setTable(DatabaseWorkspaceManager.TABLE_RESOURCES_NAME); |
761 | 763 |
JDBCResourcesStorage theResourcesStorage = new JDBCResourcesStorage( |
764 |
this.helper, |
|
762 | 765 |
null, |
763 | 766 |
params, |
764 | 767 |
"$ServerExplorer" |
... | ... | |
840 | 843 |
params = this.getOpenParameters(); |
841 | 844 |
params.setTable(resourcesTableName); |
842 | 845 |
JDBCResourcesStorage resourcesStorage = new JDBCResourcesStorage( |
846 |
this.helper, |
|
843 | 847 |
null, |
844 | 848 |
params, |
845 | 849 |
tableName, |
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/JDBCResourcesStorage.java | ||
---|---|---|
51 | 51 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_RESOURCES_NAME; |
52 | 52 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_RESOURCES_RESOURCE; |
53 | 53 |
import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_RESOURCES_NAME; |
54 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
54 | 55 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
55 | 56 |
import org.gvsig.fmap.dal.feature.Feature; |
56 | 57 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
57 | 58 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
59 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
60 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
61 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.RetrieveValueOperation; |
|
58 | 62 |
import org.gvsig.tools.ToolsLocator; |
59 | 63 |
import org.gvsig.tools.dispose.DisposeUtils; |
60 | 64 |
import org.gvsig.tools.folders.FoldersManager; |
... | ... | |
72 | 76 |
public class JDBCResourcesStorage extends AbstractResourcesStorage { |
73 | 77 |
|
74 | 78 |
private static final Logger LOGGER = LoggerFactory.getLogger(JDBCResourcesStorage.class); |
79 |
private final JDBCHelper helper; |
|
75 | 80 |
|
76 | 81 |
private static class ExistsResourcesCache extends CachedValue<Map<String,Boolean>> { |
77 | 82 |
@Override |
... | ... | |
154 | 159 |
return null; |
155 | 160 |
} |
156 | 161 |
} |
162 |
|
|
163 |
private byte[] retrieveResource() throws Exception { |
|
164 |
ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
|
165 |
String filter = builder.eq( |
|
166 |
builder.column(FIELD_RESOURCES_NAME), |
|
167 |
builder.constant(this.getTableName() + "." + this.name) |
|
168 |
).toString(); |
|
169 |
OperationsFactory operations = this.storage.helper.getOperations(); |
|
170 |
RetrieveValueOperation op = operations.createRetrieveValue( |
|
171 |
operations.createTableReference(this.getStoreParameters()), |
|
172 |
filter, |
|
173 |
null, //order |
|
174 |
FIELD_RESOURCES_RESOURCE |
|
175 |
); |
|
176 |
return (byte[] ) op.perform(); |
|
177 |
} |
|
178 |
|
|
179 |
private byte[] retrieveResource0() throws Exception { |
|
180 |
FeatureStore store = null; |
|
181 |
try { |
|
182 |
DataManager dataManager = DALLocator.getDataManager(); |
|
183 |
store = (FeatureStore) dataManager.openStore( |
|
184 |
this.getStoreParameters().getDataStoreName(), |
|
185 |
this.getStoreParameters() |
|
186 |
); |
|
187 |
ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
|
188 |
String filter = builder.eq( |
|
189 |
builder.column(FIELD_RESOURCES_NAME), |
|
190 |
builder.constant(this.getTableName() + "." + this.name) |
|
191 |
).toString(); |
|
192 |
Feature feature = store.findFirst(filter); |
|
193 |
if (feature == null) { |
|
194 |
return null; |
|
195 |
} |
|
196 |
byte[] resource = feature.getByteArray(FIELD_RESOURCES_RESOURCE); |
|
197 |
return resource; |
|
198 |
} finally { |
|
199 |
DisposeUtils.disposeQuietly(store); |
|
200 |
} |
|
201 |
} |
|
157 | 202 |
|
158 | 203 |
@Override |
159 | 204 |
public boolean exists() { |
160 |
FeatureStore store = null; |
|
205 |
// FeatureStore store = null;
|
|
161 | 206 |
try { |
162 | 207 |
FoldersManager fm = ToolsLocator.getFoldersManager(); |
163 | 208 |
Pair<String, String> key = this.getCacheID(); |
... | ... | |
170 | 215 |
if( f.exists() ) { |
171 | 216 |
return true; |
172 | 217 |
} |
173 |
DataManager dataManager = DALLocator.getDataManager(); |
|
174 |
store = (FeatureStore) dataManager.openStore( |
|
175 |
this.getStoreParameters().getDataStoreName(), |
|
176 |
this.getStoreParameters() |
|
177 |
); |
|
178 |
ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
|
179 |
String filter = builder.eq( |
|
180 |
builder.column(FIELD_RESOURCES_NAME), |
|
181 |
builder.constant(this.getTableName()+"."+this.name) |
|
182 |
).toString(); |
|
183 |
Feature feature = store.findFirst(filter); |
|
184 |
boolean exists = feature!=null; |
|
218 |
// DataManager dataManager = DALLocator.getDataManager(); |
|
219 |
// store = (FeatureStore) dataManager.openStore( |
|
220 |
// this.getStoreParameters().getDataStoreName(), |
|
221 |
// this.getStoreParameters() |
|
222 |
// ); |
|
223 |
// ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
|
224 |
// String filter = builder.eq( |
|
225 |
// builder.column(FIELD_RESOURCES_NAME), |
|
226 |
// builder.constant(this.getTableName()+"."+this.name) |
|
227 |
// ).toString(); |
|
228 |
// Feature feature = store.findFirst(filter); |
|
229 |
byte[] resource = retrieveResource(); |
|
230 |
boolean exists = resource!=null; |
|
231 |
if( resource!=null ) { |
|
232 |
putResourceInCache(resource); |
|
233 |
} |
|
185 | 234 |
this.getExistsResourcesCache().put(key_s, exists); |
186 | 235 |
return exists; |
187 | 236 |
} catch (Throwable ex) { |
188 | 237 |
LOGGER.warn("Can't access to the resoure '" + this.getURL() + "'.", ex); |
189 |
} finally { |
|
190 |
DisposeUtils.disposeQuietly(store); |
|
238 |
// } finally {
|
|
239 |
// DisposeUtils.disposeQuietly(store);
|
|
191 | 240 |
} |
192 | 241 |
return false; |
193 | 242 |
} |
... | ... | |
289 | 338 |
} |
290 | 339 |
return is; |
291 | 340 |
} |
341 |
|
|
342 |
private void putResourceInCache(byte[] resource) { |
|
343 |
FoldersManager fm = ToolsLocator.getFoldersManager(); |
|
344 |
Pair<String, String> key = this.getCacheID(); |
|
345 |
File f = fm.getTemporaryFile("resources-storage", "jdbc", key.getLeft(), key.getRight()); |
|
346 |
FileOutputStream os = null; |
|
347 |
File f2 = null; |
|
348 |
try { |
|
349 |
FileUtils.forceMkdir(f.getParentFile()); |
|
350 |
os = new FileOutputStream(f); |
|
351 |
IOUtils.write(resource, os); |
|
352 |
IOUtils.closeQuietly(os); |
|
353 |
|
|
354 |
f2 = fm.getTemporaryFile("resources-storage", "jdbc", key.getLeft(), "parameters"); |
|
355 |
byte[] data = this.getStoreParameters().toByteArray(); |
|
356 |
os = new FileOutputStream(f2); |
|
357 |
IOUtils.write(data, os); |
|
358 |
} catch (IOException ex) { |
|
359 |
FileUtils.deleteQuietly(f); |
|
360 |
FileUtils.deleteQuietly(f2); |
|
361 |
} finally { |
|
362 |
IOUtils.closeQuietly(os); |
|
363 |
} |
|
364 |
} |
|
292 | 365 |
|
293 | 366 |
private InputStream getInputStream() throws IOException { |
294 |
FeatureStore store = null; |
|
367 |
// FeatureStore store = null;
|
|
295 | 368 |
try { |
296 |
DataManager dataManager = DALLocator.getDataManager(); |
|
297 |
store = (FeatureStore) dataManager.openStore( |
|
298 |
this.getStoreParameters().getDataStoreName(), |
|
299 |
this.getStoreParameters() |
|
300 |
); |
|
301 |
ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
|
302 |
String filter = builder.eq( |
|
303 |
builder.column(FIELD_RESOURCES_NAME), |
|
304 |
builder.constant(this.getTableName()+"."+this.name) |
|
305 |
).toString(); |
|
306 |
Feature feature = store.findFirst(filter); |
|
307 |
if (feature == null) { |
|
308 |
return null; |
|
309 |
} |
|
310 |
byte[] resource = feature.getByteArray(FIELD_RESOURCES_RESOURCE); |
|
369 |
// DataManager dataManager = DALLocator.getDataManager(); |
|
370 |
// store = (FeatureStore) dataManager.openStore( |
|
371 |
// this.getStoreParameters().getDataStoreName(), |
|
372 |
// this.getStoreParameters() |
|
373 |
// ); |
|
374 |
// ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
|
375 |
// String filter = builder.eq( |
|
376 |
// builder.column(FIELD_RESOURCES_NAME), |
|
377 |
// builder.constant(this.getTableName()+"."+this.name) |
|
378 |
// ).toString(); |
|
379 |
// Feature feature = store.findFirst(filter); |
|
380 |
// if (feature == null) { |
|
381 |
// return null; |
|
382 |
// } |
|
383 |
// byte[] resource = feature.getByteArray(FIELD_RESOURCES_RESOURCE); |
|
384 |
byte[] resource = retrieveResource(); |
|
311 | 385 |
InputStream is = new ByteArrayInputStream(resource); |
312 | 386 |
return is; |
313 | 387 |
} catch (Throwable ex) { |
314 | 388 |
LOGGER.warn("Can't access to the resoure '" + this.getURL() + "'.", ex); |
315 |
} finally { |
|
316 |
DisposeUtils.disposeQuietly(store); |
|
389 |
// } finally {
|
|
390 |
// DisposeUtils.disposeQuietly(store);
|
|
317 | 391 |
} |
318 | 392 |
return null; |
319 | 393 |
} |
... | ... | |
391 | 465 |
} |
392 | 466 |
} |
393 | 467 |
|
394 |
private final ResourcesStorage alternativeStorge; |
|
468 |
private final ResourcesStorage alternativeStorage;
|
|
395 | 469 |
private final JDBCStoreParameters resourcesStoreParameters; |
396 | 470 |
private final String tableName; |
397 | 471 |
private final boolean readonly; |
398 | 472 |
private final ExistsResourcesCache existsResourcesCache; |
399 | 473 |
|
400 | 474 |
public JDBCResourcesStorage( |
401 |
ResourcesStorage alternativeStorge, |
|
475 |
JDBCHelper helper, |
|
476 |
ResourcesStorage alternativeStorage, |
|
402 | 477 |
JDBCStoreParameters resourcesStoreParameters, |
403 | 478 |
String tableName |
404 | 479 |
) { |
405 |
this(alternativeStorge, resourcesStoreParameters, tableName, false);
|
|
480 |
this(helper, alternativeStorage, resourcesStoreParameters, tableName, false);
|
|
406 | 481 |
} |
407 | 482 |
|
408 | 483 |
public JDBCResourcesStorage( |
409 |
ResourcesStorage alternativeStorge, |
|
484 |
JDBCHelper helper, |
|
485 |
ResourcesStorage alternativeStorage, |
|
410 | 486 |
JDBCStoreParameters resourcesStoreParameters, |
411 | 487 |
String tableName, |
412 | 488 |
boolean readonly |
413 | 489 |
) { |
490 |
this.helper = helper; |
|
414 | 491 |
this.readonly = readonly; |
415 |
this.alternativeStorge = alternativeStorge;
|
|
492 |
this.alternativeStorage = alternativeStorage;
|
|
416 | 493 |
if( StringUtils.equals(TABLE_RESOURCES_NAME, tableName) ) { |
417 | 494 |
// No podemos buscar recursos de la tabla de recursos, ya que si no |
418 | 495 |
// al abrise la tabla de recursos entraria en bucle. |
... | ... | |
432 | 509 |
|
433 | 510 |
@Override |
434 | 511 |
public Resource getResource(String name) { |
435 |
if( this.alternativeStorge!=null ) { |
|
436 |
Resource r = this.alternativeStorge.getResource(name); |
|
512 |
if( this.alternativeStorage!=null ) {
|
|
513 |
Resource r = this.alternativeStorage.getResource(name);
|
|
437 | 514 |
if( r.exists() ) { |
438 | 515 |
return r; |
439 | 516 |
} |
... | ... | |
449 | 526 |
if (this.resourcesStoreParameters == null) { |
450 | 527 |
return null; |
451 | 528 |
} |
452 |
if( this.alternativeStorge!=null ) { |
|
453 |
List<Resource> r = this.alternativeStorge.getResources(name); |
|
529 |
if( this.alternativeStorage!=null ) {
|
|
530 |
List<Resource> r = this.alternativeStorage.getResources(name);
|
|
454 | 531 |
if( r!=null && !r.isEmpty() ) { |
455 | 532 |
return r; |
456 | 533 |
} |
... | ... | |
499 | 576 |
|
500 | 577 |
@Override |
501 | 578 |
public boolean remove(String resourceName) { |
502 |
if( this.alternativeStorge!=null ) { |
|
579 |
if( this.alternativeStorage!=null ) {
|
|
503 | 580 |
try { |
504 |
this.alternativeStorge.remove(resourceName); |
|
581 |
this.alternativeStorage.remove(resourceName);
|
|
505 | 582 |
} catch (Exception e) { |
506 | 583 |
//Do nothing |
507 | 584 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.mdb/src/test/java/org/gvsig/fmap/dal/store/mdb/operations/sql/TestFetchFeatureType.java | ||
---|---|---|
62 | 62 |
); |
63 | 63 |
|
64 | 64 |
|
65 |
String retrieveFirstRowOfTableSQL = fetchFeatureType.getSQLToRetrieveFirstRowOfTable();
|
|
65 |
String retrieveFirstRowOfTableSQL = fetchFeatureType.getSQLToRetrieveMetadataOfTable();
|
|
66 | 66 |
String retrievePrimaryKeysFromInformationSchemaSQL = fetchFeatureType.getSQLToRetrievePrimaryKeysFromInformationSchema(); |
67 | 67 |
System.out.println("Expected 0: "); |
68 | 68 |
System.out.println(expectedSQLs.get(0)); |
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/FLayers.java | ||
---|---|---|
134 | 134 |
if (layer instanceof FLyrVect) { |
135 | 135 |
try { |
136 | 136 |
FeatureStore store = ((FLyrVect) layer).getFeatureStore(); |
137 |
if (store.getFeatureSelection().isAvailable()) {
|
|
137 |
if (store.isFeatureSelectionAvailable()) {
|
|
138 | 138 |
return true; |
139 | 139 |
} |
140 | 140 |
} catch (Exception ex) { |
... | ... | |
151 | 151 |
if (layer instanceof FLyrVect) { |
152 | 152 |
try { |
153 | 153 |
FeatureStore store = ((FLyrVect) layer).getFeatureStore(); |
154 |
FeatureSelection selection = store.getFeatureSelection(); |
|
155 |
if (!selection.isAvailable() || selection.isEmpty()) { |
|
154 |
if (!store.isFeatureSelectionAvailable() || store.isFeatureSelectionEmpty()) { |
|
156 | 155 |
return true; |
157 | 156 |
} |
158 | 157 |
return false; |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/clipboard/PasteAlphanumericValuesFromClipboardExtension.java | ||
---|---|---|
26 | 26 |
import java.io.StringReader; |
27 | 27 |
import java.util.List; |
28 | 28 |
import java.util.function.Predicate; |
29 |
import java.util.logging.Level; |
|
30 | 29 |
|
31 | 30 |
import javax.swing.JOptionPane; |
32 | 31 |
import org.apache.commons.lang.mutable.MutableInt; |
... | ... | |
43 | 42 |
import org.gvsig.app.project.documents.view.ViewManager; |
44 | 43 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
45 | 44 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
46 |
import org.gvsig.fmap.geom.Geometry; |
|
47 | 45 |
import org.gvsig.fmap.mapcontext.MapContext; |
48 | 46 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
49 | 47 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
... | ... | |
60 | 58 |
import org.gvsig.fmap.dal.feature.Feature; |
61 | 59 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
62 | 60 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
61 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
63 | 62 |
|
63 |
@SuppressWarnings({"UseSpecificCatch", "Convert2Lambda", "ConvertToTryWithResources"}) |
|
64 | 64 |
public class PasteAlphanumericValuesFromClipboardExtension extends Extension { |
65 | 65 |
|
66 | 66 |
private static final Logger LOGGER = LoggerFactory.getLogger(PasteAlphanumericValuesFromClipboardExtension.class); |
... | ... | |
123 | 123 |
} |
124 | 124 |
|
125 | 125 |
MapContext mapContext = viewdoc.getMapContext(); |
126 |
List<FLayer> layers = mapContext.getLayers().getLayers(new Predicate<FLayer>() { |
|
127 |
@Override |
|
128 |
public boolean test(FLayer layer) { |
|
129 |
return layer instanceof FLyrVect |
|
130 |
&& layer.isActive() |
|
131 |
&& layer.isAvailable() |
|
132 |
&& layer.isEditing(); |
|
133 |
} |
|
134 |
}); |
|
126 |
List<FLayer> layers = mapContext.getLayers().getLayers((FLayer layer) -> layer instanceof FLyrVect |
|
127 |
&& layer.isActive() |
|
128 |
&& layer.isAvailable() |
|
129 |
&& layer.isEditing()); |
|
135 | 130 |
if (layers.isEmpty()) { |
136 | 131 |
return; |
137 | 132 |
} |
... | ... | |
157 | 152 |
} |
158 | 153 |
JsonObject fjson = (JsonObject) obj; |
159 | 154 |
try { |
155 |
boolean hasPk = false; |
|
156 |
FeatureType ft = store.getDefaultFeatureTypeQuietly(); |
|
157 |
for (String name : fjson.keySet()) { |
|
158 |
FeatureAttributeDescriptor attr = ft.getAttributeDescriptor(name); |
|
159 |
if( attr!=null ) { |
|
160 |
if( attr.isPrimaryKey() ) { |
|
161 |
hasPk = true; |
|
162 |
break; |
|
163 |
} |
|
164 |
} |
|
165 |
} |
|
166 |
final boolean copyPk = hasPk && (application.confirmDialog( |
|
167 |
i18n.getTranslation("_Copy_primary_key_values_XQuestionX"), |
|
168 |
i18n.getTranslation("_Pasting_features_from_clipboard"), |
|
169 |
JOptionPane.YES_NO_OPTION, |
|
170 |
JOptionPane.QUESTION_MESSAGE, |
|
171 |
"_CopyPrimaryKeyWhenPasteAlphanumericValuesFromClipboard" |
|
172 |
) == JOptionPane.YES_OPTION); |
|
160 | 173 |
EditableFeature f = store.createNewFeature(fjson); |
161 | 174 |
|
162 |
|
|
163 | 175 |
for (Feature selectionFeature : selectionFeatures) { |
164 | 176 |
EditableFeature eds = selectionFeature.getEditable(); |
165 | 177 |
eds.copyFrom(f, new Predicate<FeatureAttributeDescriptor>() { |
178 |
@Override |
|
166 | 179 |
public boolean test(FeatureAttributeDescriptor attr) { |
167 | 180 |
String nameGeom; |
168 | 181 |
try { |
... | ... | |
173 | 186 |
if (StringUtils.equals(attr.getName(), nameGeom)) { |
174 | 187 |
return false; |
175 | 188 |
} |
189 |
if( !copyPk && attr.isPrimaryKey() ) { |
|
190 |
return false; |
|
191 |
} |
|
176 | 192 |
return true; |
177 | 193 |
} |
178 | 194 |
}); |
... | ... | |
184 | 200 |
mapContext.invalidate(); |
185 | 201 |
} |
186 | 202 |
|
187 |
//metodo static para escribir en el store |
|
188 |
// pasteFromClipboard(FeatureStore store) |
|
189 |
|
|
190 |
// isValidClipboard() |
|
191 |
|
|
192 |
|
|
193 | 203 |
@Override |
194 | 204 |
public boolean isEnabled() { |
195 | 205 |
ApplicationManager application = ApplicationLocator.getManager(); |
... | ... | |
227 | 237 |
if (layer.isEditing()) { |
228 | 238 |
numActiveVectorialEditable.increment(); |
229 | 239 |
} |
230 |
try { |
|
231 |
if (!((FLyrVect) layer).getFeatureStore().getFeatureSelection().isEmpty()) { |
|
232 |
hasSelection.increment(); |
|
233 |
} |
|
234 |
} catch (DataException ex) { |
|
235 |
|
|
240 |
if (!((FLyrVect) layer).getFeatureStore().isFeatureSelectionEmpty()) { |
|
241 |
hasSelection.increment(); |
|
236 | 242 |
} |
237 | 243 |
} |
238 | 244 |
// No recuperamos ninguna capa, solo contamos las activa en edicion |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/clipboard/CopyFeaturesToClipboardExtension.java | ||
---|---|---|
109 | 109 |
return false; |
110 | 110 |
} |
111 | 111 |
try { |
112 |
FeatureSelection selection = layer.getFeatureStore().getFeatureSelection(); |
|
113 |
return !selection.isEmpty(); |
|
112 |
return !layer.getFeatureStore().isFeatureSelectionEmpty(); |
|
114 | 113 |
} catch (Exception ex) { |
115 | 114 |
LOGGER.warn("Can't get selection from layer '"+layer.getName()+"'.", ex); |
116 | 115 |
return false; |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/clipboard/PasteFeaturesFromClipboardExtension.java | ||
---|---|---|
57 | 57 |
import javax.json.Json; |
58 | 58 |
import javax.json.JsonArray; |
59 | 59 |
import javax.json.JsonReader; |
60 |
import org.gvsig.fmap.dal.exception.DataException; |
|
61 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
62 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
60 | 63 |
|
61 | 64 |
|
62 | 65 |
public class PasteFeaturesFromClipboardExtension extends Extension { |
... | ... | |
136 | 139 |
} |
137 | 140 |
FLyrVect layer = (FLyrVect) layers.get(0); |
138 | 141 |
FeatureStore store = layer.getFeatureStore(); |
142 |
FeatureType ft = store.getDefaultFeatureTypeQuietly(); |
|
143 |
boolean hasPk = false; |
|
144 |
|
|
145 |
if( !jsonArray.isEmpty() ) { |
|
146 |
JsonObject fjson0 = (JsonObject) jsonArray.get(0); |
|
147 |
for (String name : fjson0.keySet()) { |
|
148 |
FeatureAttributeDescriptor attr = ft.getAttributeDescriptor(name); |
|
149 |
if( attr!=null ) { |
|
150 |
if( attr.isPrimaryKey() ) { |
|
151 |
hasPk = true; |
|
152 |
break; |
|
153 |
} |
|
154 |
} |
|
155 |
} |
|
156 |
} |
|
157 |
final boolean copyPk; |
|
158 |
if( hasPk ) { |
|
159 |
int n = application.confirmDialog( |
|
160 |
i18n.getTranslation("_Copy_primary_key_values_XQuestionX"), |
|
161 |
i18n.getTranslation("_Pasting_features_from_clipboard"), |
|
162 |
JOptionPane.YES_NO_OPTION, |
|
163 |
JOptionPane.QUESTION_MESSAGE, |
|
164 |
"_CopyPrimaryKeyWhenPasteFeaturesFromClipboard" |
|
165 |
); |
|
166 |
copyPk = ( n == JOptionPane.YES_OPTION ); |
|
167 |
} else { |
|
168 |
copyPk = false; |
|
169 |
} |
|
170 |
|
|
171 |
|
|
139 | 172 |
List<EditableFeature> features = new ArrayList<>(); |
140 | 173 |
FilteredLogger theLogger = new FilteredLogger(LOGGER, "PasteFeatures", 10); |
141 | 174 |
for (Object obj : jsonArray) { |
... | ... | |
144 | 177 |
} |
145 | 178 |
JsonObject fjson = (JsonObject) obj; |
146 | 179 |
try { |
147 |
EditableFeature f = store.createNewFeature(fjson); |
|
180 |
EditableFeature f = store.createNewFeature(false); |
|
181 |
f.copyFrom(fjson, new Predicate<FeatureAttributeDescriptor>() { |
|
182 |
@Override |
|
183 |
public boolean test(FeatureAttributeDescriptor attr) { |
|
184 |
if( !copyPk && attr.isPrimaryKey() ) { |
|
185 |
return false; |
|
186 |
} |
|
187 |
return true; |
|
188 |
} |
|
189 |
}); |
|
148 | 190 |
features.add(f); |
149 | 191 |
} catch (Exception ex) { |
150 | 192 |
theLogger.warn("Can't create feature from JSON.", ex); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
1524 | 1524 |
_Active_all_layers_of_group=Active all layers of group |
1525 | 1525 |
_Inactive_all_layers_of_group=Inactive all layers of group |
1526 | 1526 |
_Set_all_layers_of_group_to=Set all layers of group to |
1527 |
_Copy_primary_key_values_XQuestionX=Copy primary key values? |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
1608 | 1608 |
_Active_all_layers_of_group=Activar todas las capas del grupo |
1609 | 1609 |
_Inactive_all_layers_of_group=Desactivar todas las capas del grupo |
1610 | 1610 |
_Set_all_layers_of_group_to=Cambiar todas las capas del grupo a |
1611 |
_Copy_primary_key_values_XQuestionX=\u00bf Copiar los valores de la clave primaria ? |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/java/org/gvsig/selectiontools/app/extension/SelectByBufferExtension.java | ||
---|---|---|
80 | 80 |
if ((layer instanceof FLyrVect) && layer.isAvailable() && layer.isActive()) { |
81 | 81 |
FLyrVect layervect = (FLyrVect) layer; |
82 | 82 |
usefulLayers.add(layervect); |
83 |
try { |
|
84 |
if (layervect.getFeatureStore().getFeatureSelection().isEmpty()) { |
|
85 |
emptySelectionLayers++; |
|
86 |
} |
|
87 |
} catch (DataException e) { |
|
88 |
logger.warn("Error While getting selection for layer '" + layer.getName() + "'.", e); |
|
89 |
application.messageDialog( |
|
90 |
application.translate("Failed_selecting_layer") + ": " + layer.getName(), |
|
91 |
application.translate("Warning"), |
|
92 |
JOptionPane.WARNING_MESSAGE); |
|
83 |
if (layervect.getFeatureStore().isFeatureSelectionEmpty()) { |
|
84 |
emptySelectionLayers++; |
|
93 | 85 |
} |
94 | 86 |
} |
95 | 87 |
} |
... | ... | |
137 | 129 |
layer = layers[i]; |
138 | 130 |
if ((layer instanceof FLyrVect) && layer.isAvailable() && layer.isActive()) { |
139 | 131 |
FLyrVect layervect = (FLyrVect) layer; |
140 |
try { |
|
141 |
if (!layervect.getFeatureStore().getFeatureSelection().isEmpty()) { |
|
142 |
return true; |
|
143 |
} |
|
144 |
} catch (DataException e) { |
|
145 |
logger.warn("Error While getting selection for layer '" + layer.getName() + "'.", e); |
|
132 |
if (!layervect.getFeatureStore().isFeatureSelectionEmpty()) { |
|
133 |
return true; |
|
146 | 134 |
} |
147 | 135 |
} |
148 | 136 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/TableRowsOperations.java | ||
---|---|---|
119 | 119 |
private boolean thereIsSelection(FeatureTableDocumentPanel tabledoc) { |
120 | 120 |
|
121 | 121 |
if (tabledoc != null) { |
122 |
try { |
|
123 |
return !tabledoc.getModel().getStore() |
|
124 |
.getFeatureSelection().isEmpty(); |
|
125 |
} catch (Exception e) { |
|
126 |
logger.warn("Can't check if table has a selecction", e); |
|
127 |
} |
|
122 |
return !tabledoc.getModel().getStore().isFeatureSelectionEmpty(); |
|
128 | 123 |
} |
129 | 124 |
return false; |
130 | 125 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.h2spatial/org.gvsig.h2spatial.h2gis132/org.gvsig.h2spatial.h2gis132.provider/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestFetchFeatureType.java | ||
---|---|---|
62 | 62 |
); |
63 | 63 |
|
64 | 64 |
|
65 |
String retrieveFirstRowOfTableSQL = fetchFeatureType.getSQLToRetrieveFirstRowOfTable();
|
|
65 |
String retrieveMetadataOfTableSQL = fetchFeatureType.getSQLToRetrieveMetadataOfTable();
|
|
66 | 66 |
String retrievePrimaryKeysFromInformationSchemaSQL = fetchFeatureType.getSQLToRetrievePrimaryKeysFromInformationSchema(); |
67 | 67 |
|
68 |
assertEquals("FetchFeatureType first row SQL", expectedSQLs.get(0), retrieveFirstRowOfTableSQL);
|
|
68 |
assertEquals("FetchFeatureType SQL to retrieve metadata", expectedSQLs.get(0), retrieveMetadataOfTableSQL);
|
|
69 | 69 |
assertEquals("FetchFeatureType get primery keys SQL", expectedSQLs.get(1), retrievePrimaryKeysFromInformationSchemaSQL); |
70 | 70 |
} |
71 | 71 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.h2spatial/org.gvsig.h2spatial.h2gis132/org.gvsig.h2spatial.h2gis132.provider/src/test/resources/org/gvsig/fmap/dal/store/h2/fetchFeatureType.sql | ||
---|---|---|
1 | 1 |
|
2 | 2 |
-- FetchFeatureType first row SQL |
3 |
SELECT * FROM "PUBLIC"."test" LIMIT 1;
|
|
3 |
SELECT * FROM "PUBLIC"."test" LIMIT 0;
|
|
4 | 4 |
|
5 | 5 |
-- FetchFeatureType get primery keys SQL |
6 | 6 |
SELECT |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/impl/AbstractVectorialLegend.java | ||
---|---|---|
443 | 443 |
FeatureSet featureSet = null; |
444 | 444 |
try { |
445 | 445 |
taskStatus.message("Retrieve selection"); |
446 |
FeatureSelection selection = featureStore.getFeatureSelection(); |
|
446 |
FeatureSelection selection; |
|
447 |
if( featureStore.isFeatureSelectionEmpty() ) { |
|
448 |
// No hay seleccion, asi que creamos una vacia que consuma pocos recursos. |
|
449 |
selection = featureStore.createMemoryFeatureSelection(); |
|
450 |
} else { |
|
451 |
// Ojo, que esta seleccion puede acabar haciendo un count(*) sobre la tabla. |
|
452 |
selection = featureStore.getFeatureSelection(); |
|
453 |
} |
|
447 | 454 |
|
448 | 455 |
if (featureQuery == null) { |
449 | 456 |
featureQuery = featureStore.createFeatureQuery(); |
Also available in: Unified diff