From: Vance K. <va...@us...> - 2006-01-18 09:21:45
|
User: vancek Date: 06/01/18 01:21:39 Modified: andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades EJB3EntityFacadeLogicImpl.java Log: added isCompositePrimaryKeyPresent, added getEntityCompositePrimaryKeyName, added getFullyQualifiedEntityCompositePrimaryKeyName, updated getAttributesAsList with extra arg (includeCompPKAttr) to filter identifier attributes of entity bean with composite primary key Revision Changes Path 1.5 +59 -4 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.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- EJB3EntityFacadeLogicImpl.java 17 Jan 2006 04:08:12 -0000 1.4 +++ EJB3EntityFacadeLogicImpl.java 18 Jan 2006 09:21:39 -0000 1.5 @@ -139,7 +139,13 @@ public static final String ENTITY_EMBEDDABLE_NAME_PATTERN = "entityEmbeddableNamePattern"; /** - * The p0roperty that stores the generic finders option + * The property that stores the pattern defining the entity + * composite primary key class name. + */ + private static final String ENTITY_COMPOSITE_PRIMARY_KEY_NAME_PATTERN = "entityCompositePrimaryKeyNamePattern"; + + /** + * The poroperty that stores the generic finders option */ private static final String ENTITY_GENERIC_FINDERS = "entityGenericFinders"; @@ -152,6 +158,9 @@ // --------------- methods --------------------- + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3EntityFacade#getIdentifiers() + */ public Collection handleGetIdentifiers() { Collection identifiers = new ArrayList(); @@ -509,6 +518,19 @@ } /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3EntityFacadeLogic#handleGetEntityCompositePrimaryKeyName() + */ + protected String handleGetEntityCompositePrimaryKeyName() + { + String compPKPattern = + String.valueOf(this.getConfiguredProperty(ENTITY_COMPOSITE_PRIMARY_KEY_NAME_PATTERN)); + + return MessageFormat.format( + compPKPattern, + new Object[] {StringUtils.trimToEmpty(this.getName())}); + } + + /** * @see org.andromda.metafacades.uml.EntityFacade#getEntityListenerName() */ protected String handleGetEntityListenerName() @@ -546,6 +568,17 @@ } /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3EntityFacadeLogic#handleGetFullyQualifiedEntityCompositePrimaryKeyName() + */ + protected String handleGetFullyQualifiedEntityCompositePrimaryKeyName() + { + return EJB3MetafacadeUtils.getFullyQualifiedName( + this.getPackageName(), + this.getEntityCompositePrimaryKeyName(), + null); + } + + /** * @see org.andromda.cartridges.ejb3.metafacades.EJB3EntityFacadeLogic#handleGetEntityImplementationName() */ protected String handleGetEntityImplementationName() @@ -837,7 +870,11 @@ * @see org.andromda.cartridges.ejb3.metafacades.EJB3EntityFacadeLogic# * handleGetAttributesAsList(java.util.Collection, boolean, boolean) */ - protected String handleGetAttributesAsList(Collection attributes, boolean includeTypes, boolean includeNames) + protected String handleGetAttributesAsList( + Collection attributes, + boolean includeTypes, + boolean includeNames, + boolean includeCompPKAttr) { if (!includeNames && !includeTypes || attributes == null) { @@ -849,9 +886,14 @@ for (final Iterator it = attributes.iterator(); it.hasNext();) { - //AttributeFacade attr = (AttributeFacade)it.next(); EJB3EntityAttributeFacade attr = (EJB3EntityAttributeFacade)it.next(); - if (!attr.isVersion()) + /** + * Do not include attributes that are assigned for optimistic lock value for version or + * identifier attributes for entities with a composite primary key . + */ + boolean isCompositePK = this.isCompositePrimaryKeyPresent(); + if (!attr.isVersion() && + ((isCompositePK && (!attr.isIdentifier() || includeCompPKAttr)) || !isCompositePK)) { sb.append(separator); separator = ", "; @@ -877,4 +919,17 @@ { return BooleanUtils.toBoolean(String.valueOf(this.getConfiguredProperty(ENTITY_GENERIC_FINDERS))); } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3EntityFacadeLogic#handleIsCompositePrimaryKeyPresent() + */ + protected boolean handleIsCompositePrimaryKeyPresent() + { + boolean isCompositePK = false; + if (this.getIdentifiers().size() > 1) + { + isCompositePK = true; + } + return isCompositePK; + } } \ No newline at end of file |