From: <mb...@re...> - 2004-11-24 16:48:17
|
Author: mbooth Date: 2004-11-24 17:40:33 +0100 (Wed, 24 Nov 2004) New Revision: 124 Added: ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionProperty.java ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionPropertyRenderer.java Modified: ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionDefinition.java ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionRenderer.java Log: Add DataCollectionProperty and family. Modified: ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionDefinition.java =================================================================== --- ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionDefinition.java 2004-11-24 16:39:49 UTC (rev 123) +++ ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionDefinition.java 2004-11-24 16:40:33 UTC (rev 124) @@ -59,6 +59,7 @@ private ArrayList m_ordering = new ArrayList(); private ArrayList m_excludedTypes = new ArrayList(); + private ArrayList m_properties = new ArrayList(); public final void setObjectType(String objectType) { Assert.unlocked(this); @@ -115,6 +116,11 @@ Assert.unlocked(this); m_ordering.add(order); } + + public final void addProperty( DataCollectionProperty property ) { + Assert.unlocked( this ); + m_properties.add( property ); + } public final DataCollection getDataCollection(NavigationModel model) { Assert.locked(this); @@ -124,6 +130,13 @@ applyFilters(objects, model); + Iterator properties = m_properties.iterator(); + while( properties.hasNext() ) { + DataCollectionProperty property = (DataCollectionProperty) + properties.next(); + property.addProperty( objects ); + } + if (m_ordering.size() > 0) { Iterator orders = m_ordering.iterator(); while (orders.hasNext()) { Added: ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionProperty.java =================================================================== --- ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionProperty.java 2004-11-24 16:39:49 UTC (rev 123) +++ ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionProperty.java 2004-11-24 16:40:33 UTC (rev 124) @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.arsdigita.london.navigation; + +import com.arsdigita.persistence.DataCollection; + +/** + * Classes implementing this interface will add a property to a + * <code>DataCollectionDefinition</code>. An example of this might be a + * particular image from <code>imageAttachments</code>. + */ +public interface DataCollectionProperty { + /** + * Called from DataCollectionDefinition. This method will perform any + * necessary steps to add the property to the DataCollection in advance of + * it being fetched. + */ + public void addProperty( DataCollection dc ); +} Added: ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionPropertyRenderer.java =================================================================== --- ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionPropertyRenderer.java 2004-11-24 16:39:49 UTC (rev 123) +++ ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionPropertyRenderer.java 2004-11-24 16:40:33 UTC (rev 124) @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package com.arsdigita.london.navigation; + +import com.arsdigita.persistence.DataCollection; +import com.arsdigita.xml.Element; + +/** + * Classes implementing this interface will render in XML a property which + * will normally have been previously added to a + * <code>DataCollectionDefinition</code>. + */ +public interface DataCollectionPropertyRenderer { + /** + * Called from DataCollectionRenderer for every returned item. This method + * will add XML for the property to the renderer's output. + * + * @param dc A datacollection whose cursor is currently on the item whose + * property is to be renderered. + * @param parent The parent XML Element. + */ + public void render( DataCollection dc, Element parent ); +} Modified: ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionRenderer.java =================================================================== --- ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionRenderer.java 2004-11-24 16:39:49 UTC (rev 123) +++ ccm-ldn-navigation/trunk/src/com/arsdigita/london/navigation/DataCollectionRenderer.java 2004-11-24 16:40:33 UTC (rev 124) @@ -42,6 +42,8 @@ Logger.getLogger(DataCollectionRenderer.class); private ArrayList m_attributes = new ArrayList(); + private ArrayList m_properties = new ArrayList(); + private int m_pageSize = 20; private boolean m_specializeObjects = false; private boolean m_wrapAttributes = false; @@ -56,6 +58,11 @@ m_attributes.add(name); } + public void addProperty(DataCollectionPropertyRenderer pr) { + Assert.unlocked(this); + m_properties.add(pr); + } + public void setPageSize(int pageSize) { Assert.unlocked(this); m_pageSize = pageSize; @@ -126,6 +133,12 @@ String[] paths = StringUtils.split(name, '.'); outputValue( item, dobj, name, paths, 0 ); } + + Iterator properties = m_properties.iterator(); + while( properties.hasNext() ) { + DataCollectionPropertyRenderer property = (DataCollectionPropertyRenderer) properties.next(); + property.render( objects, item ); + } OID oid = new OID((String)dobj.get(ACSObject.OBJECT_TYPE), dobj.get(ACSObject.ID)); |