[ 
https://issues.apache.org/jira/browse/TUSCANY-1216?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kelvin Goodson updated TUSCANY-1216:
------------------------------------

    Affects Version/s:     (was: Java-SDO-beta1)
                       Java-SDO-M2

> Sequence.add(index,value) is not working due to a type mismatch problem
> -----------------------------------------------------------------------
>
>                 Key: TUSCANY-1216
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1216
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-M2
>         Environment: n/a
>            Reporter: David T. Adcox
>             Fix For: Java-SDO-beta1
>
>
> The sample below demonstrates a problem found when adding properties into a 
> sequence object using the property index.  The issue seems to be related to 
> how the property index is acquired and how that index is subsequently used by 
> the BasicSequence object.  BasicSequence.add(int, Object) uses the EMF 
> eClass().getEstructuralFeature(int) method to retrieve the property, based on 
> the index.  The list of properties kept in this array, includes both 
> 'explicit' properties defined by the schema or inline code, and 'implicit' 
> properties defined by the Tuscany SDO framework (in this case, I believe it 
> is actually the underlying EMF that is creating the implicit property).  Once 
> such implicit property is the 'multi' property, defined when a type is 
> identified as containing a sequence.  The core issue here is that the code 
> used to identify the index to use is based on an array of SDO properties, 
> which do not include the implicit properties.  So, the index is derived from 
> a different array than the one being used for updating, this is the root 
> cause of this problem.  A change to how the BasicSequence object obtains the 
> indexed property is probably the correct remedy for this issue.
> Sample code:
>     public static void main(String[] args) 
>     {
>         String URI = "http://example.com/test";;
>         
>         HelperContext scope = SDOUtil.createHelperContext();
>         TypeHelper typeHelper = scope.getTypeHelper();
>         Type integerType = typeHelper.getType("commonj.sdo", "Integer");
>             
>         DataObject wrapperType = scope.getDataFactory().create("commonj.sdo", 
> "Type");
>         wrapperType.set("uri", URI );
>         wrapperType.set("name", "Wrapper");
>         wrapperType.setBoolean("sequenced", true);
>             
>         // Create Property
>         DataObject intProperty = wrapperType.createDataObject("property");
>         intProperty.set("name", "Value");
>         intProperty.set("type", integerType);
>         intProperty.setBoolean("many", true);
>         
>         // register the wrapper
>         typeHelper.define(wrapperType);
>             
>         // get registered type
>         Type testType = typeHelper.getType(URI,"Wrapper");
>             
>         // Create an instance of the Wrapper Type
>         DataObject testDO = scope.getDataFactory().create(testType);
>         // Update the sequence using the index
>         List properties = testType.getProperties();
>         int index = properties.indexOf(testDO.getInstanceProperty("Value"));
>         Sequence sequence = testDO.getSequence();
>         Integer v = new Integer(10);
>         sequence.add(index,v);
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to