Bug 203519 - Data set properties are not accessible from an ISciprtedDataSetEventHandler
Summary: Data set properties are not accessible from an ISciprtedDataSetEventHandler
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 2.2.0   Edit
Hardware: PC Windows XP
: P3 enhancement with 1 vote (vote)
Target Milestone: Future   Edit
Assignee: Mingxia Wu CLA
QA Contact:
URL:
Whiteboard:
Keywords: plan
Depends on:
Blocks:
 
Reported: 2007-09-15 13:38 EDT by Ivan Biddles CLA
Modified: 2010-05-06 03:11 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Biddles CLA 2007-09-15 13:38:19 EDT
Build ID: 3.3.0   I20070625-1500

Steps To Reproduce:
1. Write an event handler that implements IScriptedDataSetEventHandler
2. Create a report design using your scripted data set and set some properties like "comments" and "customXml".
3. Put a breakpoint in the describe method and run the report in the debugger.
4. When the breakpoint is hit, note that by expanding the attributes of the IDataSetInstance you can see the "propValues" map and that the properties and their values are in that map.
5. Note that you cannot get to the property map from the IDataSetInstance because there are no accessible methods to do so.


More information:
It should be possible to request the value of a data set property from the IDataSetInstance argument directly, with a getPropertyValue method, for example.

The following reflection-based code that specifically forces inaccessible attributes to be accessible, does get to the property map, proving that the data is indeed there: 

/* =============================================================== */
public  boolean  describe
                 (
                  IDataSetInstance          aIDataSetInstance,
                  IScriptedDataSetMetadata  aIScriptedDataSetMetadata
                 )
{
   Map<String,Object> myPropertyMap = getPropertyMap (aIDataSetInstance);
   . . .
}

/* =============================================================== */
protected Map<String,Object> getPropertyMap
                             (
                              IDataSetInstance  aIDataSetInstance
                             )
{
   try {
      Object myObject = aIDataSetInstance;

      myObject = getFieldObject (myObject, myObject.getClass (),
                                           "dataSet");
      myObject = getFieldObject (myObject, myObject.getClass (), 
                                           "scriptEventHandler");
      myObject = getFieldObject (myObject, myObject.getClass (), 
                                           "dataSetHandle");
      myObject = getFieldObject (myObject, myObject.getClass (),
                                           "element");
      myObject = getFieldObject (myObject, myObject.getClass (),
                                           "propValues");

      return ((Map<String,Object>) myObject);
   }
   catch (Throwable myThrowable) {
      return (null);
   }
}

/* =============================================================== */
protected Object getFieldObject (
                                 Object    aParentObject,
                                 Class<?>  aParentObject,
                                 String    aFieldName
                                )
{
   Object myObject = null;

   try {
      Field myField = aParentClass.getDeclaredField (aFieldName);
      myField.setAccessible   (true);
      myObject = myField.get (aParentObject);
   }
   catch (Throwable myThrowable) {
      myObject = getFieldObject (
                                 aParentObject,
                                 aParentClass.getSuperclass (),
                                 aFieldName
                                );
   }
   return (myObject);
}
Comment 1 Gary Xue CLA 2008-05-29 20:15:57 EDT
Requires API change. Deferring to next maintenance release.