Search in sources :

Example 26 with Sequence

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

the class ChangeSummaryGetOldSequenceTestCases method testGetOldSequenceAndOldValueAreEqual.

public void testGetOldSequenceAndOldValueAreEqual() {
    cs.beginLogging();
    DataObject lineItem1 = (DataObject) itemsObject.getList("item").get(0);
    assertNotNull(lineItem1);
    lineItem1.delete();
    Sequence oldSeq1 = cs.getOldSequence(itemsObject);
    assertNotNull(oldSeq1);
    Object seqFirstOldValue = oldSeq1.getValue(0);
    ChangeSummary.Setting itemOldSetting = cs.getOldValue(itemsObject, itemsObject.getInstanceProperty("item"));
    assertNotNull(itemOldSetting);
    Object firstValue = ((List) itemOldSetting.getValue()).get(0);
    assertEquals(seqFirstOldValue, firstValue);
}
Also used : DataObject(commonj.sdo.DataObject) DataObject(commonj.sdo.DataObject) List(java.util.List) ArrayList(java.util.ArrayList) Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence) ChangeSummary(commonj.sdo.ChangeSummary)

Example 27 with Sequence

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

the class ChangeSummaryGetOldSequenceTestCases method testGetOldSequenceUnchanged.

public void testGetOldSequenceUnchanged() {
    cs.beginLogging();
    // if the sequence has not changed return the current sequence
    Sequence oldSeq = cs.getOldSequence(address1Object);
    assertNotNull(oldSeq);
    assertEquals(4, ((SDOSequence) oldSeq).getSettings().size());
    assertEquals("name", oldSeq.getProperty(0).getName());
    assertEquals("street", oldSeq.getProperty(1).getName());
    assertEquals("city", oldSeq.getProperty(2).getName());
    assertEquals("state", oldSeq.getProperty(3).getName());
    assertEquals("Alice Smith", oldSeq.getValue(0));
    assertEquals("123 Maple Street", oldSeq.getValue(1));
    assertEquals("Mill Valley", oldSeq.getValue(2));
    assertEquals("CA", oldSeq.getValue(3));
}
Also used : Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Example 28 with Sequence

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

the class ChangeSummaryXSDwSeqTestCases method testAddUnstructuredTextAffectsChangeSummaryUndo.

// modify sequence without modifying container and undo
public void testAddUnstructuredTextAffectsChangeSummaryUndo() {
    DataObject shipToDO = rootObject.getDataObject("shipTo");
    // Property containmentProp = shipToDO.getInstanceProperty("yard");
    DataObject yardDO = shipToDO.getDataObject("yard");
    // Object length = yardDO.get("length");
    cs.beginLogging();
    Sequence aSequence = shipToDO.getSequence();
    // modify sequence without modifying container dataObject
    // int yardIndex = getNthSequenceIndexFor((SDOSequence)aSequence, "yard");
    // aSequence.remove(yardIndex);
    // yardDO.detach();
    aSequence.addText("Unstructured1");
    List yardDOSettings = cs.getOldValues(yardDO);
    // no change to container when unstructured text is added
    // TODO: is this the case? adding unstructured text
    // should cause the data object to be considered 'modified'
    assertEquals(0, yardDOSettings.size());
    assertTrue(cs.isModified(shipToDO));
    // assertDetached(yardDO, cs);
    // assertModified(shipToDO, cs);
    assertFalse(cs.isModified(yardDO));
    // TODO: since "addText()" now sets modified on the dataObject, we will
    // have a changed dataObject.  Verify this...
    // assertEquals(0, cs.getChangedDataObjects().size());
    assertEquals(1, cs.getChangedDataObjects().size());
    // return yardDOSettings;
    // check oldSequence before undo
    Sequence shipToSeqBefore = cs.getOldSequence(shipToDO);
    assertNotNull(shipToSeqBefore);
    cs.undoChanges();
    // check oldSequence after undo
    Sequence shipToSeqAfter = cs.getOldSequence(shipToDO);
    assertNotNull(shipToSeqAfter);
    // verify that object references in settings are the same ones on the valueStore
    assertFalse(cs.isDeleted(yardDO));
    // if we add new logic
    assertFalse(cs.isModified(shipToDO));
    // assertTrue(cs.isModified(shipToDO)); // see bug# 5882923 - we should clear the setting here
    assertFalse(cs.isModified(yardDO));
    // if we add new logic
    assertEquals(0, cs.getChangedDataObjects().size());
    // assertEquals(1, cs.getChangedDataObjects().size());//just shipTo
    assertEquals(14, ((SDOChangeSummary) cs).getOldContainer().size());
    assertEquals(14, ((SDOChangeSummary) cs).getOldContainmentProperty().size());
    List shipToSettings = cs.getOldValues(shipToDO);
    // 20070214: modified from 1
    assertEquals(0, shipToSettings.size());
    yardDOSettings = cs.getOldValues(yardDO);
    // see cs.getOldValues() does not return and empty List when yardDO is !modified and !deleted (but !created as well) - (re)set
    // was 3 before we implemented undoChanges()
    assertEquals(0, yardDOSettings.size());
    // see cs.getOldValue() does not return null when yardDO is !modified and !deleted (but !created as well) - (re)set
    ChangeSummary.Setting lengthSetting = cs.getOldValue(yardDO, yardDO.getInstanceProperty("length"));
    // assertNotNull(lengthSetting);
    assertNull(lengthSetting);
// assertEquals(length, lengthSetting.getValue());
// writeXML(rootObject);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) ArrayList(java.util.ArrayList) List(java.util.List) Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence) ChangeSummary(commonj.sdo.ChangeSummary) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary)

Example 29 with Sequence

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

the class ChangeSummaryXSDwSeqTestCases method testDetachYardDOViaContainerAndUndo.

public void testDetachYardDOViaContainerAndUndo() {
    DataObject shipToDO = rootObject.getDataObject("shipTo");
    // Property containmentProp = shipToDO.getInstanceProperty("yard");
    DataObject yardDO = shipToDO.getDataObject("yard");
    Object length = yardDO.get("length");
    cs.beginLogging();
    yardDO.detach();
    List yardDOSettings = cs.getOldValues(yardDO);
    assertEquals(3, yardDOSettings.size());
    assertDetached(yardDO, cs);
    assertModified(shipToDO, cs);
    assertFalse(cs.isModified(yardDO));
    assertEquals(2, cs.getChangedDataObjects().size());
    // return yardDOSettings;
    // check oldSequence before undo
    Sequence shipToSeqBefore = cs.getOldSequence(shipToDO);
    assertNotNull(shipToSeqBefore);
    cs.undoChanges();
    // check oldSequence after undo
    Sequence shipToSeqAfter = cs.getOldSequence(shipToDO);
    assertNotNull(shipToSeqAfter);
    // different sequences in originalSequences
    assertFalse(shipToSeqBefore == shipToSeqAfter);
    // different settings in originalSequences
    assertFalse(((SDOSequence) shipToSeqBefore).getSettings().get(0) == ((SDOSequence) shipToSeqAfter).getSettings().get(0));
    // verify that object references in settings are the same ones on the valueStore
    assertFalse(cs.isDeleted(yardDO));
    // if we add new logic
    assertFalse(cs.isModified(shipToDO));
    // assertTrue(cs.isModified(shipToDO)); // see bug# 5882923 - we should clear the setting here
    assertFalse(cs.isModified(yardDO));
    // if we add new logic
    assertEquals(0, cs.getChangedDataObjects().size());
    // assertEquals(1, cs.getChangedDataObjects().size());//just shipTo
    assertEquals(14, ((SDOChangeSummary) cs).getOldContainer().size());
    assertEquals(14, ((SDOChangeSummary) cs).getOldContainmentProperty().size());
    List shipToSettings = cs.getOldValues(shipToDO);
    // 20070214: modified from 1
    assertEquals(0, shipToSettings.size());
    yardDOSettings = cs.getOldValues(yardDO);
    // see cs.getOldValues() does not return and empty List when yardDO is !modified and !deleted (but !created as well) - (re)set
    // was 3 before we implemented undoChanges()
    assertEquals(0, yardDOSettings.size());
    // see cs.getOldValue() does not return null when yardDO is !modified and !deleted (but !created as well) - (re)set
    ChangeSummary.Setting lengthSetting = cs.getOldValue(yardDO, yardDO.getInstanceProperty("length"));
    // assertNotNull(lengthSetting);
    assertNull(lengthSetting);
// assertEquals(length, lengthSetting.getValue());
// writeXML(rootObject);
}
Also used : SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) ArrayList(java.util.ArrayList) List(java.util.List) Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence) ChangeSummary(commonj.sdo.ChangeSummary) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary)

Example 30 with Sequence

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

the class ChangeSummaryGetOldSequenceTestCases method testGetOldSequenceWithText.

public void testGetOldSequenceWithText() {
    assertEquals(4, address1Object.getSequence().size());
    address1Object.getSequence().addText("abc");
    assertEquals(5, address1Object.getSequence().size());
    cs.beginLogging();
    address1Object.getSequence().addText("def");
    assertEquals(6, address1Object.getSequence().size());
    assertEquals("def", (String) address1Object.getSequence().getValue(5));
    Sequence oldSeq = cs.getOldSequence(address1Object);
    assertNotNull(oldSeq);
    assertEquals(5, oldSeq.size());
    assertEquals("abc", (String) oldSeq.getValue(4));
}
Also used : Sequence(commonj.sdo.Sequence) SDOSequence(org.eclipse.persistence.sdo.SDOSequence)

Aggregations

Sequence (commonj.sdo.Sequence)32 SDOSequence (org.eclipse.persistence.sdo.SDOSequence)29 DataObject (commonj.sdo.DataObject)18 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)12 List (java.util.List)10 ArrayList (java.util.ArrayList)8 ChangeSummary (commonj.sdo.ChangeSummary)7 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)6 SDOType (org.eclipse.persistence.sdo.SDOType)4 Property (commonj.sdo.Property)3 DataHelper (commonj.sdo.helper.DataHelper)1 TypeHelper (commonj.sdo.helper.TypeHelper)1 Iterator (java.util.Iterator)1 SDOException (org.eclipse.persistence.exceptions.SDOException)1 XMLConversionManager (org.eclipse.persistence.internal.oxm.XMLConversionManager)1 XMLRoot (org.eclipse.persistence.oxm.XMLRoot)1 XMLUnmarshaller (org.eclipse.persistence.oxm.XMLUnmarshaller)1 SequencedObject (org.eclipse.persistence.oxm.sequenced.SequencedObject)1 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)1 ListWrapper (org.eclipse.persistence.sdo.helper.ListWrapper)1