Search in sources :

Example 6 with OMultiValueChangeTimeLine

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

the class DocumentTrackingTest method testDocumentLinkListTrackingAfterSaveCacheDisabled.

public void testDocumentLinkListTrackingAfterSaveCacheDisabled() {
    database.getLocalCache().clear();
    final ODocument docOne = new ODocument();
    docOne.save();
    final ODocument docTwo = new ODocument();
    docTwo.save();
    final ODocument document = new ODocument();
    final List<ORID> list = new ArrayList<ORID>();
    list.add(docOne.getIdentity());
    document.field("linklist", list, OType.LINKLIST);
    document.field("val", 1);
    document.save();
    Assert.assertFalse(document.isDirty());
    Assert.assertEquals(document.getDirtyFields(), new String[] {});
    final List<ORID> trackedList = document.field("linklist");
    trackedList.add(docTwo.getIdentity());
    Assert.assertTrue(document.isDirty());
    final OMultiValueChangeTimeLine timeLine = document.getCollectionTimeLine("linklist");
    Assert.assertNotNull(timeLine);
    Assert.assertEquals(document.getDirtyFields(), new String[] { "linklist" });
}
Also used : OMultiValueChangeTimeLine(com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine) ArrayList(java.util.ArrayList) ORID(com.orientechnologies.orient.core.id.ORID) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 7 with OMultiValueChangeTimeLine

use of com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine 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 8 with OMultiValueChangeTimeLine

use of com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine 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 9 with OMultiValueChangeTimeLine

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

the class DocumentTrackingTest method testDocumentLinkSetTrackingAfterSave.

public void testDocumentLinkSetTrackingAfterSave() {
    final ODocument docOne = new ODocument();
    docOne.save();
    final ODocument docTwo = new ODocument();
    docTwo.save();
    final ODocument document = new ODocument();
    final Set<ORID> set = new HashSet<ORID>();
    set.add(docOne.getIdentity());
    document.field("linkset", set, OType.LINKSET);
    document.field("val", 1);
    document.save();
    Assert.assertFalse(document.isDirty());
    Assert.assertEquals(document.getDirtyFields(), new String[] {});
    final Set<ORID> trackedSet = document.field("linkset");
    trackedSet.add(docTwo.getIdentity());
    Assert.assertTrue(document.isDirty());
    final OMultiValueChangeTimeLine timeLine = document.getCollectionTimeLine("linkset");
    Assert.assertNotNull(timeLine);
    Assert.assertEquals(document.getDirtyFields(), new String[] { "linkset" });
}
Also used : OMultiValueChangeTimeLine(com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine) ORID(com.orientechnologies.orient.core.id.ORID) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) HashSet(java.util.HashSet)

Example 10 with OMultiValueChangeTimeLine

use of com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine 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

OMultiValueChangeTimeLine (com.orientechnologies.orient.core.db.record.OMultiValueChangeTimeLine)22 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)22 ArrayList (java.util.ArrayList)14 OMultiValueChangeEvent (com.orientechnologies.orient.core.db.record.OMultiValueChangeEvent)10 ORID (com.orientechnologies.orient.core.id.ORID)9 HashMap (java.util.HashMap)7 HashSet (java.util.HashSet)7 OTrackedList (com.orientechnologies.orient.core.db.record.OTrackedList)1 OTrackedMap (com.orientechnologies.orient.core.db.record.OTrackedMap)1 OTrackedSet (com.orientechnologies.orient.core.db.record.OTrackedSet)1