Search in sources :

Example 21 with SDODataObject

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

the class ChangeSummaryXSDwSeqTestCases method testDeleteItemsAndUndo.

public void testDeleteItemsAndUndo() {
    // 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
    ValueStore aCurrentValueStore = ((SDODataObject) rootObject)._getCurrentValueStore();
    assertNotNull(aCurrentValueStore);
    ValueStore anOriginalValueStore = (ValueStore) ((SDOChangeSummary) cs).getOriginalValueStores().get(rootObject);
    assertNull(anOriginalValueStore);
    itemsDO.delete();
    // check valueStores
    assertNotNull(aCurrentValueStore);
    ValueStore anOriginalValueStoreAfterOperation = (ValueStore) ((SDOChangeSummary) cs).getOriginalValueStores().get(rootObject);
    ValueStore aCurrentValueStoreAfterOperation = ((SDODataObject) rootObject)._getCurrentValueStore();
    assertNotNull(anOriginalValueStoreAfterOperation);
    assertNotNull(aCurrentValueStoreAfterOperation);
    assertTrue(anOriginalValueStoreAfterOperation == aCurrentValueStore);
    assertNotNull(item1DO);
    assertNotNull(item2DO);
    assertModified(rootObject, cs);
    assertDeleted(itemsDO, cs);
    assertDeleted(item1DO, cs);
    assertDeleted(item2DO, cs);
    assertDeleted(item1ProductDO, cs);
    assertDeleted(item1ProductPrice1DO, cs);
    assertDeleted(item1ProductPrice2DO, cs);
    assertDeleted(item2ProductDO, cs);
    assertDeleted(item2ProductPrice1DO, cs);
    assertDeleted(item2ProductPrice2DO, cs);
    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");
    ValueStore anOriginalValueStoreAfterUndo = (ValueStore) ((SDOChangeSummary) cs).getOriginalValueStores().get(rootObject);
    ValueStore aCurrentValueStoreAfterUndo = ((SDODataObject) rootObject)._getCurrentValueStore();
    assertNull(anOriginalValueStoreAfterUndo);
    assertNotNull(aCurrentValueStoreAfterUndo);
    // we return the original value store back to the current VS
    assertTrue(aCurrentValueStoreAfterUndo == aCurrentValueStore);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) ValueStore(org.eclipse.persistence.sdo.ValueStore) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 22 with SDODataObject

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

the class ChangeSummaryXSDwSeqTestCases method verifyDeepCopyObjectWithCSLoggingOnDoesNotLogChangesInTheDeepCopy.

private SDODataObject verifyDeepCopyObjectWithCSLoggingOnDoesNotLogChangesInTheDeepCopy(SDODataObject aRootObject) {
    List preOrderList = null;
    int numberOfDataObjectsInSubTree = 0;
    // verify logging is on
    // turn on logging
    cs.beginLogging();
    assertTrue(cs.isLogging());
    // take an object with CS on and deep copy it
    SDODataObject copy = (SDODataObject) copyHelper.copy(aRootObject);
    // verify that logging is still on
    assertNotNull(cs);
    assertTrue(cs.isLogging());
    ChangeSummary cs2 = copy.getChangeSummary();
    assertNotNull(cs2);
    assertTrue(cs2.isLogging());
    // verify that we have not logged changes during the copy (we dont have to worry about nested changesummaries)
    // we should not have 5 old settings after a copy
    assertEquals(0, cs2.getChangedDataObjects().size());
    preOrderList = preOrderTraversalDataObjectList(copy, false);
    numberOfDataObjectsInSubTree = preOrderList.size();
    // assume that for logging=true copies we should have oldContainer, oldContProperties
    assertEquals(15, numberOfDataObjectsInSubTree);
    assertEquals(// 
    ((SDOChangeSummary) cs2).getOldContainer().size(), copy.getChangeSummary().getOldContainer().size());
    assertEquals(// 
    ((SDOChangeSummary) cs2).getOldContainmentProperty().size(), copy.getChangeSummary().getOldContainmentProperty().size());
    return copy;
}
Also used : SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) ArrayList(java.util.ArrayList) List(java.util.List) ChangeSummary(commonj.sdo.ChangeSummary) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 23 with SDODataObject

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

the class SDODataObjectGetDataObjectConversionTest method testGetDataObjectConversionFromDefinedProperty.

public void testGetDataObjectConversionFromDefinedProperty() {
    SDOType dataObjectType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.DATAOBJECT);
    SDOProperty property = dataObject.getInstanceProperty(PROPERTY_NAME);
    property.setType(dataObjectType);
    SDODataObject b = new SDODataObject();
    // add it to instance list
    dataObject.setDataObject(property, b);
    assertEquals(b, dataObject.getDataObject(property));
}
Also used : SDOType(org.eclipse.persistence.sdo.SDOType) SDOProperty(org.eclipse.persistence.sdo.SDOProperty) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 24 with SDODataObject

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

the class SDODataObjectGetDataObjectByPositionalPathTest method testGetDataObjectConversionFromDefinedPropertyWithPath.

// purpose: opencontent properties
public void testGetDataObjectConversionFromDefinedPropertyWithPath() {
    SDOType dataObjectType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.DATAOBJECT);
    // dataObject's type add boolean property
    type_b.setOpen(true);
    SDOProperty property = new SDOProperty(aHelperContext);
    property.setName("openTest");
    property.setMany(true);
    property.setType(dataObjectType);
    List objects = new ArrayList();
    SDOType t = new SDOType("uri", "test");
    SDOProperty p = new SDOProperty(aHelperContext);
    p.setType(SDOConstants.SDO_STRING);
    p.setMany(false);
    p.setName("number");
    t.addDeclaredProperty(p);
    SDODataObject b = new SDODataObject();
    b._setType(t);
    b.set(p, "1");
    // add it to instance list
    dataObject_b.set(property, objects);
    dataObject_a.setDataObject("PName-a/openTest[1]", b);
    assertEquals(b, dataObject_a.getDataObject("PName-a/openTest[number=1]"));
}
Also used : SDOType(org.eclipse.persistence.sdo.SDOType) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) SDOProperty(org.eclipse.persistence.sdo.SDOProperty) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 25 with SDODataObject

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

the class SDODataObjectGetDataObjectByPositionalPathTest method testGetDataObjectConversionWithPathFromDefinedBooleanPropertyBracketInPathMiddle.

// 1. purpose: getBoolean with Defined Boolean Property
public void testGetDataObjectConversionWithPathFromDefinedBooleanPropertyBracketInPathMiddle() {
    SDOType dataObjectType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.DATAOBJECT);
    dataObject_c.getInstanceProperty(PROPERTY_NAME_C).setType(dataObjectType);
    SDODataObject bb = new SDODataObject();
    // c dataobject's a property has value boolean 'true'
    dataObject_a.setDataObject(property1, bb);
    assertEquals(bb, dataObject_a.getDataObject(property1));
}
Also used : SDOType(org.eclipse.persistence.sdo.SDOType) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Aggregations

SDODataObject (org.eclipse.persistence.sdo.SDODataObject)301 DataObject (commonj.sdo.DataObject)118 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)99 ArrayList (java.util.ArrayList)79 ListWrapper (org.eclipse.persistence.sdo.helper.ListWrapper)76 SDOType (org.eclipse.persistence.sdo.SDOType)70 List (java.util.List)65 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)64 Property (commonj.sdo.Property)52 SDOSequence (org.eclipse.persistence.sdo.SDOSequence)51 ValueStore (org.eclipse.persistence.sdo.ValueStore)22 SDOXMLHelper (org.eclipse.persistence.sdo.helper.SDOXMLHelper)21 ChangeSummary (commonj.sdo.ChangeSummary)20 SDOMarshalListener (org.eclipse.persistence.sdo.helper.SDOMarshalListener)20 Iterator (java.util.Iterator)18 Type (commonj.sdo.Type)9 XMLDocument (commonj.sdo.helper.XMLDocument)6 FileInputStream (java.io.FileInputStream)6 IOException (java.io.IOException)5 Map (java.util.Map)5