Revision 9512 org.gvsig.online/trunk/org.gvsig.online/org.gvsig.online.lib/org.gvsig.online.lib.impl/src/main/java/org/gvsig/online/lib/impl/workspace/tables/RemoteChangesTable.java
RemoteChangesTable.java | ||
---|---|---|
11 | 11 |
import org.gvsig.fmap.dal.DALLocator; |
12 | 12 |
import org.gvsig.fmap.dal.DataManager; |
13 | 13 |
import static org.gvsig.fmap.dal.DataManager.RECOMENDED_SIZE_FOR_CLOB; |
14 |
import org.gvsig.fmap.dal.DataTransaction; |
|
14 | 15 |
import org.gvsig.fmap.dal.feature.DisposableFeatureSetIterable; |
15 | 16 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
16 | 17 |
import org.gvsig.fmap.dal.feature.Feature; |
17 | 18 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
18 | 19 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
19 | 20 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
21 |
import static org.gvsig.fmap.dal.feature.FeatureStore.MODE_PASS_THROUGH; |
|
20 | 22 |
import org.gvsig.fmap.dal.feature.FeatureType; |
21 | 23 |
import org.gvsig.fmap.geom.Geometry; |
22 | 24 |
import org.gvsig.fmap.geom.GeometryLocator; |
23 | 25 |
import org.gvsig.fmap.geom.GeometryManager; |
24 | 26 |
import org.gvsig.json.Json; |
25 |
import org.gvsig.online.lib.api.workingcopy.OnlineEntity; |
|
26 | 27 |
import static org.gvsig.online.lib.api.OnlineManager.ONLINECODELEN; |
27 | 28 |
import static org.gvsig.online.lib.api.OnlineManager.OP_DELETE; |
28 | 29 |
import static org.gvsig.online.lib.api.OnlineManager.OP_INSERT; |
... | ... | |
30 | 31 |
import static org.gvsig.online.lib.api.OnlineManager.STATE_CONFLICT; |
31 | 32 |
import static org.gvsig.online.lib.api.OnlineManager.STATE_LOCAL_MODIFIED; |
32 | 33 |
import static org.gvsig.online.lib.api.OnlineManager.STATE_LOCAL_UNMODIFIED; |
34 |
import org.gvsig.online.lib.api.workingcopy.OnlineEntity; |
|
33 | 35 |
import org.gvsig.online.lib.api.workingcopy.OnlineRemoteChange; |
36 |
import org.gvsig.online.lib.api.workingcopy.OnlineWorkingcopy; |
|
34 | 37 |
import org.gvsig.online.lib.impl.OnlineUtils; |
35 | 38 |
import org.gvsig.tools.dataTypes.DataTypes; |
36 | 39 |
import org.gvsig.tools.dispose.DisposeUtils; |
37 | 40 |
import org.gvsig.tools.dynobject.DynObjectValueItem; |
38 | 41 |
import org.gvsig.tools.util.GetItemWithSize64; |
39 |
import org.gvsig.online.lib.api.workingcopy.OnlineWorkingcopy; |
|
40 | 42 |
|
41 | 43 |
/** |
42 | 44 |
* |
... | ... | |
78 | 80 |
|
79 | 81 |
@Override |
80 | 82 |
public long getRelatedFeatureCode() { |
83 |
if( this.isNull(FEATUREID)){ |
|
84 |
return 0l; |
|
85 |
} |
|
81 | 86 |
return this.getLong(FEATUREID); |
82 | 87 |
} |
83 | 88 |
|
... | ... | |
162 | 167 |
this.set(REVISION_DATE, date); |
163 | 168 |
} |
164 | 169 |
|
165 |
public void setDataCode(String code) {
|
|
170 |
public void setRelatedFeatureCode(long code) {
|
|
166 | 171 |
this.set(FEATUREID, code); |
167 | 172 |
} |
168 | 173 |
|
... | ... | |
272 | 277 |
} |
273 | 278 |
|
274 | 279 |
public void delete(FeatureStore store, String entityCode) { |
275 |
store.delete("\""+COD_ENTITY+"\"='"+entityCode+"'"); |
|
280 |
|
|
281 |
try { |
|
282 |
boolean needFinish = false; |
|
283 |
if(store.getMode() == FeatureStore.MODE_QUERY){ |
|
284 |
store.edit(MODE_PASS_THROUGH); |
|
285 |
needFinish = true; |
|
286 |
} |
|
287 |
store.delete("\""+COD_ENTITY+"\"='"+entityCode+"'"); |
|
288 |
if(needFinish) { |
|
289 |
store.finishEditing(); |
|
290 |
} |
|
291 |
} catch (Exception ex) { |
|
292 |
throw new RuntimeException("Can't delete changes.", ex); |
|
293 |
} |
|
294 |
|
|
276 | 295 |
} |
277 | 296 |
|
278 | 297 |
public void deleteSelecteds(OnlineWorkingcopy workspace) { |
... | ... | |
289 | 308 |
public DisposableFeatureSetIterable getByEntityCodeAsIterator(OnlineWorkingcopy workspace, String entityCode) { |
290 | 309 |
FeatureStore store = null; |
291 | 310 |
try { |
292 |
store = workspace.getFeatureStore(TABLE_NAME);
|
|
311 |
store = workspace.openFeatureStore(TABLE_NAME, true);
|
|
293 | 312 |
FeatureSet changes; |
294 | 313 |
if( StringUtils.isBlank(entityCode) ) { |
295 | 314 |
changes = store.getFeatureSet(); |
... | ... | |
308 | 327 |
public DisposableFeatureSetIterable getSelectedsByEntityCodeAsIterator(OnlineWorkingcopy workspace, String entityCode) { |
309 | 328 |
FeatureStore store = null; |
310 | 329 |
try { |
311 |
store = workspace.getFeatureStore(TABLE_NAME);
|
|
330 |
store = workspace.openFeatureStore(TABLE_NAME, true);
|
|
312 | 331 |
FeatureSet changes; |
313 | 332 |
if( StringUtils.isBlank(entityCode) ) { |
314 | 333 |
changes = store.getFeatureSet("\""+SELECTED+"\""); |
... | ... | |
326 | 345 |
public DisposableFeatureSetIterable getNotSelectedsByEntityCodeAsIterator(OnlineWorkingcopy workspace, String entityCode) { |
327 | 346 |
FeatureStore store = null; |
328 | 347 |
try { |
329 |
store = workspace.getFeatureStore(TABLE_NAME);
|
|
348 |
store = workspace.openFeatureStore(TABLE_NAME, true);
|
|
330 | 349 |
FeatureSet changes; |
331 | 350 |
if( StringUtils.isBlank(entityCode) ) { |
332 | 351 |
changes = store.getFeatureSet("NOT \""+SELECTED+"\""); |
... | ... | |
345 | 364 |
FeatureStore store = null; |
346 | 365 |
try { |
347 | 366 |
GetItemWithSize64<Feature> changes; |
348 |
store = workspace.getFeatureStore(TABLE_NAME);
|
|
367 |
store = workspace.openFeatureStore(TABLE_NAME, true);
|
|
349 | 368 |
FeatureQuery query = store.createFeatureQuery(); |
350 | 369 |
query.getOrder().add(REVISION_NUMBER, true); |
351 | 370 |
if( ArrayUtils.isNotEmpty(entityCodes) ) { |
... | ... | |
378 | 397 |
public GetItemWithSize64<Feature> getByEntityCodes(OnlineWorkingcopy workspace, List<String> entityCodes) { |
379 | 398 |
FeatureStore store = null; |
380 | 399 |
try { |
381 |
store = workspace.getFeatureStore(TABLE_NAME);
|
|
400 |
store = workspace.openFeatureStore(TABLE_NAME, true);
|
|
382 | 401 |
|
383 |
|
|
384 | 402 |
GetItemWithSize64<Feature> changes; |
385 | 403 |
if( entityCodes == null || entityCodes.isEmpty()) { |
386 | 404 |
changes = store.getFeatures64(); |
... | ... | |
455 | 473 |
public DisposableFeatureSetIterable getGroupedByEntity(OnlineWorkingcopy workspace) { |
456 | 474 |
FeatureStore store = null; |
457 | 475 |
try { |
458 |
store = workspace.getFeatureStore(TABLE_NAME);
|
|
476 |
store = workspace.openFeatureStore(TABLE_NAME, true);
|
|
459 | 477 |
FeatureQuery query = store.createFeatureQuery(); |
460 | 478 |
|
461 | 479 |
query.getOrder().add(COD_ENTITY,true); |
... | ... | |
493 | 511 |
|
494 | 512 |
return true; |
495 | 513 |
} |
514 |
|
|
515 |
public long getCountRemoteChangesOfEntity(OnlineWorkingcopy workspace, DataTransaction transaction, String entityCode) { |
|
516 |
FeatureStore store = null; |
|
517 |
FeatureSet changes = null; |
|
518 |
try { |
|
519 |
if( transaction==null ) { |
|
520 |
store = workspace.getFeatureStore(TABLE_NAME); |
|
521 |
} else { |
|
522 |
store = transaction.getFeatureStore(TABLE_NAME); |
|
523 |
if( store == null ) { |
|
524 |
store = workspace.getFeatureStore(TABLE_NAME); |
|
525 |
} else { |
|
526 |
DisposeUtils.bind(store); |
|
527 |
} |
|
528 |
} |
|
529 |
if( StringUtils.isBlank(entityCode) ) { |
|
530 |
throw new IllegalArgumentException("entityCode is required."); |
|
531 |
} |
|
532 |
changes = store.getFeatureSet( |
|
533 |
"\""+COD_ENTITY+"\"='"+entityCode+"'" |
|
534 |
); |
|
535 |
return changes.size64(); |
|
536 |
} catch (Exception ex) { |
|
537 |
throw new RuntimeException("Can't retrieve changes by entity.", ex); |
|
538 |
} finally { |
|
539 |
DisposeUtils.disposeQuietly(changes); |
|
540 |
DisposeUtils.disposeQuietly(store); |
|
541 |
} |
|
542 |
} |
|
543 |
|
|
496 | 544 |
} |
Also available in: Unified diff