From: Vance K. <va...@us...> - 2006-02-20 05:14:17
|
User: vancek Date: 06/02/19 21:14:15 Modified: andromda-ejb3/src/main/resources/templates/ejb3/crud ManageableServiceBase.vsl Log: if a display attribute is specified, transform the result collection to specify the display attribute transient value in the pojo. Revision Changes Path 1.3 +28 -1 cartridges/andromda-ejb3/src/main/resources/templates/ejb3/crud/ManageableServiceBase.vsl Index: ManageableServiceBase.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/resources/templates/ejb3/crud/ManageableServiceBase.vsl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- ManageableServiceBase.vsl 17 Feb 2006 02:32:44 -0000 1.2 +++ ManageableServiceBase.vsl 20 Feb 2006 05:14:14 -0000 1.3 @@ -316,7 +316,34 @@ #if ($manageable.maximumListSize > 0) query.setMaxResults($manageable.maximumListSize); #end - return query.getResultList(); + java.util.List<${manageable.fullyQualifiedEntityName}> entities = query.getResultList(); +#foreach ($member in $manageable.manageableAssociationEnds) +#**##if ($member.type.displayAttributeWorkaround.name != $member.type.manageableIdentifierWorkaround.name) + org.apache.commons.collections.CollectionUtils.transform(entities, new org.apache.commons.collections.Transformer() + { + public Object transform(final Object object) + { + ${manageable.fullyQualifiedEntityName} result = (${manageable.fullyQualifiedEntityName})object; +#* *##if ($member.many) + java.util.Collection<${member.type.displayAttributeWorkaround.type.fullyQualifiedName}> $member.labelName = java.util.Collections.synchronizedCollection(new java.util.ArrayList<${member.type.displayAttributeWorkaround.type.fullyQualifiedName}>()); + for (final java.util.Iterator<${member.type.fullyQualifiedEntityName}> iterator = result.${member.getterName}().iterator(); iterator.hasNext();) + { + ${member.type.fullyQualifiedEntityName} entity = iterator.next(); + synchronized (${member.labelName}) + { + ${member.labelName}.add(entity.${member.type.displayAttributeWorkaround.getterName}()); + } + } + result.${member.setterLabelName}(${member.labelName}); +#* *##else + result.${member.setterName}#if ($member.many)Labels#else#**#Label#end(result.${member.getterName}().${member.type.displayAttributeWorkaround.getterName}()); +#* *##end + return result; + } + }); +#**##end +#end + return entities; } catch (Exception ex) { |