From: Vance K. <va...@us...> - 2006-10-09 04:08:51
|
User: vancek Date: 06/10/08 21:08:51 Modified: andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades EJB3ManageableEntityFacadeLogicImpl.java EJB3EntityFacadeLogicImpl.java andromda-ejb3/src/changes changes.xml andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: jira EJB-45 fix for failure to use correct metafacade when adding Manageable stereotype for UML2 Revision Changes Path 1.8 +64 -0 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3ManageableEntityFacadeLogicImpl.java Index: EJB3ManageableEntityFacadeLogicImpl.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3ManageableEntityFacadeLogicImpl.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -r1.7 -r1.8 --- EJB3ManageableEntityFacadeLogicImpl.java 8 Oct 2006 15:23:57 -0000 1.7 +++ EJB3ManageableEntityFacadeLogicImpl.java 9 Oct 2006 04:08:51 -0000 1.8 @@ -1,13 +1,17 @@ package org.andromda.cartridges.ejb3.metafacades; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; +import java.util.List; import org.andromda.cartridges.ejb3.EJB3Globals; import org.andromda.metafacades.uml.AttributeFacade; import org.andromda.metafacades.uml.EntityAttribute; import org.andromda.metafacades.uml.UMLProfile; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.Predicate; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; @@ -240,4 +244,64 @@ } return rolesAllowed != null ? rolesAllowed.toString() : null; } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3ManageableEntityFacadeLogic#getIdentifier() + * + * Override the implemenation in EJB3EntityFacade as UML2 models cannot retrieve the identifier via the + * super EJB3EntityFacade. + */ + public EJB3EntityAttributeFacade getIdentifier() + { + return (EJB3EntityAttributeFacade)super.getIdentifiers().iterator().next(); + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3ManageableEntityFacadeLogic#getAllInstanceAttributes() + * + * Override the implemenation in EJB3EntityFacade as UML2 models will not get an + * EJB3ManageableEntityAttributeFacade when retrieving the attributes. + */ + public List getAllInstanceAttributes() + { + return EJB3MetafacadeUtils.getAllInstanceAttributes(this); + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3ManageableEntityFacadeLogic#getInheritedInstanceAttributes() + * + * Override the implemenation in EJB3EntityFacade as UML2 models will not get an + * EJB3ManageableEntityAttributeFacade when retrieving the attributes. + */ + public List getInheritedInstanceAttributes() + { + return EJB3MetafacadeUtils.getInheritedInstanceAttributes(this); + } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3ManageableEntityFacadeLogic# + * getInstanceAttributes(boolean, boolean) + * + * Override the implemenation in EJB3EntityFacade as UML2 models will not get an + * EJB3ManageableEntityAttributeFacade when retrieving the attributes. + */ + public Collection getInstanceAttributes(boolean follow, boolean withIdentifiers) + { + final Collection attributes = this.getAttributes(follow, withIdentifiers); + CollectionUtils.filter( + attributes, + new Predicate() + { + public boolean evaluate(Object object) + { + boolean valid = true; + if (object instanceof EntityAttribute) + { + valid = !((EntityAttribute)object).isStatic(); + } + return valid; + } + }); + return attributes; + } } \ No newline at end of file 1.27 +18 -10 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3EntityFacadeLogicImpl.java Index: EJB3EntityFacadeLogicImpl.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3EntityFacadeLogicImpl.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -w -r1.26 -r1.27 --- EJB3EntityFacadeLogicImpl.java 8 Oct 2006 13:52:34 -0000 1.26 +++ EJB3EntityFacadeLogicImpl.java 9 Oct 2006 04:08:51 -0000 1.27 @@ -6,6 +6,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashSet; +import java.util.List; import org.andromda.cartridges.ejb3.EJB3Globals; import org.andromda.cartridges.ejb3.EJB3Profile; @@ -1391,15 +1392,22 @@ boolean follow, boolean withIdentifiers) { - return new FilteredCollection(this.getAttributes(follow, withIdentifiers)) + final Collection attributes = this.getAttributes(follow, withIdentifiers); + CollectionUtils.filter( + attributes, + new Predicate() { - private static final long serialVersionUID = -8511475954374453779L; - public boolean evaluate(Object object) { - return !((AttributeFacade)object).isStatic(); + boolean valid = true; + if (object instanceof EntityAttribute) + { + valid = !((EntityAttribute)object).isStatic(); } - }; + return valid; + } + }); + return attributes; } /** 1.38 +7 -1 cartridges/andromda-ejb3/src/changes/changes.xml Index: changes.xml =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/changes/changes.xml,v retrieving revision 1.37 retrieving revision 1.38 diff -u -w -r1.37 -r1.38 --- changes.xml 8 Oct 2006 15:23:57 -0000 1.37 +++ changes.xml 9 Oct 2006 04:08:51 -0000 1.38 @@ -295,7 +295,7 @@ </action> <action dev="vancek" type="fix"> EJB3MessageDrivenFacade.getDestinationType requires search and replace for destination type retrieved - from TV. i.e. replace all '_' with '.'. + from TV. i.e. replace all '_' with '.'. Also fix casing for javax.jms.Queue and javax.jms.Topic. </action> <action dev="vancek" type="add"> UMLMETA-78 - Add support for member variables within type safe enumerations. @@ -307,6 +307,12 @@ Fix getIdentifier naming in EJB3EntityFacade which eliminates the workaround solution in EJB3ManageableEntityFacade. </action> + <action dev="vancek" due-to="markh" type="fix"> + JIRA EJB-45 - ClassCastException when setting Manageable stereotype on entities. The + EJB3ManageableEntityAttributeFacade was not being picked up correctly. Instead, the + emf.uml2.ManageableEntityAttributeFacade was used. The fix was to simply override the methods returning + attributes and identifiers in EJB3ManageableEntityFacade. + </action> </release> </body> </document> \ No newline at end of file 1.41 +3 -4 cartridges/andromda-ejb3/src/main/resources/templates/ejb3/EntityEmbeddable.vsl Index: EntityEmbeddable.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/resources/templates/ejb3/EntityEmbeddable.vsl,v retrieving revision 1.40 retrieving revision 1.41 diff -u -w -r1.40 -r1.41 --- EntityEmbeddable.vsl 8 Oct 2006 14:34:00 -0000 1.40 +++ EntityEmbeddable.vsl 9 Oct 2006 04:08:51 -0000 1.41 @@ -21,7 +21,7 @@ #**##set ($generatedFile = "${stringUtils.replace($entity.fullyQualifiedEntityName,'.','/')}.java") #end -#set ($identifier = $entity.identifiers.iterator().next()) +#set ($identifier = $entity.identifier) /** * Autogenerated POJO EJB#if ($entity.entityImplementationRequired || $entity.embeddableSuperclass) mapped super#end class for ${entity.entityName} containing the * bulk of the entity implementation. @@ -146,14 +146,14 @@ #**##end #end ## -## Only declase instance attributes that are NOT inherited. +## Only declare instance attributes that are NOT inherited. ## If a mapped superclass then don't generate auto identifier - but include ## normal defined identifier if one is defined. ## #if ($entity.embeddableSuperclass && $entity.dynamicIdentifiersPresent) #**##set ($attributes = $entity.getInstanceAttributes(false, false)) #else -#**##set ($attributes = $entity.instanceAttributes) +#**##set ($attributes = $entity.getInstanceAttributes(false, true)) #end #if (!$attributes.empty) @@ -242,7 +242,6 @@ ## Autogenerate a constructor implementation with all attributes. #set ($allAttributes = $transform.filterByVisibility($entity.allInstanceAttributes, "public")) #set ($inheritedAttributes = $transform.filterByVisibility($entity.inheritedInstanceAttributes, "public")) -#set ($instanceAttributes = $transform.filterByVisibility($entity.instanceAttributes, "public")) #if ($entity.syntheticCreateMethodAllowed && !$transform.filterUpdatableAttributes($allAttributes, $entity.compositePrimaryKeyPresent).empty) /** * Implementation for the constructor with all POJO attributes except auto incremented identifiers. |