Search in sources :

Example 26 with SDOSequence

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

the class SDOSequenceTestCS method testDetachAlsoRemovesSequenceSetting.

public void testDetachAlsoRemovesSequenceSetting() {
    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
    shipToDO.detach();
    // are we removed on the sequence?
    int shipToSequenceIndexAfterDelete = getNthSequenceIndexFor(aSequence, "shipTo");
    assertEquals(NO_MATCH_INDEX, shipToSequenceIndexAfterDelete);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 27 with SDOSequence

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

the class SDOSequenceTestCS method test_SequenceReturnFrom_SDODataObject_getSequence_index_type_complex_many.

/**
 * Returns the value of a <code>Sequence</code> property identified by the specified property index.
 * @param propertyIndex the index of the property.
 * @see #get(int)
 * @deprecated in 2.1.0.
 */
@Deprecated
public void test_SequenceReturnFrom_SDODataObject_getSequence_index_type_complex_many() {
    defineAndLoadRoot(false, false);
    assertNotNull(root);
    // get property index of porder
    int propertyIndex = ((SDOProperty) root.getInstanceProperty(PO_PATH)).getIndexInType();
    // Expect a failure for a complex many property
    boolean exceptionThrown = false;
    int errorCode = -1;
    SDOSequence aSequence = null;
    try {
        aSequence = (SDOSequence) root.getSequence(propertyIndex);
    } catch (SDOException e) {
        exceptionThrown = true;
        errorCode = e.getErrorCode();
    } finally {
        assertTrue(exceptionThrown);
        assertNull(aSequence);
        assertEquals(45022, errorCode);
    }
}
Also used : SDOException(org.eclipse.persistence.exceptions.SDOException) SDOProperty(org.eclipse.persistence.sdo.SDOProperty) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 28 with SDOSequence

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

the class SDOSequenceTestCS method testEqualDeepSameSequence.

public void testEqualDeepSameSequence() {
    defineAndLoadRoot(false, false);
    SDOSequence aSequence = getSequence(root, PO_SEQUENCE_PATH, PO_SEQUENCE_SIZE);
    // compareSequences(aSequence, aSequence, PO_SEQUENCE_SIZE, true);
    // get sequence po
    DataObject po = (DataObject) root.get(PO_SEQUENCE_PATH);
    assertNotNull(po);
    assertTrue(po.getType().isSequenced());
    // test equalityHelper
    boolean bEqual = equalityHelper.equal(po, po);
    assertTrue(bEqual);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 29 with SDOSequence

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

the class SDOSequenceTestCS method testClearComplexManyReferenceByListWrapper.

public void testClearComplexManyReferenceByListWrapper() {
    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());
    ListWrapper existingList = (ListWrapper) po.get("item");
    int listSizeBefore = existingList.size();
    assertEquals(2, listSizeBefore);
    int indexToPlaceAtEnd = aSequence.size();
    // object to add
    DataObject item3 = (DataObject) root.get("item[1]");
    assertNotNull(item3);
    Property itemProperty = po.getInstanceProperty("item");
    // add list of items to existing list
    List<DataObject> aListToAdd = new ArrayList<DataObject>();
    aListToAdd.add(item3);
    aListToAdd.add(item3);
    existingList.clear();
    // verify that the list has decreased on the do
    int listSizeAfter = ((ListWrapper) po.get("item")).size();
    assertEquals(listSizeBefore - aListToAdd.size(), listSizeAfter);
    // verify that the sequence size has decreased
    assertEquals(indexToPlaceAtEnd - aListToAdd.size(), aSequence.size());
    // check decreased size of sequence
    assertEquals(PO_SEQUENCE_TREE_SIZE - aListToAdd.size(), aSequence.size());
    // verify that DataObject has changed
    int treeSizeAfterAdd = preOrderTraversalDataObjectList(po).size();
    assertEquals(treeSizeBeforeAdd - aListToAdd.size(), treeSizeAfterAdd);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) ArrayList(java.util.ArrayList) ListWrapper(org.eclipse.persistence.sdo.helper.ListWrapper) SDOProperty(org.eclipse.persistence.sdo.SDOProperty) Property(commonj.sdo.Property) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 30 with SDOSequence

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

the class SDOSequenceTestCS method test_PropertyReturnFrom_getProperty.

/**
 * Returns the property for the given entry index.
 * Returns <code>null</code> for mixed text entries.
 * @param index the index of the entry.
 */
public void test_PropertyReturnFrom_getProperty() {
    // int index) {
    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() - 1;
    // object to replace
    DataObject item2 = (DataObject) root.get("item[2]");
    assertNotNull(item2);
/*        // add the item to the current list
        ListWrapper existingList = (ListWrapper)aSequence.getValue(indexToPlaceAtEnd);
        assertNotNull(existingList);
        existingList.add(item2);

        boolean exceptionThrown = false;
        Property property1 = po.getInstanceProperty("item");
        Object property1Return = null;
        try {
            property1Return = aSequence.getProperty(indexToPlaceAtEnd);
        } catch (IndexOutOfBoundsException e) {
            exceptionThrown = true;
        } finally {
            assertFalse(exceptionThrown);
        }

        // verify property
        assertNotNull(property1Return);
        assertEquals(property1, property1Return);
*/
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) ListWrapper(org.eclipse.persistence.sdo.helper.ListWrapper) 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