From: Vance K. <va...@us...> - 2006-07-24 14:02:06
|
User: vancek Date: 06/07/24 07:02:02 Modified: andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades EJB3AssociationEndFacadeLogicImpl.java andromda-ejb3/src/changes changes.xml andromda-ejb3/src/main/resources/templates/ejb3 EntityEmbeddable.vsl Log: JIRA EJB-40 fix support for modelling map association ends Revision Changes Path 1.14 +34 -5 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3AssociationEndFacadeLogicImpl.java Index: EJB3AssociationEndFacadeLogicImpl.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3AssociationEndFacadeLogicImpl.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -w -r1.13 -r1.14 --- EJB3AssociationEndFacadeLogicImpl.java 24 Jul 2006 07:10:22 -0000 1.13 +++ EJB3AssociationEndFacadeLogicImpl.java 24 Jul 2006 14:02:01 -0000 1.14 @@ -264,7 +264,9 @@ */ if ("true".equals(this.getConfiguredProperty(UMLMetafacadeProperties.ENABLE_TEMPLATING))) { - getterSetterTypeName = getterSetterTypeName + "<" + this.getType().getFullyQualifiedName() + ">"; + getterSetterTypeName = getterSetterTypeName + "<" + + (this.isMap()? this.getCollectionIndexType() + ", ": "") + + this.getType().getFullyQualifiedName() + ">"; } } return getterSetterTypeName; @@ -680,12 +682,39 @@ Object value = this.findTaggedValue(EJB3Profile.TAGGEDVALUE_ASSOCIATION_INDEX_TYPE); if (value == null) { + Object name = this.findTaggedValue(EJB3Profile.TAGGEDVALUE_ASSOCIATION_INDEX); + if(name == null) + { + // Find the identifier + EJB3EntityAttributeFacade identifier = ((EJB3EntityFacade)this.getOtherEnd().getType()).getIdentifer(); + value = identifier.getType().getFullyQualifiedName(); + return value.toString(); + } + else + { + // Find the attribute corresponding to name + Collection attributes = ((EJB3EntityFacade)this.getOtherEnd().getType()).getAttributes(); + Iterator it = attributes.iterator(); + while(it.hasNext()) + { + EJB3EntityAttributeFacade attribute = (EJB3EntityAttributeFacade) it.next(); + if(attribute.getName().equals(name)) + { + value = attribute.getType().getFullyQualifiedName(); + return value.toString(); + } + } + } + + if (value == null) + { value = this.getConfiguredProperty(COLLECTION_INDEX_TYPE); if (StringUtils.isBlank(ObjectUtils.toString(value))) { value = null; } } + } if (value != null) { 1.25 +8 -0 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.24 retrieving revision 1.25 diff -u -w -r1.24 -r1.25 --- changes.xml 24 Jul 2006 07:10:22 -0000 1.24 +++ changes.xml 24 Jul 2006 14:02:02 -0000 1.25 @@ -259,6 +259,14 @@ composition end. The non-navigable end is assumed to be the owning end of the association. This fix renders the mappedBy property for OneToOne annotations on the inverse side of the association. </action> + <action dev="vancek" due-to="sverker" type="fix"> + JIRA EJB-40 - Fix support for modelling map associations ends. + "The attached patch solves this issue as well as providing an improvement in regards to List associations. + If no OrderBy tagged value is provided, the IndexColumn annotation is used (hibernate extension) to provide + true list association." - The hibernate annotation needs to be switched depending on the persistence + provider. This will be fixed once a namespace property is introduced along the lines of + persistenceProvider. + </action> </release> </body> </document> \ No newline at end of file 1.38 +24 -6 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.37 retrieving revision 1.38 diff -u -w -r1.37 -r1.38 --- EntityEmbeddable.vsl 1 Jul 2006 10:13:01 -0000 1.37 +++ EntityEmbeddable.vsl 24 Jul 2006 14:02:02 -0000 1.38 @@ -593,12 +593,21 @@ #* *##else #* *##set ($argExists = false) @javax.persistence.OneToMany(#if ($target.cascadeType)cascade = {${target.cascadeType}}#set ($argExists = true)#end#if ($associationEnd.navigable)#if ($argExists) ,#end#**#mappedBy = "${associationEnd.name}"#set ($argExists = true)#end#if ($target.eager)#if ($argExists), #end#**#fetch = javax.persistence.FetchType.EAGER#end) +#* *##if ($target.map) + @javax.persistence.MapKey#if ($target.hasTaggedValue("@andromda.persistence.collection.index"))(name = "${target.collectionIndexName}")#end + +#* *##else #* *##if ($target.hasTaggedValue("@andromda.persistence.orderBy")) #* *##if ($stringUtils.isNotEmpty(${target.orderByClause})) @javax.persistence.OrderBy("${target.orderByClause}") #* *##else @javax.persistence.OrderBy #* *##end +#* *##else +#* *##if ($target.list) + @org.hibernate.annotations.IndexColumn(name = "${target.collectionIndexName}") +#* *##end +#* *##end #* *##end #* *##if ($target.associationCacheEnabled) @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.${target.cacheType}) @@ -711,12 +720,21 @@ ) #* *##end #* *##end +#* *##if ($target.map) + @javax.persistence.MapKey#if ($target.hasTaggedValue("@andromda.persistence.collection.index"))(name = "${target.collectionIndexName}")#end + +#* *##else #* *##if ($target.hasTaggedValue("@andromda.persistence.orderBy")) #* *##if ($stringUtils.isNotEmpty(${target.orderByClause})) @javax.persistence.OrderBy("${target.orderByClause}") #* *##else @javax.persistence.OrderBy #* *##end +#* *##else +#* *##if ($target.list) + @org.hibernate.annotations.IndexColumn(name = "${target.collectionIndexName}") +#* *##end +#* *##end #* *##end #* *##if ($target.associationCacheEnabled) @org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.${target.cacheType}) |