From: Vance K. <va...@us...> - 2006-10-08 15:24:00
|
User: vancek Date: 06/10/08 08:23:57 Modified: andromda-ejb3/src/main/resources/templates/ejb3/crud ManageableServiceRemote.vsl ManageableServiceBase.vsl andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades EJB3ManageableEntityFacadeLogicImpl.java andromda-ejb3/src/changes changes.xml andromda-ejb3/src/main/uml EJB3MetafacadeModel.xml.zip Log: removed workaround in EJB3ManageableEntityFacade due to invalid naming of getIdentifier Revision Changes Path 1.4 +3 -7 cartridges/andromda-ejb3/src/main/resources/templates/ejb3/crud/ManageableServiceRemote.vsl Index: ManageableServiceRemote.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/resources/templates/ejb3/crud/ManageableServiceRemote.vsl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -r1.3 -r1.4 --- ManageableServiceRemote.vsl 26 Jun 2006 06:45:12 -0000 1.3 +++ ManageableServiceRemote.vsl 8 Oct 2006 15:23:57 -0000 1.4 @@ -6,16 +6,12 @@ #set ($generatedFile = "${manageable.manageableServiceFullPath}.java") #set ($memberList = $manageable.listManageableMembers(true)) #if (!$manageable.identifiers.empty) -#**##set ($identifier = $manageable.manageableIdentifierWorkaround) +#**##set ($identifier = $manageable.manageableIdentifier) #end package $manageable.manageablePackageName; /** * Manageable service bean remote interface - * - * NOTE: This is currently using the workaround to get the manageable entity identifer - * Once the metafacade engine is fixed, search for all calls with suffix "Workaround" - * and remove this suffix. */ public interface $manageable.manageableServiceName { @@ -44,12 +40,12 @@ #**##end #end -#if ($manageable.updateWorkaround) +#if ($manageable.update) public $manageable.fullyQualifiedName update($memberList) throws ${manageable.fullyQualifiedManageableServiceUpdateExceptionName}; #end -#if ($manageable.deleteWorkaround) +#if ($manageable.delete) public void delete(${identifier.type.fullyQualifiedName}[] ids) throws ${manageable.fullyQualifiedManageableServiceDeleteExceptionName}; 1.7 +12 -16 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.6 retrieving revision 1.7 diff -u -w -r1.6 -r1.7 --- ManageableServiceBase.vsl 10 Jul 2006 05:39:26 -0000 1.6 +++ ManageableServiceBase.vsl 8 Oct 2006 15:23:57 -0000 1.7 @@ -7,16 +7,12 @@ #set ($memberList = $manageable.listManageableMembers(true)) #set ($memberListArguments = $manageable.listManageableMembers(false)) #if (!$manageable.identifiers.empty) -#**##set ($identifier = $manageable.manageableIdentifierWorkaround) +#**##set ($identifier = $manageable.manageableIdentifier) #end package $manageable.manageablePackageName; /** * Autogenerated EJB manageable session bean class ${manageable.manageableServiceName}. - * - * NOTE: This is currently using the workaround to get the manageable entity identifer - * Once the metafacade engine is fixed, search for all calls with suffix "Workaround" - * and remove this suffix. */ /** * Do not specify the javax.ejb.${manageable.type} annotation @@ -53,13 +49,13 @@ // ------------ Private Operations ---------- #**##foreach ($associatedClass in $associatedClasses) - private java.util.List<${associatedClass.fullyQualifiedEntityName}> find${associatedClass.name}ByIds(${associatedClass.manageableIdentifierWorkaround.type.fullyQualifiedName}[] ids) + private java.util.List<${associatedClass.fullyQualifiedEntityName}> find${associatedClass.name}ByIds(${associatedClass.identifier.type.fullyQualifiedName}[] ids) throws ${manageable.fullyQualifiedManageableServiceReadExceptionName} { try { - javax.persistence.Query query = emanager.createQuery("select entity from ${associatedClass.entityName} as entity where entity.${associatedClass.manageableIdentifierWorkaround.name} in (:${associatedClass.manageableIdentifierWorkaround.name})"); - query.setParameter("${associatedClass.manageableIdentifierWorkaround.name}", java.util.Arrays.asList(ids)); + javax.persistence.Query query = emanager.createQuery("select entity from ${associatedClass.entityName} as entity where entity.${associatedClass.identifier.name} in (:${associatedClass.identifier.name})"); + query.setParameter("${associatedClass.identifier.name}", java.util.Arrays.asList(ids)); return query.getResultList(); } catch (Exception ex) @@ -335,7 +331,7 @@ ## add left join fetch to query to retrieve many side of association ends ## this is only required if the ends are not initialised further down ## -#**##if ($member.type.displayAttributeWorkaround.name == $member.type.manageableIdentifierWorkaround.name) +#**##if ($member.type.manageableDisplayAttribute.name == $member.type.identifier.name) #* *##if ($member.many) #* *##set ($findAllQuery = "${findAllQuery} left join fetch entity.${member.name}") #* *##end @@ -347,7 +343,7 @@ #end java.util.List<${manageable.fullyQualifiedEntityName}> entities = query.getResultList(); #foreach ($member in $manageable.manageableAssociationEnds) -#**##if ($member.type.displayAttributeWorkaround.name != $member.type.manageableIdentifierWorkaround.name) +#**##if ($member.type.manageableDisplayAttribute.name != $member.type.identifier.name) org.apache.commons.collections.CollectionUtils.transform(entities, new org.apache.commons.collections.Transformer() { public Object transform(final Object object) @@ -356,18 +352,18 @@ if (result.${member.getterName}() != null) { #* *##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}>()); + java.util.Collection<${member.type.manageableDisplayAttribute.type.fullyQualifiedName}> $member.labelName = java.util.Collections.synchronizedCollection(new java.util.ArrayList<${member.type.manageableDisplayAttribute.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}()); + ${member.labelName}.add(entity.${member.type.manageableDisplayAttribute.getterName}()); } } result.${member.setterLabelName}(${member.labelName}); #* *##else - result.${member.setterName}#if ($member.many)Labels#else#**#Label#end(result.${member.getterName}().${member.type.displayAttributeWorkaround.getterName}()); + result.${member.setterName}#if ($member.many)Labels#else#**#Label#end(result.${member.getterName}().${member.type.manageableDisplayAttribute.getterName}()); #* *##end } return result; @@ -435,7 +431,7 @@ try { #* *##foreach ($member in $manageable.manageableAssociationEnds) - lists.put("${member.name}", emanager.createQuery("select item.${member.type.manageableIdentifierWorkaround.name}, item.${member.type.displayAttributeWorkaround.name} from ${member.type.entityName} as item order by item.${member.type.displayAttributeWorkaround.name}").getResultList()); + lists.put("${member.name}", emanager.createQuery("select item.${member.type.identifier.name}, item.${member.type.manageableDisplayAttribute.name} from ${member.type.entityName} as item order by item.${member.type.manageableDisplayAttribute.name}").getResultList()); #* *##end } catch (Exception ex) @@ -447,7 +443,7 @@ #**##end #end -#if ($manageable.updateWorkaround) +#if ($manageable.update) /** * Update Operation * @@ -533,7 +529,7 @@ } #end -#if ($manageable.deleteWorkaround) +#if ($manageable.delete) /** * Delete operation * 1.7 +0 -63 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.6 retrieving revision 1.7 diff -u -w -r1.6 -r1.7 --- EJB3ManageableEntityFacadeLogicImpl.java 11 Aug 2006 05:49:46 -0000 1.6 +++ EJB3ManageableEntityFacadeLogicImpl.java 8 Oct 2006 15:23:57 -0000 1.7 @@ -215,69 +215,6 @@ } /** - * @see org.andromda.cartridges.ejb3.metafacades.EJB3ManageableEntityFacadeLogic#isDeleteWorkaround() - */ - protected boolean handleIsDeleteWorkaround() - { - return (this.getIdentifiers(true).iterator().next() != null ? true : false); - } - - /** - * @see org.andromda.cartridges.ejb3.metafacades.EJB3ManageableEntityFacadeLogic#isUpdateWorkaround() - */ - protected boolean handleIsUpdateWorkaround() - { - return (this.getIdentifiers(true).iterator().next() != null ? true : false); - } - - /** - * @see org.andromda.cartridges.ejb3.metafacades.EJB3ManageableEntityFacadeLogic#getManageableIdentifierWorkaround() - */ - protected EntityAttribute handleGetManageableIdentifierWorkaround() - { - return (EntityAttribute)this.getIdentifiers(true).iterator().next(); - } - - /** - * @see org.andromda.cartridges.ejb3.metafacades.EJB3ManageableEntityFacadeLogic#handleGetDisplayAttributeWorkaround() - */ - protected AttributeFacade handleGetDisplayAttributeWorkaround() - { - AttributeFacade displayAttribute = null; - - final Object taggedValueObject = findTaggedValue(UMLProfile.TAGGEDVALUE_MANAGEABLE_DISPLAY_NAME); - if (taggedValueObject != null) - { - displayAttribute = findAttribute(StringUtils.trimToEmpty(taggedValueObject.toString())); - } - - final Collection attributes = getAttributes(true); - for (final Iterator attributeIterator = attributes.iterator(); - attributeIterator.hasNext() && displayAttribute == null;) - { - final EntityAttribute attribute = (EntityAttribute)attributeIterator.next(); - if (attribute.isUnique()) - { - displayAttribute = attribute; - } - } - - if (displayAttribute == null) - { - if (!getIdentifiers().isEmpty()) - { - displayAttribute = (EntityAttribute)getIdentifiers().iterator().next(); - } - else if (!attributes.isEmpty()) - { - displayAttribute = (EntityAttribute)attributes.iterator().next(); - } - } - - return displayAttribute; - } - - /** * @see org.andromda.cartridges.ejb3.metafacades.EJB3ManageableEntityFacadeLogic#handleGetManageableRolesAllowed() */ protected String handleGetManageableRolesAllowed() 1.37 +2 -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.36 retrieving revision 1.37 diff -u -w -r1.36 -r1.37 --- changes.xml 8 Oct 2006 13:52:34 -0000 1.36 +++ changes.xml 8 Oct 2006 15:23:57 -0000 1.37 @@ -304,7 +304,8 @@ Demo EJB3 added to andromda-plugins/samples accompanied by quick site docs. </action> <action dev="vancek" type="fix"> - Fix getIdentifier naming in EJB3EntityFacade. + Fix getIdentifier naming in EJB3EntityFacade which eliminates the workaround solution in + EJB3ManageableEntityFacade. </action> </release> </body> 1.47 +214 -221 cartridges/andromda-ejb3/src/main/uml/EJB3MetafacadeModel.xml.zip <<Binary file>> |