You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by kelvin goodson <ke...@gmail.com> on 2007/08/07 14:36:38 UTC

Re: Dynamic Type Definition...

I think you need the fix in
https://issues.apache.org/jira/browse/TUSCANY-1408 that is part of the
1.0-incubating release which is currently being voted on.

Regards, Kelvin.

On 25/07/07, Upeka Bulumulle <ca...@gmail.com> wrote:
> 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$InternalSettingDelegateMany.dynamicSet
> (EStructuralFeatureImpl.java:1647)
>     at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(BasicEObjectImpl.java:709)
>     at
> org.apache.tuscany.sdo.impl.DynamicDataObjectImpl.eDynamicSet(DynamicDataObjectImpl.java
> :150)
>     at
> org.apache.tuscany.sdo.impl.DataObjectImpl.eSet(DataObjectImpl.java:1442)
>     at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:654)
>     at org.apache.tuscany.sdo.impl.DataObjectImpl.set
> (DataObjectImpl.java:143)
>     at
> org.apache.tuscany.sdo.util.DataObjectUtil.setInt(DataObjectUtil.java:532)
>     at
> org.apache.tuscany.sdo.impl.DataObjectImpl.setInt(DataObjectImpl.java:526)
>
> (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:
> tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org