Search in sources :

Example 21 with ValueStore

use of org.eclipse.persistence.sdo.ValueStore in project eclipselink by eclipse-ee4j.

the class ChangeSummaryXSDWithCSonRootUndoTestCases method testSetItemsAfterDeleteAndUndo_MultiOperation_SetComplexSingleWithManyChildBelowRootAndUndo.

public void testSetItemsAfterDeleteAndUndo_MultiOperation_SetComplexSingleWithManyChildBelowRootAndUndo() {
    // get items property - to speed debugging
    Property itemsProperty = rootObject.getInstanceProperty("items");
    // save objects before deletion
    DataObject itemsDO = rootObject.getDataObject("items");
    DataObject item1DO = rootObject.getDataObject("items/item[1]");
    DataObject item2DO = rootObject.getDataObject("items/item[2]");
    DataObject item1ProductDO = item1DO.getDataObject("product");
    DataObject item1ProductPrice1DO = item1ProductDO.getDataObject("price[1]");
    DataObject item1ProductPrice2DO = item1ProductDO.getDataObject("price[2]");
    DataObject item2ProductDO = item2DO.getDataObject("product");
    DataObject item2ProductPrice1DO = item2ProductDO.getDataObject("price[1]");
    DataObject item2ProductPrice2DO = item2ProductDO.getDataObject("price[2]");
    // take the full DataObject and remove the complex single that we would like to set
    DataObject itemsDOtoSet = rootObject.getDataObject(itemsProperty);
    // verify logging is off
    assertFalse(cs.isLogging());
    // rootObject.unset(itemsProperty); //unset is not clearing the cs when logging is off
    itemsDOtoSet.delete();
    // verify CS is null on removed trees
    assertChangeSummaryStatusIfClearedIfCSIsAncestor(itemsDOtoSet, true);
    // verify that items is not set
    assertNull(rootObject.getDataObject(itemsProperty));
    assertFalse(rootObject.isSet(itemsProperty));
    // save original root for later comparison after undo
    DataObject originalRootDO = copyHelper.copy(rootObject);
    assertTrue(equalityHelper.equal(rootObject, originalRootDO));
    assertNull(rootObject.getDataObject(itemsProperty));
    assertNull(rootObject.getDataObject("items/item[1]"));
    assertNull(rootObject.getDataObject("items/item[2]"));
    cs.beginLogging();
    // verify original VS is null and save a copy of current VS for object identity testing after undo
    assertValueStoresInitializedAfterLoggingOn(rootObject);
    // save a copy of current VS for object identity testing after undo
    ValueStore aCurrentValueStoreAfterLoggingFirstOn = ((SDODataObject) rootObject)._getCurrentValueStore();
    // set the items back  (in effect doing an undo)
    rootObject.set(itemsProperty, itemsDOtoSet);
    // check valueStores
    assertValueStoresCopiedAndSwappedAfterFirstModifyOperation(rootObject, aCurrentValueStoreAfterLoggingFirstOn);
    verifySetItemsAfterDetachUnsetOrDeleteAndUndo_MultiOperation_SetComplexSingleWithManyChildBelowRootAndUndo(// 
    rootObject.getDataObject(itemsProperty), // 
    item1DO, // 
    item2DO, // 
    item1ProductDO, // 
    item1ProductPrice1DO, // 
    item1ProductPrice2DO, // 
    item2ProductDO, // 
    item2ProductPrice1DO, // 
    item2ProductPrice2DO, // 
    itemsProperty, // 
    originalRootDO, // 
    itemsDOtoSet, aCurrentValueStoreAfterLoggingFirstOn, true);
}
Also used : DataObject(commonj.sdo.DataObject) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) ValueStore(org.eclipse.persistence.sdo.ValueStore) Property(commonj.sdo.Property) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 22 with ValueStore

use of org.eclipse.persistence.sdo.ValueStore in project eclipselink by eclipse-ee4j.

the class ChangeSummaryXSDWithCSonRootUndoTestCases method testDeleteChainBottomToRoot_ItemsItem2ProductPrice2_MultiOperation_DeleteComplexManyOfComplexSingleOfComplexManyOfComplexSingleInSequence.

public void testDeleteChainBottomToRoot_ItemsItem2ProductPrice2_MultiOperation_DeleteComplexManyOfComplexSingleOfComplexManyOfComplexSingleInSequence() {
    // save original root for later comparison after undo
    DataObject originalRootDO = copyHelper.copy(rootObject);
    assertTrue(equalityHelper.equal(rootObject, originalRootDO));
    DataObject itemsDO = rootObject.getDataObject("items");
    DataObject item1DO = rootObject.getDataObject("items/item[1]");
    DataObject item2DO = rootObject.getDataObject("items/item[2]");
    DataObject item1ProductDO = item1DO.getDataObject("product");
    DataObject item1ProductPrice1DO = item1ProductDO.getDataObject("price[1]");
    DataObject item1ProductPrice2DO = item1ProductDO.getDataObject("price[2]");
    DataObject item2ProductDO = item2DO.getDataObject("product");
    DataObject item2ProductPrice1DO = item2ProductDO.getDataObject("price[1]");
    DataObject item2ProductPrice2DO = item2ProductDO.getDataObject("price[2]");
    cs.beginLogging();
    // verify original VS is null and save a copy of current VS for object identity testing after undo
    assertValueStoresInitializedAfterLoggingOn(rootObject);
    // save a copy of current VS for object identity testing after undo
    ValueStore aCurrentValueStoreAfterLoggingFirstOn = ((SDODataObject) rootObject)._getCurrentValueStore();
    assertNotNull(itemsDO.getChangeSummary());
    // start deleting at the bottom of the tree and move up
    item2ProductPrice2DO.delete();
    // ListWrapper.clear() will call copyElements() twice for this parent of many
    item2ProductDO.delete();
    item2DO.delete();
    // ListWrapper.clear() will call copyElements() twice for this parent of many
    itemsDO.delete();
    boolean wasDeleted = true;
    // verify CS is null on removed trees
    assertChangeSummaryStatusIfClearedIfCSIsAncestor(itemsDO, true);
    // check valueStores
    assertValueStoresCopiedAndSwappedAfterFirstModifyOperation(rootObject, aCurrentValueStoreAfterLoggingFirstOn);
    assertNotNull(item1DO);
    assertNotNull(item2DO);
    assertModified(rootObject, cs);
    assertDeleted(itemsDO, cs, wasDeleted);
    assertDeleted(item1DO, cs, wasDeleted);
    assertDeleted(item2DO, cs, wasDeleted);
    assertDeleted(item1ProductDO, cs, wasDeleted);
    assertDeleted(item1ProductPrice1DO, cs, wasDeleted);
    assertDeleted(item1ProductPrice2DO, cs, wasDeleted);
    assertDeleted(item2ProductDO, cs, wasDeleted);
    assertDeleted(item2ProductPrice1DO, cs, wasDeleted);
    assertDeleted(item2ProductPrice2DO, cs, wasDeleted);
    assertEquals(10, cs.getChangedDataObjects().size());
    // from 9
    assertEquals(14, ((SDOChangeSummary) cs).getOldContainer().size());
    // from 9
    assertEquals(14, ((SDOChangeSummary) cs).getOldContainmentProperty().size());
    assertUndoChangesEqualToOriginal(cs, rootObject, originalRootDO);
    // verify that property is reset
    assertTrue(rootObject.isSet("items"));
    // get back items object
    DataObject itemsDOundone = rootObject.getDataObject("items");
    // compare with original
    assertTrue(equalityHelper.equal(itemsDOundone, itemsDO));
    assertValueStoresReturnedToStartStateAfterUndoChanges(rootObject, aCurrentValueStoreAfterLoggingFirstOn);
}
Also used : DataObject(commonj.sdo.DataObject) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) ValueStore(org.eclipse.persistence.sdo.ValueStore) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Aggregations

SDODataObject (org.eclipse.persistence.sdo.SDODataObject)22 ValueStore (org.eclipse.persistence.sdo.ValueStore)22 DataObject (commonj.sdo.DataObject)17 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)17 Property (commonj.sdo.Property)3 DefaultValueStore (org.eclipse.persistence.sdo.DefaultValueStore)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)1 SDOSequence (org.eclipse.persistence.sdo.SDOSequence)1