Search in sources :

Example 96 with Property

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

the class SDOSequenceTestXSD method test_voidReturnFrom_add_int_Property_Object_propertyIsAttribute.

public void test_voidReturnFrom_add_int_Property_Object_propertyIsAttribute() {
    // int index, Property property, Object value) {
    defineAndLoadRoot(false, false);
    // detach shipTo
    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 orderDateProperty = po.getInstanceProperty("orderDate");
    // add to sequence
    try {
        aSequence.add(indexToPlaceAtEnd, orderDateProperty, "1999-10-19");
    } catch (Exception e) {
    }
    // get back new Setting value
    ListWrapper item2Value = null;
    boolean exceptionThrown = false;
    try {
        item2Value = (ListWrapper) aSequence.getValue(indexToPlaceAtEnd);
    } catch (SDOException e) {
        assertEquals(SDOException.INVALID_INDEX, e.getErrorCode());
        exceptionThrown = true;
    }
    assertNull(item2Value);
    assertTrue(exceptionThrown);
}
Also used : SDOException(org.eclipse.persistence.exceptions.SDOException) 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) SDOException(org.eclipse.persistence.exceptions.SDOException)

Example 97 with Property

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

the class XmlElementPropertyTestCases method testPropertyFromDataObjectWithOpenContentPropertySet.

public void testPropertyFromDataObjectWithOpenContentPropertySet() {
    String controlProperty = "CONTROL_PROPERTY";
    String controlValue = "CONTROL_VALUE";
    Type stringType = typeHelper.getType("commonj.sdo", "String");
    DataObject propertyDO = dataFactory.create("commonj.sdo", "Property");
    propertyDO.set("name", "foo");
    propertyDO.set("type", stringType);
    propertyDO.set(controlProperty, controlValue);
    Property property = typeHelper.defineOpenContentProperty("urn:example", propertyDO);
    assertEquals(1, property.getInstanceProperties().size());
}
Also used : Type(commonj.sdo.Type) DataObject(commonj.sdo.DataObject) Property(commonj.sdo.Property)

Example 98 with Property

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

the class XmlElementPropertyTestCases method testPropertyFromDataObjectWithOpenContentPropertySetAndXmlElementPropertySetToTrue.

public void testPropertyFromDataObjectWithOpenContentPropertySetAndXmlElementPropertySetToTrue() {
    String controlProperty = "CONTROL_PROPERTY";
    String controlValue = "CONTROL_VALUE";
    Type stringType = typeHelper.getType("commonj.sdo", "String");
    DataObject propertyDO = dataFactory.create("commonj.sdo", "Property");
    propertyDO.set("name", "foo");
    propertyDO.set("type", stringType);
    propertyDO.set(controlProperty, controlValue);
    propertyDO.set(SDOConstants.XMLELEMENT_PROPERTY, Boolean.TRUE);
    Property property = typeHelper.defineOpenContentProperty("urn:example", propertyDO);
    assertTrue((Boolean) property.get(SDOConstants.XMLELEMENT_PROPERTY));
    assertEquals(2, property.getInstanceProperties().size());
}
Also used : Type(commonj.sdo.Type) DataObject(commonj.sdo.DataObject) Property(commonj.sdo.Property)

Example 99 with Property

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

the class SDOSequenceTestXSD method testAddSimpleSingleAttributeFailsViaSequenceAdd.

public void testAddSimpleSingleAttributeFailsViaSequenceAdd() {
    defineAndLoadRoot(false, false);
    SDOSequence aSequence = getSequence(root, CUSTOMER_PATH, PO_SEQUENCE_SIZE);
    DataObject cust = (DataObject) root.get(CUSTOMER_PATH);
    Property custProperty = cust.getInstanceProperty("custID");
    int errorCode = -1;
    try {
        aSequence.add(custProperty, "0001");
    } catch (SDOException e) {
        errorCode = e.getErrorCode();
    }
    assertEquals(SDOException.SEQUENCE_ERROR_PROPERTY_IS_ATTRIBUTE, errorCode);
}
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 100 with Property

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

the class SDOSequenceTestXSD method testMoveSameIndex.

public void testMoveSameIndex() {
    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);
    aSequence.move(1, 1);
    Property afterMoveProp1 = aSequence.getProperty(1);
    assertTrue(beforeMoveProp1 == afterMoveProp1);
}
Also used : 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)

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