Search in sources :

Example 36 with LayerRecord

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

the class RecordStoreLayerTest method testModifiyRecordDeleteCancelChanges.

@Test
public void testModifiyRecordDeleteCancelChanges() {
    final LayerRecord testRecord = testNewRecord();
    this.layer.saveChanges();
    assertRecordCounts(0, 1, 0, 0);
    testRecord.setValue("NAME", CHANGED_NAME);
    assertRecordState(testRecord, RecordState.MODIFIED);
    // Delete the record and verify that it's deleted
    this.layer.deleteRecord(testRecord);
    assertRecordCounts(0, 1, 0, 1);
    assertGetRecords(0);
    assertRecordState(testRecord, RecordState.DELETED);
    assertRecordValue(testRecord, "NAME", DEFAULT_NAME);
    // Cancel the changes and verify that it hasn't been deleted.
    this.layer.cancelChanges();
    assertRecordCounts(0, 1, 0, 0);
    final List<LayerRecord> records = assertGetRecords(1);
    final LayerRecord actualRecord = assertRecordAtIndex(1, records, 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 37 with LayerRecord

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

the class RecordStoreLayerTest method newTestRecord.

public LayerRecord newTestRecord(final String name, final int count, final Point point) {
    final Map<String, Object> newValues = Maps.<String, Object>buildLinkedHash().add("NAME", name).add("COUNT", count).add("GEOMETRY", point);
    final LayerRecord testRecord = this.layer.newLayerRecord(newValues);
    return testRecord;
}
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)

Example 38 with LayerRecord

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

the class RecordStoreLayerTest method testDeleteRecordSaveChanges.

@Test
public void testDeleteRecordSaveChanges() {
    final LayerRecord testRecord = testNewRecord();
    this.layer.saveChanges();
    assertRecordCounts(0, 1, 0, 0);
    // Delete the record and verify that it's deleted
    this.layer.deleteRecord(testRecord);
    assertRecordCounts(0, 1, 0, 1);
    assertGetRecords(0);
    assertRecordState(testRecord, RecordState.DELETED);
    // Cancel the changes and verify that it hasn't been deleted.
    this.layer.saveChanges();
    assertRecordCounts(0, 0, 0, 0);
    assertGetRecords(0);
    assertRecordState(testRecord, RecordState.DELETED);
}
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 39 with LayerRecord

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

the class RecordStoreLayerTest method testDeleteRecordCancelChanges.

@Test
public void testDeleteRecordCancelChanges() {
    final LayerRecord testRecord = testNewRecord();
    this.layer.saveChanges();
    assertRecordCounts(0, 1, 0, 0);
    // Delete the record and verify that it's deleted
    this.layer.deleteRecord(testRecord);
    assertRecordCounts(0, 1, 0, 1);
    assertGetRecords(0);
    assertRecordState(testRecord, RecordState.DELETED);
    // Cancel the changes and verify that it hasn't been deleted.
    this.layer.cancelChanges();
    assertRecordCounts(0, 1, 0, 0);
    final List<LayerRecord> records = assertGetRecords(1);
    final LayerRecord actualRecord = assertRecordAtIndex(1, records, 0, testRecord, IdentifierProxyLayerRecord.class);
    assertRecordState(testRecord, RecordState.PERSISTED);
    assertRecordState(actualRecord, RecordState.PERSISTED);
}
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 40 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, final Class<?> expectedClass) {
    final LayerRecord actualRecord = assertRecordAtIndex(count, records, index, expectedRecord);
    Assert.assertEquals("Class", expectedClass, actualRecord.getClass());
    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