From: Vance K. <va...@us...> - 2006-01-03 01:39:58
|
User: vancek Date: 06/01/02 17:39:53 Modified: andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades EJB3MetafacadeUtils.java Log: changed getViewType signature and added convertTransacionType method Revision Changes Path 1.2 +66 -15 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3MetafacadeUtils.java Index: EJB3MetafacadeUtils.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3MetafacadeUtils.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- EJB3MetafacadeUtils.java 28 Dec 2005 00:32:55 -0000 1.1 +++ EJB3MetafacadeUtils.java 3 Jan 2006 01:39:53 -0000 1.2 @@ -1,5 +1,6 @@ package org.andromda.cartridges.ejb3.metafacades; +import org.andromda.cartridges.ejb3.EJB3Globals; import org.andromda.cartridges.ejb3.EJB3Profile; import org.andromda.core.common.ExceptionUtils; import org.andromda.metafacades.uml.AttributeFacade; @@ -20,6 +21,7 @@ * Contains utilities for use with EJB metafacades. * * @author Chad Brandon + * @author Vance Karimi */ class EJB3MetafacadeUtils { @@ -82,38 +84,49 @@ } /** - * Gets the view type for the passed in <code>classifier</code>. Returns 'local' if the model element has the entity - * stereotype, others checks there ejb tagged value and if there is no value defined, returns 'remote'. + * Gets the view type for the passed in <code>classifier</code>. If no + * view type can be retrieved from the <code>classifier</code>, then the + * <code>defaultViewType</code> is returned. * + * If the model element has the entity stereotype, returns 'local'. + * Otherwise (session ejb) checks the ejb tagged value and if there is + * no value defined, returns 'remote'. + * + * @param classifier The classifier to lookup the view type tagged value + * @param defaultViewType The default view type if one is not found * @return String the view type name. */ - static String getViewType(ClassifierFacade classifier) + static String getViewType( + ClassifierFacade classifier, + String defaultViewType) { final String methodName = "EJBMetafacadeUtils.getViewType"; ExceptionUtils.checkNull(methodName, "classifer", classifier); - String viewType = "local"; - if (classifier.hasStereotype(EJB3Profile.STEREOTYPE_SERVICE)) + String viewType = (String)classifier.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_VIEWTYPE); + if (classifier.hasStereotype(EJB3Profile.STEREOTYPE_ENTITY)) + { + if (StringUtils.isEmpty(viewType)) + { + viewType = (StringUtils.isNotBlank(defaultViewType) ? defaultViewType : EJB3Globals.VIEW_TYPE_LOCAL); + } + } + else if (classifier.hasStereotype(EJB3Profile.STEREOTYPE_SERVICE)) { - String viewTypeValue = (String)classifier.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_VIEWTYPE); // if the view type wasn't found, search all super classes - if (StringUtils.isEmpty(viewTypeValue)) + if (StringUtils.isEmpty(viewType)) { viewType = (String)CollectionUtils.find(classifier.getAllGeneralizations(), new Predicate() { public boolean evaluate(Object object) { - return ((ModelElementFacade)object).findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_VIEWTYPE) != - null; + return ((ModelElementFacade)object).findTaggedValue( + EJB3Profile.TAGGEDVALUE_EJB_VIEWTYPE) != null; } }); } - if (StringUtils.isNotEmpty(viewTypeValue)) - { - viewType = viewTypeValue; - } - else + if (StringUtils.isEmpty(viewType)) { - viewType = "remote"; + viewType = (StringUtils.isNotBlank(defaultViewType) ? defaultViewType : EJB3Globals.VIEW_TYPE_REMOTE); } } return viewType.toLowerCase(); @@ -274,4 +287,42 @@ fullyQualifiedName.append(StringUtils.trimToEmpty(suffix)); return fullyQualifiedName.toString(); } + + /** + * Convert the transaction type from lower casing to upper casing. + * This maintains reusable tagged value enumeration from EJB + * implementation. + * + * @param transType + * @return + */ + static String convertTransactionType(String transType) + { + String type = null; + if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_MANDATORY)) + { + type = "MANDATORY"; + } + else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_NEVER)) + { + type = "NEVER"; + } + else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_NOT_SUPPORTED)) + { + transType = "NOT_SUPPORTED"; + } + else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_REQUIRED)) + { + type = "REQUIRED"; + } + else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_REQUIRES_NEW)) + { + type = "REQUIRES_NEW"; + } + else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_SUPPORTS)) + { + type = "SUPPORTS"; + } + return type; + } } \ No newline at end of file |
From: Vance K. <va...@us...> - 2006-01-06 13:58:01
|
User: vancek Date: 06/01/06 05:57:39 Modified: andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades EJB3MetafacadeUtils.java Log: added getTransactionType used by ClassifierFacades Revision Changes Path 1.3 +70 -41 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3MetafacadeUtils.java Index: EJB3MetafacadeUtils.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3MetafacadeUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- EJB3MetafacadeUtils.java 3 Jan 2006 01:39:53 -0000 1.2 +++ EJB3MetafacadeUtils.java 6 Jan 2006 13:57:39 -0000 1.3 @@ -213,8 +213,75 @@ } /** - * Gets all constants for the specified <code>classifier</code>. If <code>follow</code> is true, then a search up - * the inheritance hierachy will be performed and all super type constants will also be retrieved. + * Returns the transaction type for the specified <code>classifier</code>. + * + * @param classifier the classifier from which to retrieve the transaction type. + * @param defaultTransactionType the default transaction type if no tagged value is specified. + * @return the transaction type as a String. + */ + static String getTransactionType(ClassifierFacade classifier, String defaultTransactionType) + { + final String methodName = "EJBMetafacadeUtils.getTransactionType"; + ExceptionUtils.checkNull(methodName, "classifer", classifier); + + String transactionType = (String)classifier.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_TRANSACTION_TYPE); + if (StringUtils.isNotBlank(transactionType)) + { + transactionType = convertTransactionType(transactionType); + } + else + { + transactionType = defaultTransactionType; + } + return transactionType; + } + + /** + * Convert the transaction type from lower casing to upper casing. + * This maintains reusable tagged value enumeration from EJB + * implementation. + * + * @param transType + * @return + */ + static String convertTransactionType(String transType) + { + final String methodName = "EJBMetafacadeUtils.convertTransactionType"; + ExceptionUtils.checkNull(methodName, "transType", transType); + + String type = null; + if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_MANDATORY)) + { + type = "MANDATORY"; + } + else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_NEVER)) + { + type = "NEVER"; + } + else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_NOT_SUPPORTED)) + { + transType = "NOT_SUPPORTED"; + } + else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_REQUIRED)) + { + type = "REQUIRED"; + } + else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_REQUIRES_NEW)) + { + type = "REQUIRES_NEW"; + } + else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_SUPPORTS)) + { + type = "SUPPORTS"; + } + return type; + } + + /** + * Gets all constants for the specified <code>classifier</code>. + * If <code>follow</code> is true, then a search up + * the inheritance hierachy will be performed and all super + * type constants will also be retrieved. * * @param classifier the classifier from which to retrieve the constants * @param follow true/false on whether or not to 'follow' the inheritance hierarchy when retrieving the @@ -225,7 +292,7 @@ ClassifierFacade classifier, boolean follow) { - final String methodName = "EJBMetafacadeUtils.getEnvironmentEntries"; + final String methodName = "EJBMetafacadeUtils.getConstants"; ExceptionUtils.checkNull(methodName, "classifer", classifier); Collection attributes = classifier.getStaticAttributes(); @@ -287,42 +354,4 @@ fullyQualifiedName.append(StringUtils.trimToEmpty(suffix)); return fullyQualifiedName.toString(); } - - /** - * Convert the transaction type from lower casing to upper casing. - * This maintains reusable tagged value enumeration from EJB - * implementation. - * - * @param transType - * @return - */ - static String convertTransactionType(String transType) - { - String type = null; - if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_MANDATORY)) - { - type = "MANDATORY"; - } - else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_NEVER)) - { - type = "NEVER"; - } - else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_NOT_SUPPORTED)) - { - transType = "NOT_SUPPORTED"; - } - else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_REQUIRED)) - { - type = "REQUIRED"; - } - else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_REQUIRES_NEW)) - { - type = "REQUIRES_NEW"; - } - else if (StringUtils.equalsIgnoreCase(transType, EJB3Globals.TRANSACTION_TYPE_SUPPORTS)) - { - type = "SUPPORTS"; - } - return type; - } } \ No newline at end of file |
From: Vance K. <va...@us...> - 2006-01-25 03:02:48
|
User: vancek Date: 06/01/24 19:02:42 Modified: andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades EJB3MetafacadeUtils.java Log: fixed comments Revision Changes Path 1.4 +3 -1 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3MetafacadeUtils.java Index: EJB3MetafacadeUtils.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3MetafacadeUtils.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -r1.3 -r1.4 --- EJB3MetafacadeUtils.java 6 Jan 2006 13:57:39 -0000 1.3 +++ EJB3MetafacadeUtils.java 25 Jan 2006 03:02:41 -0000 1.4 @@ -5,11 +5,13 @@ import org.andromda.core.common.ExceptionUtils; import org.andromda.metafacades.uml.AttributeFacade; import org.andromda.metafacades.uml.ClassifierFacade; +import org.andromda.metafacades.uml.DependencyFacade; import org.andromda.metafacades.uml.ModelElementFacade; import org.andromda.metafacades.uml.OperationFacade; import org.andromda.metafacades.uml.UMLProfile; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.Predicate; +import org.apache.commons.collections.Transformer; import org.apache.commons.lang.StringUtils; import java.util.ArrayList; @@ -320,7 +322,7 @@ /** * Returns true/false based on whether or not synthetic or auto generated create methods should be allowed. * - * @param classifier the entity or session EJB. + * @param classifier The entity or session bean. * @return true/false */ static boolean allowSyntheticCreateMethod(ClassifierFacade classifier) |
From: Vance K. <va...@us...> - 2006-02-01 08:41:40
|
User: vancek Date: 06/02/01 00:41:34 Modified: andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades EJB3MetafacadeUtils.java Log: fixed comment Revision Changes Path 1.5 +2 -2 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3MetafacadeUtils.java Index: EJB3MetafacadeUtils.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3MetafacadeUtils.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- EJB3MetafacadeUtils.java 25 Jan 2006 03:02:41 -0000 1.4 +++ EJB3MetafacadeUtils.java 1 Feb 2006 08:41:34 -0000 1.5 @@ -160,8 +160,8 @@ } /** - * Gets all instance attributes including those instance attributes belonging to the <code>classifier</code> and any - * inherited ones. + * Gets all instance attributes including those instance attributes belonging to the + * <code>classifier</code> and any inherited ones. * * @param classifier the ClassifierFacade from which to retrieve the instance attributes. * @return the list of all instance attributes. |