Search in sources :

Example 26 with Property

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

the class ChangeSummaryTestCases method testDataTypePropertyWasNotSetXML.

public void testDataTypePropertyWasNotSetXML() throws IOException {
    Type rootType = jaxbHelperContext.getType(Root.class);
    Property controlDataTypeProperty = rootType.getProperty(CONTROL_DATATYPE_PROPERTY);
    InputStream xml = Thread.currentThread().getContextClassLoader().getResourceAsStream(XML_DATA_TYPE_PROPERTY_WAS_NOT_SET);
    DataObject rootDO = jaxbHelperContext.getXMLHelper().load(xml).getRootObject();
    assertEquals(CONTROL_DATATYPE_PROPERTY_NEW_VALUE, rootDO.get(controlDataTypeProperty));
    ChangeSummary.Setting setting = rootDO.getChangeSummary().getOldValue(rootDO, controlDataTypeProperty);
    String testOldValue = (String) setting.getValue();
    assertEquals(null, testOldValue);
    assertEquals(false, setting.isSet());
}
Also used : Type(commonj.sdo.Type) DataObject(commonj.sdo.DataObject) InputStream(java.io.InputStream) ChangeSummary(commonj.sdo.ChangeSummary) Property(commonj.sdo.Property)

Example 27 with Property

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

the class ContainmentTestCases method testCollectionMove1.

public void testCollectionMove1() {
    Type rootType = jaxbHelperContext.getTypeHelper().getType("urn:containment", "root");
    Property childManyProperty = rootType.getProperty("child-many");
    DataObject root1DO = jaxbHelperContext.getDataFactory().create(rootType);
    DataObject childDO = root1DO.createDataObject(childManyProperty);
    assertFalse(root1DO.getList(childManyProperty).isEmpty());
    DataObject root2DO = jaxbHelperContext.getDataFactory().create(rootType);
    assertTrue(root2DO.getList(childManyProperty).isEmpty());
    root2DO.getList(childManyProperty).add(childDO);
    assertTrue(root1DO.getList(childManyProperty).isEmpty());
    assertFalse(root2DO.getList(childManyProperty).isEmpty());
}
Also used : Type(commonj.sdo.Type) DataObject(commonj.sdo.DataObject) Property(commonj.sdo.Property)

Example 28 with Property

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

the class ContainmentTestCases method testCollectionMove2.

public void testCollectionMove2() {
    Type rootType = jaxbHelperContext.getTypeHelper().getType("urn:containment", "root");
    Property childManyProperty = rootType.getProperty("child-many");
    Root root1 = new Root();
    Child child = new Child();
    ArrayList children = new ArrayList(1);
    children.add(child);
    root1.setChildCollectionProperty(children);
    assertFalse(root1.getChildCollectionProperty().isEmpty());
    Root root2 = new Root();
    root2.setChildCollectionProperty(new ArrayList(1));
    assertTrue(root2.getChildCollectionProperty().isEmpty());
    DataObject root1DO = jaxbHelperContext.wrap(root1);
    DataObject root2DO = jaxbHelperContext.wrap(root2);
    DataObject childDO = (DataObject) root1DO.getList(childManyProperty).get(0);
    root2DO.getList(childManyProperty).add(childDO);
    assertTrue(root1DO.getList(childManyProperty).isEmpty());
    assertFalse(root2DO.getList(childManyProperty).isEmpty());
}
Also used : Type(commonj.sdo.Type) DataObject(commonj.sdo.DataObject) ArrayList(java.util.ArrayList) Property(commonj.sdo.Property)

Example 29 with Property

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

the class ContainmentTestCases method testGetContainer.

public void testGetContainer() {
    Root root = new Root();
    Child child = new Child();
    root.setChildProperty(child);
    Type rootType = jaxbHelperContext.getTypeHelper().getType("urn:containment", "root");
    Property childProperty = rootType.getProperty("child");
    DataObject rootDO = jaxbHelperContext.wrap(root);
    DataObject childDO = rootDO.getDataObject(childProperty);
    DataObject containerDO = childDO.getContainer();
    assertNotNull(containerDO);
    assertSame(rootDO, containerDO);
    Property containmentProperty = childDO.getContainmentProperty();
    assertNotNull(containmentProperty);
    assertSame(childProperty, containmentProperty);
}
Also used : Type(commonj.sdo.Type) DataObject(commonj.sdo.DataObject) Property(commonj.sdo.Property)

Example 30 with Property

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

the class ContainmentTestCases method testMove2.

public void testMove2() {
    Type rootType = jaxbHelperContext.getTypeHelper().getType("urn:containment", "root");
    Property childProperty = rootType.getProperty("child");
    Root root1 = new Root();
    Child child = new Child();
    root1.setChildProperty(child);
    assertNotNull(root1.getChildProperty());
    Root root2 = new Root();
    assertNull(root2.getChildProperty());
    DataObject root1DO = jaxbHelperContext.wrap(root1);
    DataObject root2DO = jaxbHelperContext.wrap(root2);
    root2DO.set(childProperty, root1DO.get(childProperty));
    assertNotNull(root2DO.get(childProperty));
    assertNull(root1DO.get(childProperty));
}
Also used : Type(commonj.sdo.Type) DataObject(commonj.sdo.DataObject) Property(commonj.sdo.Property)

Aggregations

Property (commonj.sdo.Property)354 DataObject (commonj.sdo.DataObject)204 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)194 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)124 List (java.util.List)99 Type (commonj.sdo.Type)87 SDOSequence (org.eclipse.persistence.sdo.SDOSequence)76 ArrayList (java.util.ArrayList)73 ChangeSummary (commonj.sdo.ChangeSummary)56 SDOType (org.eclipse.persistence.sdo.SDOType)54 ListWrapper (org.eclipse.persistence.sdo.helper.ListWrapper)47 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)37 SDOException (org.eclipse.persistence.exceptions.SDOException)35 Iterator (java.util.Iterator)24 QName (javax.xml.namespace.QName)12 InputStream (java.io.InputStream)11 SDOSetting (org.eclipse.persistence.sdo.SDOSetting)11 Map (java.util.Map)5 XMLDocument (commonj.sdo.helper.XMLDocument)4 SequencedObject (org.eclipse.persistence.oxm.sequenced.SequencedObject)4