Uploaded image for project: 'Tuscany'
  1. Tuscany
  2. TUSCANY-1216

Sequence.add(index,value) is not working due to a type mismatch problem

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Java-SDO-M2
    • Java-SDO-beta1
    • None
    • n/a

    Description

      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); }

      Attachments

        Activity

          People

            Unassigned Unassigned
            dtadcox David T. Adcox
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: