Search in sources :

Example 6 with ValueStore

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

the class ChangeSummaryUndoChangeTest method testUndoDetachComplexAtRoot.

public void testUndoDetachComplexAtRoot() {
    SDODataObject original = (SDODataObject) copyHelper.copy(root);
    // logging
    changeSummary.beginLogging();
    // verify original VS is null and save a copy of current VS for object identity testing after undo
    ValueStore aCurrentValueStore = root._getCurrentValueStore();
    assertNotNull(aCurrentValueStore);
    ValueStore anOriginalValueStore = (ValueStore) changeSummary.getOriginalValueStores().get(root);
    assertNull(anOriginalValueStore);
    // save original child
    SDODataObject aChild = (SDODataObject) root.get("property-Containment");
    assertNotNull(aChild.getChangeSummary());
    // operation on complex child of root
    aChild.detach();
    // verify CS is null on removed trees
    assertChangeSummaryStatusIfClearedIfCSIsAncestor(aChild, true);
    assertNotNull(aCurrentValueStore);
    ValueStore anOriginalValueStoreAfterOperation = (ValueStore) changeSummary.getOriginalValueStores().get(root);
    ValueStore aCurrentValueStoreAfterOperation = root._getCurrentValueStore();
    assertNotNull(anOriginalValueStoreAfterOperation);
    assertNotNull(aCurrentValueStoreAfterOperation);
    assertTrue(anOriginalValueStoreAfterOperation == aCurrentValueStore);
    assertFalse(root.isSet(rootProperty));
    // make sure it is changed
    assertNull(containedDataObject.getContainer());
    // undo and verify equality
    assertUndoChangesEqualToOriginal(changeSummary, root, original);
    // verify that property is reset
    assertTrue(root.isSet(rootProperty));
    // we have object identity
    assertTrue(equalityHelper.equal(original, root));
    ValueStore anOriginalValueStoreAfterUndo = (ValueStore) changeSummary.getOriginalValueStores().get(root);
    ValueStore aCurrentValueStoreAfterUndo = root._getCurrentValueStore();
    assertNull(anOriginalValueStoreAfterUndo);
    assertNotNull(aCurrentValueStoreAfterUndo);
    // we return the original value store back to the current VS
    assertTrue(aCurrentValueStoreAfterUndo == aCurrentValueStore);
}
Also used : DefaultValueStore(org.eclipse.persistence.sdo.DefaultValueStore) ValueStore(org.eclipse.persistence.sdo.ValueStore) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 7 with ValueStore

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

the class ChangeSummaryXSDWithCSonChildUndoTestCases method testMoveBetweenDifferentTreesIntoChildChangeSummaryAndUndo_MoveEmployeeDownIntoCS1asBuyerOfCurrentWithoutCSInDiffTree.

// * UC 10.5             move corp2.sales.emp inside/down into corp1.sales.po2.buyer (diff tree/ into cs)
public void testMoveBetweenDifferentTreesIntoChildChangeSummaryAndUndo_MoveEmployeeDownIntoCS1asBuyerOfCurrentWithoutCSInDiffTree() {
    // save original root for later comparison after undo
    DataObject originalRootDO = copyHelper.copy(rootObject);
    assertTrue(equalityHelper.equal(rootObject, originalRootDO));
    DataObject salesDO = rootObject.getDataObject("sales");
    DataObject salesDO2 = rootObject2.getDataObject("sales");
    DataObject salesPO1DO = salesDO.getDataObject("purchaseOrder[1]");
    DataObject salesPO2DO = salesDO.getDataObject("purchaseOrder[2]");
    DataObject salesPO1DO2 = salesDO2.getDataObject("purchaseOrder[1]");
    DataObject salesPO2DO2 = salesDO2.getDataObject("purchaseOrder[2]");
    DataObject salesPO1BuyerDO = salesPO1DO.getDataObject("buyer");
    DataObject salesPO2BuyerDO = salesPO2DO.getDataObject("buyer");
    DataObject salesPO1BuyerDO2 = salesPO1DO2.getDataObject("buyer");
    DataObject salesPO2BuyerDO2 = salesPO2DO2.getDataObject("buyer");
    DataObject salesPO1ItemsDO = salesPO1DO.getDataObject("items");
    DataObject salesPO2ItemsDO = salesPO2DO.getDataObject("items");
    DataObject salesPO1ItemsDO2 = salesPO1DO2.getDataObject("items");
    DataObject salesPO2ItemsDO2 = salesPO2DO2.getDataObject("items");
    DataObject salesPO1Item1DO = salesPO1ItemsDO.getDataObject("item[1]");
    DataObject salesPO1Item2DO = salesPO1ItemsDO.getDataObject("item[2]");
    DataObject salesPO2Item1DO = salesPO2ItemsDO.getDataObject("item[1]");
    DataObject salesPO2Item2DO = salesPO2ItemsDO.getDataObject("item[2]");
    DataObject salesPO1Item1ProductDO = salesPO1Item1DO.getDataObject("product");
    DataObject salesPO1Item2ProductDO = salesPO1Item2DO.getDataObject("product");
    DataObject salesPO2Item1ProductDO = salesPO2Item1DO.getDataObject("product");
    DataObject salesPO2Item2ProductDO = salesPO2Item2DO.getDataObject("product");
    DataObject salesPO1Item1ProductPrice1DO = salesPO1Item1ProductDO.getDataObject("price[1]");
    DataObject salesPO1Item1ProductPrice2DO = salesPO1Item1ProductDO.getDataObject("price[2]");
    DataObject salesPO1Item2ProductPrice1DO = salesPO1Item2ProductDO.getDataObject("price[1]");
    DataObject salesPO1Item2ProductPrice2DO = salesPO1Item2ProductDO.getDataObject("price[2]");
    DataObject salesPO2Item1ProductPrice1DO = salesPO2Item1ProductDO.getDataObject("price[1]");
    DataObject salesPO2Item1ProductPrice2DO = salesPO2Item1ProductDO.getDataObject("price[2]");
    DataObject salesPO2Item2ProductPrice1DO = salesPO2Item2ProductDO.getDataObject("price[1]");
    DataObject salesPO2Item2ProductPrice2DO = salesPO2Item2ProductDO.getDataObject("price[2]");
    // DataObject developmentDO = rootObject.getDataObject("development");
    DataObject stock1DO = rootObject.getDataObject("stock[1]");
    DataObject stock2DO = rootObject.getDataObject("stock[2]");
    DataObject stock3DO = rootObject.getDataObject("stock[3]");
    assertNull(salesDO.getChangeSummary());
    assertNotNull(salesPO1DO.getChangeSummary());
    assertNotNull(salesPO2DO.getChangeSummary());
    assertNotNull(salesPO1ItemsDO.getChangeSummary());
    assertNotNull(salesPO2ItemsDO.getChangeSummary());
    assertNull(salesDO2.getChangeSummary());
    assertNotNull(salesPO1DO2.getChangeSummary());
    assertNotNull(salesPO2DO2.getChangeSummary());
    assertNotNull(salesPO1ItemsDO2.getChangeSummary());
    assertNotNull(salesPO2ItemsDO2.getChangeSummary());
    // preoperation setup
    // move from buyer to emp[1] on tree2
    salesDO2.set("employee[1]", salesPO1BuyerDO2);
    // delete buyer on tree1
    salesPO1BuyerDO.delete();
    DataObject salesEmp1DO2 = salesDO2.getDataObject("employee[1]");
    salesPO1CS.beginLogging();
    salesPO2CS.beginLogging();
    stock1CS.beginLogging();
    stock2CS.beginLogging();
    stock3CS.beginLogging();
    salesPO1CS2.beginLogging();
    salesPO2CS2.beginLogging();
    stock1CS2.beginLogging();
    stock2CS2.beginLogging();
    stock3CS2.beginLogging();
    // verify original VS is null and save a copy of current VS for object identity testing after undo
    assertValueStoresInitializedAfterLoggingOn(salesPO1DO);
    assertValueStoresInitializedAfterLoggingOn(salesPO2DO);
    assertValueStoresInitializedAfterLoggingOn(stock1DO);
    assertValueStoresInitializedAfterLoggingOn(stock2DO);
    assertValueStoresInitializedAfterLoggingOn(stock3DO);
    // save a copy of current VS for object identity testing after undo
    ValueStore aCurrentValueStoreAfterLoggingFirstOn = ((SDODataObject) salesPO1DO)._getCurrentValueStore();
    // move from buyer to emp[1]
    salesPO1DO.set("buyer", salesEmp1DO2);
    // salesDO.set("employee[2]", null); NPE
    boolean wasDeleted = false;
    boolean wasReattachedInContextOfAChangeSummary = false;
    // buyer was set to null
    assertModified(salesPO1DO, salesPO1CS);
    assertEquals(0, salesDO.getList("employee").size());
    // moving an object outside and reattaching above clears it from the cs tree
    // , wasDeleted, wasReattachedInContextOfAChangeSummary, false);
    assertCreated(salesEmp1DO2, salesPO1CS);
    // assertUnchanged(someChildofBuyerDO, salesPO1CS);
    assertEquals(2, salesPO1CS.getChangedDataObjects().size());
    // from 14 (sales has 2 PO's not 1)
    assertEquals(15, ((SDOChangeSummary) salesPO1CS).getOldContainer().size());
    assertEquals(15, ((SDOChangeSummary) salesPO1CS).getOldContainmentProperty().size());
// assertValueStoresReturnedToStartStateAfterUndoChanges(salesPO1DO, aCurrentValueStoreAfterLoggingFirstOn);
// writeXML(rootObject, URINAME, TYPENAME, System.out);
// null xpath for create
}
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)

Example 8 with ValueStore

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

the class ChangeSummaryXSDWithCSonChildUndoTestCases method testUnsetSalesPO1ItemsResetAndUndo_MultiOperation_UnsetComplexSingleWithManyChildBelowRootResetAndUndo.

// reset
public void testUnsetSalesPO1ItemsResetAndUndo_MultiOperation_UnsetComplexSingleWithManyChildBelowRootResetAndUndo() {
    // save original root for later comparison after undo
    DataObject originalRootDO = copyHelper.copy(rootObject);
    assertTrue(equalityHelper.equal(rootObject, originalRootDO));
    DataObject salesDO = rootObject.getDataObject("sales");
    DataObject salesPO1DO = salesDO.getDataObject("purchaseOrder[1]");
    DataObject salesPO2DO = salesDO.getDataObject("purchaseOrder[2]");
    DataObject salesPO1ItemsDO = salesPO1DO.getDataObject("items");
    DataObject salesPO2ItemsDO = salesPO2DO.getDataObject("items");
    DataObject salesPO1Item1DO = salesPO1ItemsDO.getDataObject("item[1]");
    DataObject salesPO1Item2DO = salesPO1ItemsDO.getDataObject("item[2]");
    // DataObject salesPO2Item1DO = salesPO2ItemsDO.getDataObject("item[1]");
    // DataObject salesPO2Item2DO = salesPO2ItemsDO.getDataObject("item[2]");
    DataObject salesPO1Item1ProductDO = salesPO1Item1DO.getDataObject("product");
    DataObject salesPO1Item2ProductDO = salesPO1Item2DO.getDataObject("product");
    // DataObject salesPO2Item1ProductDO = salesPO2Item1DO.getDataObject("product");
    // DataObject salesPO2Item2ProductDO = salesPO2Item2DO.getDataObject("product");
    DataObject salesPO1Item1ProductPrice1DO = salesPO1Item1ProductDO.getDataObject("price[1]");
    DataObject salesPO1Item1ProductPrice2DO = salesPO1Item1ProductDO.getDataObject("price[2]");
    DataObject salesPO1Item2ProductPrice1DO = salesPO1Item2ProductDO.getDataObject("price[1]");
    DataObject salesPO1Item2ProductPrice2DO = salesPO1Item2ProductDO.getDataObject("price[2]");
    // DataObject salesPO2Item1ProductPrice1DO = salesPO2Item1ProductDO.getDataObject("price[1]");
    // DataObject salesPO2Item1ProductPrice2DO = salesPO2Item1ProductDO.getDataObject("price[2]");
    // DataObject salesPO2Item2ProductPrice1DO = salesPO2Item2ProductDO.getDataObject("price[1]");
    // DataObject salesPO2Item2ProductPrice2DO = salesPO2Item2ProductDO.getDataObject("price[2]");
    // DataObject developmentDO = rootObject.getDataObject("development");
    DataObject stock1DO = rootObject.getDataObject("stock[1]");
    DataObject stock2DO = rootObject.getDataObject("stock[2]");
    DataObject stock3DO = rootObject.getDataObject("stock[3]");
    assertNull(salesDO.getChangeSummary());
    assertNotNull(salesPO1DO.getChangeSummary());
    assertNotNull(salesPO2DO.getChangeSummary());
    assertNotNull(salesPO1ItemsDO.getChangeSummary());
    assertNotNull(salesPO2ItemsDO.getChangeSummary());
    salesPO1CS.beginLogging();
    salesPO2CS.beginLogging();
    stock1CS.beginLogging();
    stock2CS.beginLogging();
    stock3CS.beginLogging();
    // verify original VS is null and save a copy of current VS for object identity testing after undo
    assertValueStoresInitializedAfterLoggingOn(salesPO1DO);
    assertValueStoresInitializedAfterLoggingOn(salesPO2DO);
    assertValueStoresInitializedAfterLoggingOn(stock1DO);
    assertValueStoresInitializedAfterLoggingOn(stock2DO);
    assertValueStoresInitializedAfterLoggingOn(stock3DO);
    // save a copy of current VS for object identity testing after undo
    ValueStore aCurrentValueStoreAfterLoggingFirstOn = ((SDODataObject) salesPO1DO)._getCurrentValueStore();
    salesPO1DO.unset("items");
    boolean wasDeleted = false;
    // verify CS is null on removed trees
    assertChangeSummaryStatusIfClearedIfCSIsAncestor(salesPO1ItemsDO, true);
    // check valueStores
    assertValueStoresCopiedAndSwappedAfterFirstModifyOperation(salesPO1DO, aCurrentValueStoreAfterLoggingFirstOn);
    assertNotNull(salesPO1Item1DO);
    assertNotNull(salesPO1Item2DO);
    assertModified(salesPO1DO, salesPO1CS);
    // 20070206 CS is not being deleted
    assertDetached(salesPO1ItemsDO, salesPO1CS);
    assertDetached(salesPO1Item1DO, salesPO1CS, wasDeleted);
    assertDetached(salesPO1Item2DO, salesPO1CS, wasDeleted);
    assertDetached(salesPO1Item1ProductDO, salesPO1CS, wasDeleted);
    assertDetached(salesPO1Item1ProductPrice1DO, salesPO1CS, wasDeleted);
    assertDetached(salesPO1Item1ProductPrice2DO, salesPO1CS, wasDeleted);
    assertDetached(salesPO1Item2ProductDO, salesPO1CS, wasDeleted);
    assertDetached(salesPO1Item2ProductPrice1DO, salesPO1CS, wasDeleted);
    assertDetached(salesPO1Item2ProductPrice2DO, salesPO1CS, wasDeleted);
    assertEquals(10, salesPO1CS.getChangedDataObjects().size());
    // from 14 (sales has 2 PO's not 1)
    assertEquals(16, ((SDOChangeSummary) salesPO1CS).getOldContainer().size());
    assertEquals(16, ((SDOChangeSummary) salesPO1CS).getOldContainmentProperty().size());
    // set the items back  (in effect doing an undo)
    salesPO1DO.set("items", salesPO1ItemsDO);
    assertUndoChangesEqualToOriginal(salesPO1CS, rootObject, originalRootDO);
    // verify that property is reset
    assertTrue(salesPO1DO.isSet("items"));
    // get back items object
    DataObject itemsDOundone = salesPO1DO.getDataObject("items");
    // compare with original
    assertTrue(equalityHelper.equal(itemsDOundone, salesPO1ItemsDO));
    assertValueStoresReturnedToStartStateAfterUndoChanges(salesPO1DO, 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)

Example 9 with ValueStore

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

the class ChangeSummaryXSDWithCSonRootUndoTestCases method testSetItemsAfterDetachAndUndo_MultiOperation_SetComplexSingleWithManyChildBelowRootAndUndo.

public void testSetItemsAfterDetachAndUndo_MultiOperation_SetComplexSingleWithManyChildBelowRootAndUndo() {
    // get items property - to speed debugging
    Property itemsProperty = rootObject.getInstanceProperty("items");
    // 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.detach();
    // 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), // 
    rootObject.getDataObject("items/item[1]"), // 
    rootObject.getDataObject("items/item[2]"), // 
    rootObject.getDataObject("items/item[1]/product"), // 
    rootObject.getDataObject("items/item[1]/product/price[1]"), // 
    rootObject.getDataObject("items/item[1]/product/price[2]"), // 
    rootObject.getDataObject("items/item[2]/product"), // 
    rootObject.getDataObject("items/item[2]/product/price[1]"), // 
    rootObject.getDataObject("items/item[2]/product/price[2]"), // 
    itemsProperty, // 
    originalRootDO, // 
    itemsDOtoSet, aCurrentValueStoreAfterLoggingFirstOn, false);
}
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 10 with ValueStore

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

the class ChangeSummaryXSDWithCSonRootUndoTestCases method testSetItemsAfterUnsetAndUndo_MultiOperation_SetComplexSingleWithManyChildBelowRootAndUndo.

public void testSetItemsAfterUnsetAndUndo_MultiOperation_SetComplexSingleWithManyChildBelowRootAndUndo() {
    // get items property - to speed debugging
    Property itemsProperty = rootObject.getInstanceProperty("items");
    // 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());
    // unset is not clearing the cs when logging is off
    rootObject.unset(itemsProperty);
    // 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), // 
    rootObject.getDataObject("items/item[1]"), // 
    rootObject.getDataObject("items/item[2]"), // 
    rootObject.getDataObject("items/item[1]/product"), // 
    rootObject.getDataObject("items/item[1]/product/price[1]"), // 
    rootObject.getDataObject("items/item[1]/product/price[2]"), // 
    rootObject.getDataObject("items/item[2]/product"), // 
    rootObject.getDataObject("items/item[2]/product/price[1]"), // 
    rootObject.getDataObject("items/item[2]/product/price[2]"), // 
    itemsProperty, // 
    originalRootDO, // 
    itemsDOtoSet, aCurrentValueStoreAfterLoggingFirstOn, false);
}
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)

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