Search in sources :

Example 6 with OMultiValueChangeEvent

use of com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent in project orientdb by orientechnologies.

the class DocumentTrackingTest method testDocumentEmbeddedMapTrackingAfterSave.

public void testDocumentEmbeddedMapTrackingAfterSave() {
    final ODocument document = new ODocument();
    final Map<String, String> map = new HashMap<String, String>();
    map.put("key1", "value1");
    document.field("embeddedmap", map, OType.EMBEDDEDMAP);
    document.field("val", 1);
    document.save();
    Assert.assertEquals(document.getDirtyFields(), new String[] {});
    Assert.assertFalse(document.isDirty());
    final Map<String, String> trackedMap = document.field("embeddedmap");
    trackedMap.put("key2", "value2");
    Assert.assertTrue(document.isDirty());
    final OMultiValueChangeTimeLine timeLine = document.getCollectionTimeLine("embeddedmap");
    Assert.assertNotNull(timeLine);
    Assert.assertNotNull(timeLine.getMultiValueChangeEvents());
    final List<OMultiValueChangeEvent> firedEvents = new ArrayList<OMultiValueChangeEvent>();
    firedEvents.add(new OMultiValueChangeEvent(OMultiValueChangeEvent.OChangeType.ADD, "key2", "value2"));
    Assert.assertEquals(timeLine.getMultiValueChangeEvents(), firedEvents);
    Assert.assertEquals(document.getDirtyFields(), new String[] { "embeddedmap" });
}
Also used : OMultiValueChangeTimeLine(com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine) OMultiValueChangeEvent(com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 7 with OMultiValueChangeEvent

use of com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent in project orientdb by orientechnologies.

the class DocumentTrackingTest method testDocumentEmbeddedMapTrackingAfterSaveWithClass.

public void testDocumentEmbeddedMapTrackingAfterSaveWithClass() {
    final ODocument document = new ODocument("DocumentTrackingTestClass");
    final Map<String, String> map = new HashMap<String, String>();
    map.put("key1", "value1");
    document.field("embeddedmap", map);
    document.field("val", 1);
    document.save();
    Assert.assertEquals(document.getDirtyFields(), new String[] {});
    Assert.assertFalse(document.isDirty());
    final Map<String, String> trackedMap = document.field("embeddedmap");
    trackedMap.put("key2", "value2");
    Assert.assertTrue(document.isDirty());
    final OMultiValueChangeTimeLine timeLine = document.getCollectionTimeLine("embeddedmap");
    Assert.assertNotNull(timeLine);
    Assert.assertNotNull(timeLine.getMultiValueChangeEvents());
    final List<OMultiValueChangeEvent> firedEvents = new ArrayList<OMultiValueChangeEvent>();
    firedEvents.add(new OMultiValueChangeEvent(OMultiValueChangeEvent.OChangeType.ADD, "key2", "value2"));
    Assert.assertEquals(timeLine.getMultiValueChangeEvents(), firedEvents);
    Assert.assertEquals(document.getDirtyFields(), new String[] { "embeddedmap" });
}
Also used : OMultiValueChangeTimeLine(com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine) OMultiValueChangeEvent(com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 8 with OMultiValueChangeEvent

use of com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent in project orientdb by orientechnologies.

the class DocumentTrackingTest method testDocumentEmbeddedListTrackingAfterSave.

public void testDocumentEmbeddedListTrackingAfterSave() {
    final ODocument document = new ODocument();
    final List<String> list = new ArrayList<String>();
    list.add("value1");
    document.field("embeddedlist", list, OType.EMBEDDEDLIST);
    document.field("val", 1);
    document.save();
    Assert.assertEquals(document.getDirtyFields(), new String[] {});
    Assert.assertFalse(document.isDirty());
    final List<String> trackedList = document.field("embeddedlist");
    trackedList.add("value2");
    Assert.assertTrue(document.isDirty());
    final OMultiValueChangeTimeLine timeLine = document.getCollectionTimeLine("embeddedlist");
    Assert.assertNotNull(timeLine);
    Assert.assertNotNull(timeLine.getMultiValueChangeEvents());
    final List<OMultiValueChangeEvent> firedEvents = new ArrayList<OMultiValueChangeEvent>();
    firedEvents.add(new OMultiValueChangeEvent(OMultiValueChangeEvent.OChangeType.ADD, 1, "value2"));
    Assert.assertEquals(timeLine.getMultiValueChangeEvents(), firedEvents);
    Assert.assertEquals(document.getDirtyFields(), new String[] { "embeddedlist" });
}
Also used : OMultiValueChangeTimeLine(com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine) OMultiValueChangeEvent(com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent) ArrayList(java.util.ArrayList) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 9 with OMultiValueChangeEvent

use of com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent in project orientdb by orientechnologies.

the class DocumentTrackingTest method testDocumentEmbeddedSetTrackingAfterSaveCacheDisabled.

public void testDocumentEmbeddedSetTrackingAfterSaveCacheDisabled() {
    database.getLocalCache().clear();
    final ODocument document = new ODocument();
    final Set<String> set = new HashSet<String>();
    set.add("value1");
    document.field("embeddedset", set, OType.EMBEDDEDSET);
    document.field("val", 1);
    document.save();
    Assert.assertFalse(document.isDirty());
    Assert.assertEquals(document.getDirtyFields(), new String[] {});
    final Set<String> trackedSet = document.field("embeddedset");
    trackedSet.add("value2");
    Assert.assertTrue(document.isDirty());
    final OMultiValueChangeTimeLine timeLine = document.getCollectionTimeLine("embeddedset");
    Assert.assertNotNull(timeLine);
    Assert.assertNotNull(timeLine.getMultiValueChangeEvents());
    final List<OMultiValueChangeEvent> firedEvents = new ArrayList<OMultiValueChangeEvent>();
    firedEvents.add(new OMultiValueChangeEvent(OMultiValueChangeEvent.OChangeType.ADD, "value2", "value2"));
    Assert.assertEquals(timeLine.getMultiValueChangeEvents(), firedEvents);
    Assert.assertEquals(document.getDirtyFields(), new String[] { "embeddedset" });
}
Also used : OMultiValueChangeTimeLine(com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine) OMultiValueChangeEvent(com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent) ArrayList(java.util.ArrayList) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) HashSet(java.util.HashSet)

Example 10 with OMultiValueChangeEvent

use of com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent in project orientdb by orientechnologies.

the class DocumentTrackingTest method testDocumentEmbeddedListTrackingAfterSaveCacheDisabled.

public void testDocumentEmbeddedListTrackingAfterSaveCacheDisabled() {
    database.getLocalCache().clear();
    final ODocument document = new ODocument();
    final List<String> list = new ArrayList<String>();
    list.add("value1");
    document.field("embeddedlist", list, OType.EMBEDDEDLIST);
    document.field("val", 1);
    document.save();
    Assert.assertEquals(document.getDirtyFields(), new String[] {});
    Assert.assertFalse(document.isDirty());
    final List<String> trackedList = document.field("embeddedlist");
    trackedList.add("value2");
    Assert.assertTrue(document.isDirty());
    final OMultiValueChangeTimeLine timeLine = document.getCollectionTimeLine("embeddedlist");
    Assert.assertNotNull(timeLine);
    Assert.assertNotNull(timeLine.getMultiValueChangeEvents());
    final List<OMultiValueChangeEvent> firedEvents = new ArrayList<OMultiValueChangeEvent>();
    firedEvents.add(new OMultiValueChangeEvent(OMultiValueChangeEvent.OChangeType.ADD, 1, "value2"));
    Assert.assertEquals(timeLine.getMultiValueChangeEvents(), firedEvents);
    Assert.assertEquals(document.getDirtyFields(), new String[] { "embeddedlist" });
}
Also used : OMultiValueChangeTimeLine(com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine) OMultiValueChangeEvent(com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent) ArrayList(java.util.ArrayList) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Aggregations

OMultiValueChangeEvent (com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent)21 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)11 OMultiValueChangeTimeLine (com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine)10 ORecordId (com.orientechnologies.orient.core.id.ORecordId)10 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)10 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3