use of com.revolsys.util.Label in project com.revolsys.open by revolsys.
the class AbstractRecordLayer method removeRecordFromCache.
protected boolean removeRecordFromCache(LayerRecord record) {
boolean removed = false;
record = getProxiedRecord(record);
synchronized (getSync()) {
if (isLayerRecord(record)) {
for (final Label cacheId : new ArrayList<>(this.recordsByCacheId.keySet())) {
removed |= removeRecordFromCache(cacheId, record);
}
}
}
return removed;
}
use of com.revolsys.util.Label in project com.revolsys.open by revolsys.
the class AbstractRecordLayer method getCacheIdsDo.
protected Set<Label> getCacheIdsDo(final LayerRecord record) {
final Set<Label> cacheIds = new HashSet<>();
for (final Entry<Label, Collection<LayerRecord>> entry : this.recordsByCacheId.entrySet()) {
final Collection<LayerRecord> records = entry.getValue();
if (records.contains(record)) {
final Label cacheId = entry.getKey();
cacheIds.add(cacheId);
}
}
return cacheIds;
}
use of com.revolsys.util.Label in project com.revolsys.open by revolsys.
the class AbstractRecordLayer method saveChanges.
@Override
public boolean saveChanges() {
if (isExists()) {
final List<LayerRecord> allRecords = new ArrayList<>();
for (final Label cacheId : Arrays.asList(this.cacheIdDeleted, this.cacheIdModified, this.cacheIdNew)) {
final List<LayerRecord> records = getRecordsCached(cacheId);
allRecords.addAll(records);
}
return saveChanges(allRecords);
} else {
return false;
}
}
use of com.revolsys.util.Label in project com.revolsys.open by revolsys.
the class AbstractRecordLayer method setIndexRecords.
protected void setIndexRecords(final List<LayerRecord> records) {
synchronized (getSync()) {
if (hasGeometryField()) {
final GeometryFactory geometryFactory = getGeometryFactory();
final LayerRecordQuadTree index = new LayerRecordQuadTree(geometryFactory);
final Label cacheIdIndex = getCacheIdIndex();
clearCachedRecords(cacheIdIndex);
if (records != null) {
for (final LayerRecord record : records) {
if (record.hasGeometry()) {
addRecordToCache(cacheIdIndex, record);
index.addRecord(record.newRecordProxy());
}
}
}
cleanCachedRecords();
final List<LayerRecord> newRecords = getRecordsNew();
index.addRecords(newRecords);
this.index = index;
}
}
}
use of com.revolsys.util.Label in project com.revolsys.open by revolsys.
the class RecordStoreLayer method getCacheIdsDo.
@Override
protected Set<Label> getCacheIdsDo(final LayerRecord record) {
final Set<Label> cacheIds = super.getCacheIdsDo(record);
final Identifier identifier = record.getIdentifier();
if (identifier != null) {
for (final Entry<Label, Set<Identifier>> entry : this.recordIdentifiersByCacheId.entrySet()) {
final Label cacheId = entry.getKey();
if (!cacheIds.contains(cacheId)) {
final Collection<Identifier> identifiers = entry.getValue();
if (identifiers.contains(identifier)) {
cacheIds.add(cacheId);
}
}
}
}
return cacheIds;
}
Aggregations