Search in sources :

Example 1 with Label

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;
}
Also used : Label(com.revolsys.util.Label) ArrayList(java.util.ArrayList)

Example 2 with Label

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;
}
Also used : Label(com.revolsys.util.Label) Collection(java.util.Collection) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Example 3 with Label

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;
    }
}
Also used : ArrayList(java.util.ArrayList) Label(com.revolsys.util.Label)

Example 4 with Label

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;
        }
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) Label(com.revolsys.util.Label)

Example 5 with Label

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;
}
Also used : Identifier(com.revolsys.identifier.Identifier) Set(java.util.Set) HashSet(java.util.HashSet) Label(com.revolsys.util.Label)

Aggregations

Label (com.revolsys.util.Label)5 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 Identifier (com.revolsys.identifier.Identifier)1 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1