I think the problem is that when you set many=true then the attribute
becomes a list rather than a bare type (otherwise there is no way to add
multiple attributes). You need to do:
List<int> custNum = new ArrayList();
custNum.add(1000);
createdDO.setList("custNum", custNum);
I didn't see the custNum element in your XSD so I don't know if you want
to do the above or remove the many=true property.
Dean.
> -----Original Message-----
> From: Upeka Bulumulle [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 26 July 2007 4:21 AM
> To: [email protected]; [EMAIL PROTECTED]
> Subject: Dynamic Type Definition...
>
> Hi All,
>
> Tuscany SDO version: Tuscany SDO 1.0 beta1.
>
> I'm trying to dynamically create and use types without the use of an
XSD
> file. What i want to do is something a little different to what is
> described in the samples provided. I want to have elements within each
> nested type. i also want to to be able to support lists (String lists,
> Interger lists etc).
>
> My dynamically defined XSD should look like this (complete xsd is
> attached...),
>
> <xsd:element name="dataType" type="DataType"/>
> <xsd:complexType name="DataType">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
name="item"
> type="ItemType"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
name="list"
> type="ListItemType"/>
> </xsd:sequence>
> </xsd:complexType>
> <xsd:complexType name="ItemType">
> <xsd:sequence>
> <xsd:element name="type" type="xsd:string"/>
> <xsd:element name="name" type="xsd:string"/>
> <xsd:element name="boolean" type="xsd:boolean"/>
> </xsd:sequence>
> <xsd:complexType name="ListItemType">
> <xsd:sequence>
> <xsd:element name="listType" type= "xsd:string"/>
> <xsd:element name="listName" type= "xsd:string"/>
> <xsd:element name="booleanList" type= "BooleanListType"/>
> </xsd:sequence>
> </xsd:complexType>
> <xsd:complexType name="BooleanListType">
> <xsd:sequence>
> <xsd:element maxOccurs="unbounded" minOccurs= "0"
> name="booleanValue" type="xsd:boolean"/ >
> </xsd:sequence>
> </xsd:complexType>
>
> I added the many true option when creating the property for each data
> object which resulted in type, name and boolean resulting in elements.
> // create data graph root
> DataGraph dataGraph = SDOUtil.createDataGraph();
> DataObject dynamic = dataGraph.createRootObject("commonj.sdo",
> "Type");
> dynamic.set("uri", "http://www.dynamic.com/dynamic ");
> dynamic.set("name", "DataType");
> dynamic.set("dataType", false);
>
> // primitive type.. ints
> DataObject custNumProperty = dynamic.createDataObject
> ("property");
> custNumProperty.set("name", "custNum");
> custNumProperty.set("type", intType);
> custNumProperty.set("many", true);
>
> However i am unable set values to the data object once i do this.I get
the
> following stack trace when i do this,
> DataObject createdDO =
> DataFactory.INSTANCE.create("http://www.dynamic.com/dynamic",
"DataType");
> createdDO.setInt("custNum", 1000);
>
> java.lang.ClassCastException: java.lang.Integer
> at org.eclipse.emf.ecore.util.EcoreEList.set(EcoreEList.java:448)
> at
>
org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegat
eM
> any.dynamicSet (EStructuralFeatureImpl.java:1647)
> at
>
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(BasicEObjectImpl
.j
> ava:709)
> at
>
org.apache.tuscany.sdo.impl.DynamicDataObjectImpl.eDynamicSet(DynamicDat
aO
> bjectImpl.java :150)
> at
>
org.apache.tuscany.sdo.impl.DataObjectImpl.eSet(DataObjectImpl.java:1442
)
> at
>
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:6
54
> )
> at org.apache.tuscany.sdo.impl.DataObjectImpl.set
> (DataObjectImpl.java:143)
> at
>
org.apache.tuscany.sdo.util.DataObjectUtil.setInt(DataObjectUtil.java:53
2)
> at
>
org.apache.tuscany.sdo.impl.DataObjectImpl.setInt(DataObjectImpl.java:52
6)
>
> (if i leave out the many true flag, then the xsd displays them as
> attributes and i am able to set values to them)
>
> My code is attached for your review.
>
> I would appreciate your help in this regard. The reason i want to
> dynamically define the type is because my client requires high
performant
> code. The time taken to execute the dynamic xsd is quite less compared
to
> the time taken to read the xsd. Almost a whole second.
>
> Thanks and regards
> Roshan
>
> The samples provide an example where the dynamically defined types
result
> in attributes and not elements.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]