Bug 107813 - Cannot directly get an aggressively loaded property
Cannot directly get an aggressively loaded property
Status: CLOSED WONTFIX
Product: Red Hat Web Application Framework
Classification: Retired
Component: persistence (Show other bugs)
nightly
All Linux
medium Severity medium
: ---
: ---
Assigned To: ccm-bugs-list
Jon Orris
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-10-23 06:34 EDT by Daniel Berrange
Modified: 2007-04-18 12:58 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-09-02 13:24:42 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Daniel Berrange 2003-10-23 06:34:33 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.2.9 (X11; Linux i686; U;) Gecko/20030314

Description of problem:
Consider we are retrieving a bunch of Event items & we want to aggressive load
the draft item id. We'd use 'addPath' to pull in the masterVersion.id property.
However, we can't then directly 'get' the property we aggressive loaded. (The
m_attributes variable contains a list of properties to add to the XML, eg 'id',
'title', 'masterVersion.id')

 
DataCollection events =
SessionManager.getSession().retrieve(Event.BASE_DATA_OBJECT_TYPE);
events.addPath("masterVersion.id");

while (events.next()) {
    DataObject dobj = events.getDataObject();

    Element eventEl = new Element("cms:event", CMS_XML_NS);

    Iterator attributes = m_attributes.iterator();
    while (attributes.hasNext()) {
        String name = (String)attributes.next();
        Object value = dobj.get(name);
        if (value != null) {
           Element attributeEl = new Element("cms:attribute", CMS_XML_NS);
           attributeEl.addAttribute("name", name);
           attributeEl.setText(XML.format(value));
           eventEl.addContent(attributeEl);
        }
    }
}

The line

  Object value = dobj.get(name);

fails when it gets to 'masterVersion.id', with:

com.arsdigita.persistence.PersistenceException: no such property:
masterVersion.id for [com.arsdigita.cms.contenttypes.Event:{id=41003}]
        at com.arsdigita.persistence.DataObjectImpl.get(DataObjectImpl.java:159)
        at
com.arsdigita.london.navigation.DataCollectionRenderer.generateXML(DataCollectionRenderer.java:122)
        at
com.arsdigita.london.navigation.ui.AbstractObjectList.generateObjectListXML(AbstractObjectList.java:89)
        at
com.arsdigita.london.navigation.ui.object.AtoZObjectList.generateXML(AtoZObjectList.java:120)
        at
com.arsdigita.london.navigation.ui.AbstractComponent.generateXML(AbstractComponent.java:75)
        at
com.arsdigita.bebop.SimpleContainer.generateChildrenXML(SimpleContainer.java:243)
        at com.arsdigita.bebop.SimpleContainer.generateXML(SimpleContainer.java:260)
        at com.arsdigita.bebop.Page.generateXML(Page.java:639)
        at com.arsdigita.bebop.jsp.DefinePage.doEndTag(DefinePage.java:191)


We managed to hack around it by changing the line in question to:


   Object value = dobj;
   String[] paths = StringUtils.split(name, '.');
   for (int i = 0 ; i < paths.length ; i++) {
     value = ((DataObject)value).get(paths[i]);
   }

Ie, it gets the DataObject for 'masterVersion', and then from that gets the 'id'
property. 

The 'get' method should be fixed so that it accepts full paths in the same way
as other methods taking property names - ie 'addOrder', 'addEqualsFilter',
'addPath'.

Archit mentioned that the fix is probably the same as that required for bz 104102

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Get a data collection of Event items
2. add masterVersion.id to the path
3. call get('masterVersion.id') on a data object


Actual Results:  Exception thrown

Expected Results:  The value of masterVersion.is is returned

Additional info:
Comment 1 Daniel Berrange 2006-09-02 13:24:42 EDT
Closing old tickets

Note You need to log in before you can comment on or make changes to this bug.