View Javadoc
1   package org.andromda.cartridges.spring.metafacades;
2   
3   import java.util.ArrayList;
4   import java.util.Collection;
5   
6   import org.andromda.metafacades.uml.ParameterFacade;
7   import org.apache.commons.lang.StringUtils;
8   
9   import org.andromda.cartridges.spring.SpringProfile;
10  
11  /**
12   * MetafacadeLogic implementation for org.andromda.cartridges.spring.metafacades.SpringEntityOperation.
13   *
14   * @see org.andromda.cartridges.spring.metafacades.SpringEntityOperation
15   */
16  public class SpringEntityOperationLogicImpl
17          extends SpringEntityOperationLogic
18  {
19      private static final long serialVersionUID = 34L;
20      /**
21       * Public constructor for SpringEntityOperationLogicImpl
22       * @param metaObject
23       * @param context
24       * @see org.andromda.cartridges.spring.metafacades.SpringEntityOperation
25       */
26      public SpringEntityOperationLogicImpl(Object metaObject, String context)
27      {
28          super(metaObject, context);
29      }
30  
31      /**
32       * @return getImplementationOperationName(StringUtils.capitalize(this.getName()))
33       * @see org.andromda.cartridges.spring.metafacades.SpringEntityOperation#getImplementationName()
34       */
35      protected String handleGetImplementationName()
36      {
37          return this.getImplementationOperationName(StringUtils.capitalize(this.getName()));
38      }
39  
40      /**
41       * @return getImplementationOperationName(StringUtils.capitalize(this.getCall()))
42       * @see org.andromda.cartridges.spring.metafacades.SpringEntityOperation#getImplementationCall()
43       */
44      protected String handleGetImplementationCall()
45      {
46          return this.getImplementationOperationName(StringUtils.capitalize(this.getCall()));
47      }
48  
49      /**
50       * @return getImplementationOperationName(StringUtils.capitalize(this.getSignature()))
51       * @see org.andromda.cartridges.spring.metafacades.SpringEntityOperation#getImplementationSignature()
52       */
53      protected String handleGetImplementationSignature()
54      {
55          return this.getImplementationOperationName(StringUtils.capitalize(this.getSignature()));
56      }
57  
58      /**
59       * Retrieves the implementationOperatName by replacing the <code>replacement</code> in the {@link
60       * SpringGlobals#IMPLEMENTATION_OPERATION_NAME_PATTERN}
61       *
62       * @param replacement the replacement string for the pattern.
63       * @return the operation name
64       */
65      private String getImplementationOperationName(String replacement)
66      {
67          return StringUtils.trimToEmpty(String.valueOf(this.getConfiguredProperty(
68                  SpringGlobals.IMPLEMENTATION_OPERATION_NAME_PATTERN))).replaceAll("\\{0\\}", replacement);
69      }
70  
71      /**
72       * @return getArguments().getType()
73       * @see org.andromda.cartridges.spring.metafacades.SpringEntityOperation#getImplementationCall()
74       */
75      protected Collection<SpringCriteriaAttributeLogic> handleGetArguments()
76      {
77          Collection<SpringCriteriaAttributeLogic> arguments = new ArrayList<SpringCriteriaAttributeLogic>();
78          for (ParameterFacade parameter : this.getArguments())
79          {
80              arguments.add((SpringCriteriaAttributeLogic)parameter.getType());
81          }
82          return arguments;
83      }
84  
85      /**
86       * @see org.andromda.cartridges.spring.metafacades.SpringEntityOperation#isPrePersist()
87       */
88      @Override
89      protected boolean handleIsPrePersist()
90      {
91          return this.hasStereotype(SpringProfile.STEREOTYPE_PRE_PERSIST);
92      }
93  
94      /**
95       * @see org.andromda.cartridges.spring.metafacades.SpringEntityOperation#isPostPersist()
96       */
97      @Override
98      protected boolean handleIsPostPersist()
99      {
100         return this.hasStereotype(SpringProfile.STEREOTYPE_POST_PERSIST);
101     }
102 
103     /**
104      * @see org.andromda.cartridges.spring.metafacades.SpringEntityOperation#isPreRemove()
105      */
106     @Override
107     protected boolean handleIsPreRemove()
108     {
109         return this.hasStereotype(SpringProfile.STEREOTYPE_PRE_REMOVE);
110     }
111 
112     /**
113      * @see org.andromda.cartridges.spring.metafacades.SpringEntityOperation#isPostRemove()
114      */
115     @Override
116     protected boolean handleIsPostRemove()
117     {
118         return this.hasStereotype(SpringProfile.STEREOTYPE_POST_REMOVE);
119     }
120 
121     /**
122      * @see org.andromda.cartridges.spring.metafacades.SpringEntityOperation#isPreUpdate()
123      */
124     @Override
125     protected boolean handleIsPreUpdate()
126     {
127         return this.hasStereotype(SpringProfile.STEREOTYPE_PRE_UPDATE);
128     }
129 
130     /**
131      * @see org.andromda.cartridges.spring.metafacades.SpringEntityOperation#isPostUpdate()
132      */
133     @Override
134     protected boolean handleIsPostUpdate()
135     {
136         return this.hasStereotype(SpringProfile.STEREOTYPE_POST_UPDATE);
137     }
138 }