Search in sources :

Example 1 with SDOSequence

use of org.eclipse.persistence.sdo.SDOSequence 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 2 with SDOSequence

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

the class SDOSequenceTestXSD method testEqualDeepComplexManySequenceWithDifferentSequence2.

public void testEqualDeepComplexManySequenceWithDifferentSequence2() {
    defineAndLoadRoot(false, false);
    SDOSequence aSequence = getSequence(root, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
    DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
    // copy po
    DataObject rootCopy = copyHelper.copy(root);
    // check sequence was copied
    SDOSequence aSequenceCopy = getSequence(rootCopy, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
    assertNotNull(aSequenceCopy);
    // compareSequences(aSequence, aSequenceCopy, PO_SEQUENCE_SIZE, true);
    // modify copy sequence
    aSequenceCopy.setValue(0, null);
    // test equalityHelper
    DataObject poCopy = (DataObject) rootCopy.get(PO_SEQUENCE_PATH);
    boolean bEqual = equalityHelper.equal(po, poCopy);
    assertFalse(bEqual);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 3 with SDOSequence

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

the class SDOSequenceTestXSD method testAddOpenContentElementByIndexPropertyViaSequence.

public void testAddOpenContentElementByIndexPropertyViaSequence() {
    // make a source object
    defineAndLoadRoot(false, false);
    SDOSequence aSequence = (SDOSequence) root.getSequence();
    int sequenceSizeBefore = aSequence.size();
    assertNotNull(aSequence);
    SDOProperty openPropString = createOpenContentElementProperty("openContentString", SDOConstants.SDO_STRING);
    // perform open content op
    aSequence.add(2, openPropString, "openContentValue");
    // sequence should be modified
    assertEquals(aSequence.size(), sequenceSizeBefore + 1);
    // get dataObject side
    Object openDOContent = root.get("openContentString");
    assertNotNull(openDOContent);
    // get sequence side
    Object openSequenceContent = aSequence.getValue(2);
    assertNotNull(openSequenceContent);
    assertEquals(openSequenceContent, openDOContent);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDOProperty(org.eclipse.persistence.sdo.SDOProperty) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 4 with SDOSequence

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

the class SDOSequenceTestXSD method testRemoveAllEmptyComplexManyReferenceViaListWrapper.

public void testRemoveAllEmptyComplexManyReferenceViaListWrapper() {
    defineAndLoadRoot(false, false);
    SDOSequence aSequence = getSequence(root, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
    int sequenceSizeBefore = aSequence.size();
    DataObject itemDO1 = (DataObject) root.get(PO_SEQUENCE_PATH + "/item[1]");
    // after removal the items list indexes on the dataObject will shift down, get item[2] for later comparison
    DataObject itemDO2 = (DataObject) root.get(PO_SEQUENCE_PATH + "/item[2]");
    assertNotNull(itemDO1);
    assertNotNull(itemDO2);
    assertFalse(itemDO1 == itemDO2);
    DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
    ListWrapper existingList = (ListWrapper) po.get("item");
    int listSizeBefore = existingList.size();
    assertEquals(2, listSizeBefore);
    // get item from sequence
    int item2SequenceIndex = getNthSequenceIndexFor(aSequence, "item", 2);
    assertTrue(item2SequenceIndex > -1);
    DataObject itemObjectFromSetting = (DataObject) aSequence.getValue(item2SequenceIndex);
    assertNotNull(itemObjectFromSetting);
    assertTrue(itemObjectFromSetting == itemDO2);
    // create a list of items to remove
    List<DataObject> listToRemove = new ArrayList<DataObject>();
    // for(Iterator<DataObject> i = existingList.iterator(); i.hasNext();) {
    // listToRemove.add(i.next());
    // }
    int sizeListToRemove = listToRemove.size();
    // remove entire list
    existingList.removeAll(listToRemove);
    assertEquals(sequenceSizeBefore - sizeListToRemove, aSequence.size());
    assertEquals(listSizeBefore - sizeListToRemove, existingList.size());
// are we removed on the DataObject?
// DataObject item1ObjectFromAfterRemove = (DataObject)root.get(PO_SEQUENCE_PATH + "/item[1]");
// TODO: verify delete or dont delete after a sequence.remove
// assertTrue(item1ObjectFromAfterRemove == itemDO1);
// assertFalse(item1ObjectFromAfterRemove == itemDO2);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) ArrayList(java.util.ArrayList) ListWrapper(org.eclipse.persistence.sdo.helper.ListWrapper) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 5 with SDOSequence

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

the class SDOSequenceTestXSD method test_voidReturnFrom_add_int_String.

/**
 * @deprecated replaced by {@link #addText(int, String)} in 2.1.0
 */
@Deprecated
public void test_voidReturnFrom_add_int_String() {
    defineAndLoadRoot(false, false);
    SDOSequence aSequence = getSequence(root, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
    DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
    int textIndexToPlaceAtEnd = aSequence.size();
    int treeSizeBeforeAdd = preOrderTraversalDataObjectList(po).size();
    assertEquals(PO_TREE_SIZE, treeSizeBeforeAdd);
    aSequence.add(textIndexToPlaceAtEnd, "random text");
    Object addText = aSequence.getValue(textIndexToPlaceAtEnd);
    assertNotNull(addText);
    assertNull(aSequence.getProperty(textIndexToPlaceAtEnd));
    assertEquals(PO_SEQUENCE_TREE_SIZE + 1, aSequence.size());
    // verify that DataObject has not changed
    int treeSizeAfterAdd = preOrderTraversalDataObjectList(po).size();
    assertEquals(treeSizeBeforeAdd, treeSizeAfterAdd);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Aggregations

SDOSequence (org.eclipse.persistence.sdo.SDOSequence)211 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)178 DataObject (commonj.sdo.DataObject)176 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)93 Property (commonj.sdo.Property)75 ListWrapper (org.eclipse.persistence.sdo.helper.ListWrapper)73 ArrayList (java.util.ArrayList)46 SDOException (org.eclipse.persistence.exceptions.SDOException)37 Sequence (commonj.sdo.Sequence)15 List (java.util.List)10 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)8 Iterator (java.util.Iterator)7 ChangeSummary (commonj.sdo.ChangeSummary)6 SDOType (org.eclipse.persistence.sdo.SDOType)4 Map (java.util.Map)2 TypeHelper (commonj.sdo.helper.TypeHelper)1 HashMap (java.util.HashMap)1 XMLConversionManager (org.eclipse.persistence.internal.oxm.XMLConversionManager)1 XMLRoot (org.eclipse.persistence.oxm.XMLRoot)1 XMLUnmarshaller (org.eclipse.persistence.oxm.XMLUnmarshaller)1