Search in sources :

Example 31 with LayerRecord

use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.

the class ModeAllPaged method getRecordsForCache.

@Override
protected List<LayerRecord> getRecordsForCache() {
    final AbstractRecordLayer layer = getLayer();
    final List<LayerRecord> records = layer.getRecordsNew();
    final Condition filter = getFilter();
    if (!filter.isEmpty()) {
        Predicates.retain(records, filter);
        for (final LayerRecord modifiedRecord : layer.getRecordsModified()) {
            if (filterTestModified(filter, modifiedRecord)) {
                records.add(modifiedRecord);
            }
        }
    }
    final RecordLayerTableModel model = getTableModel();
    final Comparator<Record> comparator = model.getOrderByComparatorIdentifier();
    if (comparator != null) {
        records.sort(comparator);
    }
    return records;
}
Also used : Condition(com.revolsys.record.query.Condition) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) Record(com.revolsys.record.Record) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 32 with LayerRecord

use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.

the class ModeAllPaged method getRecordPagePersisted.

protected LayerRecord getRecordPagePersisted(final int pageNumber, final int recordIndex) {
    synchronized (this) {
        final List<LayerRecord> page = this.pageCache.get(pageNumber);
        if (page == null) {
            boolean load = false;
            synchronized (this.loadingPageNumbers) {
                if (!this.loadingPageNumbers.contains(pageNumber)) {
                    this.loadingPageNumbers.add(pageNumber);
                    load = true;
                }
            }
            if (load) {
                final long refreshIndex = getRefreshIndex();
                Invoke.background("loadPage" + getTypeName(), 2, "Loading records " + getTypeName(), // 
                () -> loadPage(pageNumber), (records) -> {
                    setRecords(refreshIndex, pageNumber, records);
                });
            }
        } else {
            if (recordIndex < page.size()) {
                final LayerRecord record = page.get(recordIndex);
                return record;
            }
        }
    }
    return null;
}
Also used : LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 33 with LayerRecord

use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.

the class RecordStoreLayerTest method testModifiyRecordCancelChanges.

@Test
public void testModifiyRecordCancelChanges() {
    final LayerRecord testRecord = testNewRecord();
    this.layer.saveChanges();
    assertRecordCounts(0, 1, 0, 0);
    testRecord.setValue("NAME", CHANGED_NAME);
    assertRecordState(testRecord, RecordState.MODIFIED);
    assertRecordCounts(0, 1, 1, 0);
    final List<LayerRecord> records1 = assertGetRecords(1);
    assertRecordAtIndex(1, records1, 0, testRecord, IdentifierProxyLayerRecord.class);
    // Save the record and verify that it's modified
    this.layer.cancelChanges();
    assertRecordCounts(0, 1, 0, 0);
    final List<LayerRecord> records2 = assertGetRecords(1);
    final LayerRecord actualRecord = assertRecordAtIndex(1, records2, 0, testRecord, IdentifierProxyLayerRecord.class);
    assertRecordState(testRecord, RecordState.PERSISTED);
    assertRecordState(actualRecord, RecordState.PERSISTED);
    assertRecordValue(testRecord, "NAME", DEFAULT_NAME);
    assertRecordValue(actualRecord, "NAME", DEFAULT_NAME);
}
Also used : NewProxyLayerRecord(com.revolsys.swing.map.layer.record.NewProxyLayerRecord) IdentifierProxyLayerRecord(com.revolsys.swing.map.layer.record.IdentifierProxyLayerRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) Test(org.junit.Test)

Example 34 with LayerRecord

use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.

the class RecordStoreLayerTest method testNewRecordChangeValues.

@Test
public void testNewRecordChangeValues() {
    final LayerRecord testRecord = testNewRecord();
    testRecord.setValue("NAME", CHANGED_NAME);
    final List<LayerRecord> records2 = assertGetRecords(1);
    final LayerRecord actualRecord = assertRecordAtIndex(1, records2, 0, testRecord);
    assertRecordCounts(1, 0, 0, 0);
    assertRecordState(testRecord, RecordState.NEW);
    assertRecordState(actualRecord, RecordState.NEW);
    Assert.assertTrue("Has Changes", this.layer.isHasChanges());
}
Also used : NewProxyLayerRecord(com.revolsys.swing.map.layer.record.NewProxyLayerRecord) IdentifierProxyLayerRecord(com.revolsys.swing.map.layer.record.IdentifierProxyLayerRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) Test(org.junit.Test)

Example 35 with LayerRecord

use of com.revolsys.swing.map.layer.record.LayerRecord in project com.revolsys.open by revolsys.

the class RecordStoreLayerTest method assertRecordAtIndex.

public LayerRecord assertRecordAtIndex(final int count, final List<LayerRecord> records, final int index, final LayerRecord expectedRecord) {
    Assert.assertEquals("queryCount", count, records.size());
    final LayerRecord actualRecord = records.get(index);
    final boolean same1 = expectedRecord.isSame(actualRecord);
    Assert.assertTrue("record same", same1);
    final boolean same2 = actualRecord.isSame(expectedRecord);
    Assert.assertTrue("record same", same2);
    return actualRecord;
}
Also used : NewProxyLayerRecord(com.revolsys.swing.map.layer.record.NewProxyLayerRecord) IdentifierProxyLayerRecord(com.revolsys.swing.map.layer.record.IdentifierProxyLayerRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Aggregations

LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)79 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)34 Geometry (com.revolsys.geometry.model.Geometry)15 IdentifierProxyLayerRecord (com.revolsys.swing.map.layer.record.IdentifierProxyLayerRecord)15 NewProxyLayerRecord (com.revolsys.swing.map.layer.record.NewProxyLayerRecord)15 BoundingBox (com.revolsys.geometry.model.BoundingBox)11 Record (com.revolsys.record.Record)11 ArrayList (java.util.ArrayList)11 List (java.util.List)10 Test (org.junit.Test)10 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 Point (com.revolsys.geometry.model.Point)6 Condition (com.revolsys.record.query.Condition)4 LayerRecordMenu (com.revolsys.swing.map.layer.record.LayerRecordMenu)4 CloseLocation (com.revolsys.swing.map.overlay.CloseLocation)4 RecordRowTable (com.revolsys.swing.table.record.RecordRowTable)4 LineString (com.revolsys.geometry.model.LineString)3 RecordDefinition (com.revolsys.record.schema.RecordDefinition)3 AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)3 Layer (com.revolsys.swing.map.layer.Layer)3