Search in sources :

Example 1 with ChangeSummary

use of commonj.sdo.ChangeSummary in project eclipselink by eclipse-ee4j.

the class SDODataObject method detachDeleteRecursivePrivateHelper.

/**
 * INTERNAL:
 * Call detach or delete recursively on aDataObject after possibly changing the flag whether to clear the ChangeSummary pointer at this level
 * @param aDataObject
 * @param fromDelete
 * @param clearCS
 */
private void detachDeleteRecursivePrivateHelper(SDODataObject aDataObject, boolean fromDelete, boolean clearCS) {
    if (aDataObject != null) {
        // Return whether (aDataObject) is the changeSummary root.
        boolean isCSRoot = // 
        (aDataObject.getChangeSummary() != null) && (aDataObject.getChangeSummary().getRootObject() == aDataObject);
        // If we are at the CS root - we do not clear the changeSummary
        if (isCSRoot) {
            clearCS = false;
        } else {
            if (aDataObject.getContainer() != null) {
                ChangeSummary containerCS = aDataObject.getContainer().getChangeSummary();
                // If there is no CS field set above this object then clear any ChangeSummary pointer at this level
                if (containerCS == null) {
                    clearCS = true;
                }
            }
        }
        aDataObject.detachDeleteRecursivePrivate(fromDelete, clearCS, false);
    }
}
Also used : ChangeSummary(commonj.sdo.ChangeSummary)

Example 2 with ChangeSummary

use of commonj.sdo.ChangeSummary in project eclipselink by eclipse-ee4j.

the class LoadAndSaveBug6680769TestCases method verifyAfterLoad.

@Override
protected void verifyAfterLoad(XMLDocument doc) {
    super.verifyAfterLoad(doc);
    DataObject rootDO = doc.getRootObject();
    DataObject dataDO = rootDO.getDataObject("data");
    ChangeSummary cs = dataDO.getChangeSummary();
    cs.beginLogging();
    List valueList = (List) dataDO.get("Value");
    // clear the list, this is to recreate the issue that this bug is about
    valueList.clear();
}
Also used : DataObject(commonj.sdo.DataObject) ArrayList(java.util.ArrayList) List(java.util.List) ChangeSummary(commonj.sdo.ChangeSummary)

Example 3 with ChangeSummary

use of commonj.sdo.ChangeSummary in project eclipselink by eclipse-ee4j.

the class ChangeSummaryRootLoggingOnModifyComplexAtCSLoadAndSaveTestCases method verifyAfterLoad.

@Override
protected void verifyAfterLoad(XMLDocument document) {
    super.verifyAfterLoad(document);
    ChangeSummary teamCS = document.getRootObject().getChangeSummary();
    assertNotNull(teamCS);
    DataObject manager = document.getRootObject().getDataObject("manager");
    assertNotNull(manager);
    assertTrue(teamCS.isLogging());
    assertTrue(teamCS.isLogging());
    assertFalse(teamCS.isCreated(manager));
    assertTrue(teamCS.isModified(manager));
    DataObject phone3 = manager.getDataObject("phone[3]");
    assertEquals("3456789", phone3.getString("number"));
    teamCS.isModified(phone3);
    List managersettings = teamCS.getOldValues(manager);
    // assertEquals(1, managersettings.size());
    SDOSetting nameSetting = (SDOSetting) teamCS.getOldValue(manager, manager.getInstanceProperty("name"));
    assertEquals("Old Name", nameSetting.getValue());
    List settings = teamCS.getOldValues(phone3);
    assertEquals(1, settings.size());
    SDOSetting firstSetting = (SDOSetting) settings.get(0);
    assertEquals("1111111", firstSetting.getValue());
// setting for number should have value 1111111
/*        DataObject address = manager.getDataObject("address");
        assertNotNull(address);
        ChangeSummary addressCS = address.getChangeSummary();

        List phones = manager.getList("phone");
        for (int i = 0; i < phones.size(); i++) {
            DataObject nextPhone = ((DataObject)phones.get(i));
            ChangeSummary phoneCS = nextPhone.getChangeSummary();
            // verify changesummary tree integrity
            assertEquals(teamCS, phoneCS);
            // we modified the address
            if (i == 2) {
                assertEquals("3456789",nextPhone.getString("number"));
                assertTrue(teamCS.isCreated(nextPhone));
            } else {
                assertFalse(teamCS.isCreated(nextPhone));
            }
        }

        // verify child change summaries are equal to their parent
        assertEquals(teamCS, addressCS);
        assertTrue(teamCS.isCreated(address));
        */
// verify logging status
// assertEquals(0, teamCS.getOldValues(address).size());
// DataObject addressDO = manager.getDataObject("address");
// assertTrue(teamCS.isModified(addressDO));
// modify stuff for write
// document.getRootObject();
}
Also used : DataObject(commonj.sdo.DataObject) SDOSetting(org.eclipse.persistence.sdo.SDOSetting) List(java.util.List) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) ChangeSummary(commonj.sdo.ChangeSummary)

Example 4 with ChangeSummary

use of commonj.sdo.ChangeSummary in project eclipselink by eclipse-ee4j.

the class ChangeSummaryCreateOpenContentTestCases method verifyAfterLoad.

@Override
protected void verifyAfterLoad(XMLDocument document) {
    super.verifyAfterLoad(document);
    ChangeSummary teamCS = document.getRootObject().getChangeSummary();
    assertNotNull(teamCS);
    DataObject manager = document.getRootObject().getDataObject("manager");
    assertNotNull(manager);
    assertTrue(manager.getType().isSequenced());
    ChangeSummary managerCS = manager.getChangeSummary();
    assertEquals(teamCS, managerCS);
    assertTrue(teamCS.isLogging());
    assertTrue(teamCS.isLogging());
    DataObject address = manager.getDataObject("address");
    assertNotNull(address);
    assertCreated(address, teamCS);
    List yards = manager.getList("theYard");
    assertEquals(1, yards.size());
    DataObject yard = (DataObject) yards.get(0);
    assertNotNull(yard);
    assertCreated(yard, teamCS);
    DataObject theYardDefined = manager.getDataObject("theYardDefined");
    // assertEquals(1, yards.size());
    // DataObject yard = (DataObject)yards.get(0);
    assertNotNull(theYardDefined);
    assertCreated(theYardDefined, teamCS);
    List theYardUndefinedList = manager.getList("theYardUndefined");
    assertEquals(1, theYardUndefinedList.size());
    DataObject theYardUndefined = (DataObject) theYardUndefinedList.get(0);
    assertNotNull(theYardUndefined);
    assertCreated(theYardUndefined, teamCS);
    assertNull(xsdHelper.getGlobalProperty("http://www.example.org", "theYardUndefined", true));
    assertNull(xsdHelper.getGlobalProperty("http://www.example.org", "theYardUndefined", false));
}
Also used : DataObject(commonj.sdo.DataObject) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) List(java.util.List) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) ChangeSummary(commonj.sdo.ChangeSummary)

Example 5 with ChangeSummary

use of commonj.sdo.ChangeSummary in project eclipselink by eclipse-ee4j.

the class ChangeSummaryDeleteOpenContentTestCases method verifyAfterLoad.

@Override
protected void verifyAfterLoad(XMLDocument document) {
    super.verifyAfterLoad(document);
    ChangeSummary teamCS = document.getRootObject().getChangeSummary();
    assertNotNull(teamCS);
    DataObject manager = document.getRootObject().getDataObject("manager");
    assertNotNull(manager);
    ChangeSummary managerCS = manager.getChangeSummary();
    assertEquals(teamCS, managerCS);
    assertTrue(teamCS.isLogging());
    assertTrue(teamCS.isLogging());
    List yards = manager.getList("theYard");
    assertTrue(yards.isEmpty());
    assertEquals(1, ((SDOChangeSummary) managerCS).getModified().size());
    assertEquals(4, ((SDOChangeSummary) managerCS).getDeleted().size());
    DataObject deletedYard = (DataObject) ((SDOChangeSummary) managerCS).getDeleted().get(0);
    // TODO: what should be deletedYard.get"width" vs. get oldSetting "width
    assertEquals("theSqFootage", deletedYard.get("squarefootage"));
    assertEquals("thelength", deletedYard.get("length"));
    assertEquals("theWidth", deletedYard.get("width"));
    // theYardDefined
    DataObject deletedYardDefined = (DataObject) ((SDOChangeSummary) managerCS).getDeleted().get(1);
    ChangeSummary.Setting setting = managerCS.getOldValue(deletedYardDefined, deletedYardDefined.getInstanceProperty("squarefootage"));
    assertNotNull(setting);
    assertEquals("theSqFootageDefined", setting.getValue());
    setting = managerCS.getOldValue(deletedYardDefined, deletedYardDefined.getInstanceProperty("length"));
    assertNotNull(setting);
    assertEquals("thelengthDefined", setting.getValue());
    setting = managerCS.getOldValue(deletedYardDefined, deletedYardDefined.getInstanceProperty("width"));
    assertNotNull(setting);
    assertEquals("theWidthDefined", setting.getValue());
    // theYardUndefined
    DataObject deletedYardUndefined = (DataObject) ((SDOChangeSummary) managerCS).getDeleted().get(2);
    setting = managerCS.getOldValue(deletedYardUndefined, deletedYardUndefined.getInstanceProperty("squarefootage"));
    assertNotNull(setting);
    assertEquals(1, ((List) setting.getValue()).size());
    assertEquals("theSqFootageUndefined", ((List) setting.getValue()).get(0));
    setting = managerCS.getOldValue(deletedYardUndefined, deletedYardUndefined.getInstanceProperty("length"));
    assertNotNull(setting);
    assertEquals(1, ((List) setting.getValue()).size());
    assertEquals("thelengthUndefined", ((List) setting.getValue()).get(0));
    setting = managerCS.getOldValue(deletedYardUndefined, deletedYardUndefined.getInstanceProperty("width"));
    assertNotNull(setting);
    assertEquals(1, ((List) setting.getValue()).size());
    assertEquals("theWidthUndefined", ((List) setting.getValue()).get(0));
    // 
    // address
    DataObject address = (DataObject) ((SDOChangeSummary) managerCS).getDeleted().get(3);
    setting = managerCS.getOldValue(address, address.getInstanceProperty("street"));
    assertNotNull(setting);
    assertEquals("theStreet", setting.getValue());
    assertTrue(setting.isSet());
    ChangeSummary.Setting oldNameSetting = managerCS.getOldValue(manager, manager.getInstanceProperty("name"));
    List oldValues = managerCS.getOldValues(manager);
    Sequence oldSequence = managerCS.getOldSequence(manager);
    assertEquals(4, oldValues.size());
    assertEquals(5, oldSequence.size());
    assertEquals("Jane Doe", oldSequence.getValue(0));
    assertEquals("name", oldSequence.getProperty(0).getName());
    DataObject yardValue = (DataObject) oldSequence.getValue(1);
    assertNotNull(yardValue);
    assertEquals("Yard", yardValue.getType().getName());
    assertEquals("theYard", oldSequence.getProperty(1).getName());
    DataObject yardDefinedValue = (DataObject) oldSequence.getValue(2);
    assertEquals("Yard", yardDefinedValue.getType().getName());
    assertNotNull(yardDefinedValue);
    // assertEquals("theYardDefined" ,oldSequence.getProperty(2).getName());
    SDODataObject yardUnDefinedValue = (SDODataObject) oldSequence.getValue(3);
    assertNotNull(yardUnDefinedValue);
    assertTrue(yardUnDefinedValue.getType().isOpenSequencedType());
    assertEquals("theYardUndefined", oldSequence.getProperty(3).getName());
    DataObject addressValue = (DataObject) oldSequence.getValue(4);
    assertEquals("Address", addressValue.getType().getName());
    assertEquals("address", oldSequence.getProperty(4).getName());
// olsequence is size 2 with name + address
// DataObject yard = manager.getDataObject("theYard");
/* List yards = manager.getList("theYard");
        assertEquals(1, yards.size());
        DataObject yard = (DataObject)yards.get(0);
        assertNotNull(yard);
        assertEquals("theSqFootage", yard.get("squarefootage"));
        assertEquals("thelength", yard.get("length"));
        assertEquals("theWidth", yard.get("width"));
        */
}
Also used : DataObject(commonj.sdo.DataObject) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) List(java.util.List) Sequence(commonj.sdo.Sequence) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) ChangeSummary(commonj.sdo.ChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Aggregations

ChangeSummary (commonj.sdo.ChangeSummary)55 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)44 DataObject (commonj.sdo.DataObject)35 List (java.util.List)24 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)24 Property (commonj.sdo.Property)21 ArrayList (java.util.ArrayList)12 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)10 XMLDocument (commonj.sdo.helper.XMLDocument)4 Map (java.util.Map)4 SDOType (org.eclipse.persistence.sdo.SDOType)4 ListWrapper (org.eclipse.persistence.sdo.helper.ListWrapper)4 FileInputStream (java.io.FileInputStream)3 Iterator (java.util.Iterator)2 SDOSequence (org.eclipse.persistence.sdo.SDOSequence)2 SDOSetting (org.eclipse.persistence.sdo.SDOSetting)2 Sequence (commonj.sdo.Sequence)1 InputStream (java.io.InputStream)1