Search in sources :

Example 6 with SDOSequence

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

the class SDOSequenceTestXSD method testEqualDeepComplexManySequence.

public void testEqualDeepComplexManySequence() {
    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);
    // test equalityHelper
    DataObject poCopy = (DataObject) rootCopy.get(PO_SEQUENCE_PATH);
    boolean bEqual = equalityHelper.equal(po, poCopy);
    assertTrue(bEqual);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 7 with SDOSequence

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

the class SDOSequenceTestXSD method testMoveIndexFromOutOfBoundsHigh.

public void testMoveIndexFromOutOfBoundsHigh() {
    defineAndLoadRoot(false, false);
    DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
    assertNotNull(po);
    assertTrue(po.getType().isSequenced());
    SDOSequence aSequence = (SDOSequence) po.getSequence();
    // move 2 sequenced objects
    Property beforeMoveProp1 = aSequence.getProperty(1);
    assertNotNull(beforeMoveProp1);
    boolean exceptionThrown = false;
    try {
        aSequence.move(99, 1);
    } catch (SDOException e) {
        // catch error
        assertEquals(SDOException.INVALID_INDEX, e.getErrorCode());
        exceptionThrown = true;
    }
    Property afterMoveProp1 = aSequence.getProperty(1);
    // verify the move did not take place
    assertTrue(beforeMoveProp1 == afterMoveProp1);
    assertTrue(exceptionThrown);
}
Also used : SDOException(org.eclipse.persistence.exceptions.SDOException) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDOProperty(org.eclipse.persistence.sdo.SDOProperty) Property(commonj.sdo.Property) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 8 with SDOSequence

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

the class SDOSequenceTestXSD method testRemoveDoesDeleteDataObjectPropertyValue.

// TODO: Issue resolution 20070403-1: is remove local to Sequence - no
public void testRemoveDoesDeleteDataObjectPropertyValue() {
    defineAndLoadRoot(false, false);
    SDOSequence aSequence = getSequence(root, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
    DataObject shipToDO = (DataObject) root.get(PO_SEQUENCE_PATH + "/shipTo");
    assertNotNull(shipToDO);
    // get shipTo sequence
    int shipToSequenceIndex = getNthSequenceIndexFor(aSequence, "shipTo");
    assertTrue(shipToSequenceIndex > -1);
    DataObject shipToObjectFromSetting = (DataObject) aSequence.getValue(shipToSequenceIndex);
    assertNotNull(shipToObjectFromSetting);
    assertTrue(shipToObjectFromSetting == shipToDO);
    // delete po[1]/shipTo from setting
    aSequence.remove(shipToSequenceIndex);
    // are we removed on the DataObject?
    DataObject shipToObjectFromAfterRemove = (DataObject) root.get(PO_SEQUENCE_PATH + "/shipTo");
    assertNull(shipToObjectFromAfterRemove);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 9 with SDOSequence

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

the class SDOSequenceTestXSD method testAddOpenContentPropertyViaDataObject.

public void testAddOpenContentPropertyViaDataObject() {
    // 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
    root.set(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(sequenceSizeBefore);
    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 10 with SDOSequence

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

the class SDOSequenceTestXSD method test_booleanReturnFrom_add_Property_Object_WhereValuePassedIsSingleItemInEmptyList.

/**
 * Test setting a many property using a single item of a list instead of passing a
 * ListWrapper as usual.
 * The existing list will need to be null (not an empty ListWrapper)
 */
public void test_booleanReturnFrom_add_Property_Object_WhereValuePassedIsSingleItemInEmptyList() {
    // Property property, Object value) {
    defineAndLoadRoot(false, false);
    SDOSequence aSequence = getSequence(root, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
    DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
    int treeSizeBeforeAdd = preOrderTraversalDataObjectList(po).size();
    assertEquals(PO_TREE_SIZE, treeSizeBeforeAdd);
    assertEquals(PO_SEQUENCE_SIZE, aSequence.size());
    int listSizeBefore = ((ListWrapper) po.get("item")).size();
    assertEquals(2, listSizeBefore);
    int indexToPlaceAtEnd = aSequence.size();
    // object to add
    DataObject item2 = (DataObject) root.get("item[2]");
    assertNotNull(item2);
    Property itemProperty = po.getInstanceProperty("item");
    // add to sequence
    aSequence.add(itemProperty, item2);
    // get back new Setting value
    // ListWrapper item2Value = (ListWrapper)aSequence.getValue(indexToPlaceAtEnd);
    SDODataObject item2Value = (SDODataObject) aSequence.getValue(indexToPlaceAtEnd);
    assertNotNull(item2Value);
    assertNotNull(aSequence.getProperty(indexToPlaceAtEnd));
    // check increased size of sequence
    assertEquals(PO_SEQUENCE_TREE_SIZE + 1, aSequence.size());
    // verify that the list has increased
    int listSizeAfter = ((ListWrapper) po.get("item")).size();
    assertEquals(listSizeBefore + 1, listSizeAfter);
    // verify that DataObject has changed
    int treeSizeAfterAdd = preOrderTraversalDataObjectList(po).size();
    assertEquals(treeSizeBeforeAdd + 1, treeSizeAfterAdd);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) ListWrapper(org.eclipse.persistence.sdo.helper.ListWrapper) SDOProperty(org.eclipse.persistence.sdo.SDOProperty) Property(commonj.sdo.Property) SDOSequence(org.eclipse.persistence.sdo.SDOSequence) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

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