Search in sources :

Example 6 with SDODataObject

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

the class SDOTestCase method preOrderTraversalDataObjectList.

private List<DataObject> preOrderTraversalDataObjectList(SDODataObject currentDO, ArrayList<DataObject> currentList, boolean countNullObjects, boolean recurse) {
    if (currentDO != null) {
        // add yourself
        currentList.add(currentDO);
        // check DO's recursively
        List instanceProperties = currentDO.getInstanceProperties();
        SDOProperty nextProperty = null;
        Object value = null;
        if (recurse) {
            for (int i = 0; i < instanceProperties.size(); i++) {
                nextProperty = (SDOProperty) instanceProperties.get(i);
                value = currentDO.get(nextProperty);
                boolean recurseHopefullyNotToInfinityPlease = true;
                if (!nextProperty.getType().isChangeSummaryType() && !nextProperty.getType().isDataType()) {
                    // infinite loop
                    if (null != nextProperty.getOpposite()) {
                        recurseHopefullyNotToInfinityPlease = false;
                    }
                    if (nextProperty.isMany()) {
                        // iterate list
                        Object manyItem;
                        // generate a ConcurrentModificationException
                        for (int index = 0; index < ((List) value).size(); index++) {
                            manyItem = ((List) value).get(index);
                            if (manyItem != null && manyItem instanceof SDODataObject) {
                                preOrderTraversalDataObjectList((SDODataObject) manyItem, currentList, countNullObjects, recurseHopefullyNotToInfinityPlease);
                            }
                        }
                    } else {
                        if (value != null) {
                            preOrderTraversalDataObjectList((SDODataObject) value, currentList, countNullObjects, recurseHopefullyNotToInfinityPlease);
                        }
                    }
                }
            }
        }
    } else {
        if (countNullObjects) {
            currentList.add(currentDO);
        }
    }
    return currentList;
}
Also used : ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDOProperty(org.eclipse.persistence.sdo.SDOProperty) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 7 with SDODataObject

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

the class SDOTestCase method assertValueStoresReturnedToStartStateAfterUndoChanges.

/**
 */
protected void assertValueStoresReturnedToStartStateAfterUndoChanges(DataObject aRootObject, ValueStore aCurrentValueStoreAfterLoggingFirstOnParam) {
    // verify logging is on
    assertTrue(aRootObject.getChangeSummary().isLogging());
    ValueStore anOriginalValueStoreAfterUndo = (ValueStore) ((SDOChangeSummary) aRootObject.getChangeSummary()).getOriginalValueStores().get(aRootObject);
    ValueStore aCurrentValueStoreAfterUndo = ((SDODataObject) aRootObject)._getCurrentValueStore();
    assertNull(anOriginalValueStoreAfterUndo);
    assertNotNull(aCurrentValueStoreAfterUndo);
    // we return the original value store back to the current VS
    assertTrue(aCurrentValueStoreAfterUndo == aCurrentValueStoreAfterLoggingFirstOnParam);
}
Also used : ValueStore(org.eclipse.persistence.sdo.ValueStore) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 8 with SDODataObject

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

the class SDOTestCase method assertValueStoresCopiedAndSwappedAfterFirstModifyOperation.

/**
 */
protected void assertValueStoresCopiedAndSwappedAfterFirstModifyOperation(DataObject aRootObject, ValueStore aCurrentValueStoreAfterLoggingFirstOnParam) {
    // verify logging is on
    assertTrue(aRootObject.getChangeSummary().isLogging());
    assertNotNull(aCurrentValueStoreAfterLoggingFirstOnParam);
    ValueStore anOriginalValueStoreAfterOperation = (ValueStore) ((SDOChangeSummary) aRootObject.getChangeSummary()).getOriginalValueStores().get(aRootObject);
    ValueStore aCurrentValueStoreAfterOperation = ((SDODataObject) aRootObject)._getCurrentValueStore();
    assertNotNull(anOriginalValueStoreAfterOperation);
    assertNotNull(aCurrentValueStoreAfterOperation);
    assertTrue(anOriginalValueStoreAfterOperation == aCurrentValueStoreAfterLoggingFirstOnParam);
}
Also used : ValueStore(org.eclipse.persistence.sdo.ValueStore) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 9 with SDODataObject

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

the class SDOTestCase method assertSequencesReturnedToStartStateAfterUndoChanges.

/**
 */
protected void assertSequencesReturnedToStartStateAfterUndoChanges(DataObject aRootObject, Sequence aCurrentSequenceAfterLoggingFirstOnParam) {
    // verify logging is on
    assertTrue(aRootObject.getChangeSummary().isLogging());
    SDOSequence anOriginalSequenceAfterUndo = (SDOSequence) ((SDOChangeSummary) aRootObject.getChangeSummary()).getOriginalSequences().get(aRootObject);
    SDOSequence aCurrentSequenceAfterUndo = ((SDODataObject) aRootObject).getSequence();
    assertNull(anOriginalSequenceAfterUndo);
    assertNotNull(aCurrentSequenceAfterUndo);
    // we return the sequence back to the current VS
    assertEquals(aCurrentSequenceAfterUndo.size(), aCurrentSequenceAfterLoggingFirstOnParam.size());
    assertTrue(compareSequences(aCurrentSequenceAfterUndo, (SDOSequence) aCurrentSequenceAfterLoggingFirstOnParam, true));
}
Also used : SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDOSequence(org.eclipse.persistence.sdo.SDOSequence) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 10 with SDODataObject

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

the class SDOTestCase method checkOldSettingsValues.

// inOrderNodeList, preOrderNodeList, postOrderNodeList
// function to monitor actual values inside the oldSetting HashMap
protected void checkOldSettingsValues(String values, SDOChangeSummary aCS, List dataObjectList) {
    SDODataObject aDataObject = null;
    for (int i = 0; i < dataObjectList.size(); i++) {
        aDataObject = (SDODataObject) dataObjectList.get(i);
        assertEquals(Integer.parseInt(values.substring(i, i + 1)), aCS.getOldValues(aDataObject).size());
    }
}
Also used : 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