1 package org.andromda.cartridges.ejb3.metafacades;
2
3 import java.text.MessageFormat;
4 import org.andromda.cartridges.ejb3.EJB3Globals;
5 import org.andromda.cartridges.ejb3.EJB3Profile;
6 import org.andromda.metafacades.uml.UMLProfile;
7 import org.apache.commons.lang.StringUtils;
8
9
10
11
12
13
14 public class EJB3OperationFacadeLogicImpl
15 extends EJB3OperationFacadeLogic
16 {
17 private static final long serialVersionUID = 34L;
18
19
20
21
22
23
24 public EJB3OperationFacadeLogicImpl(final Object metaObject, final String context)
25 {
26 super (metaObject, context);
27 }
28
29
30
31
32
33
34 @Override
35 protected boolean handleIsBusinessOperation()
36 {
37 return !this.isCreateMethod() &&
38 !this.isFinderMethod() &&
39 !this.isSelectMethod();
40 }
41
42
43
44
45 @Override
46 protected boolean handleIsSelectMethod()
47 {
48 return this.hasStereotype(EJB3Profile.STEREOTYPE_SELECT_METHOD);
49 }
50
51
52
53
54 @Override
55 protected boolean handleIsCreateMethod()
56 {
57 return this.hasStereotype(EJB3Profile.STEREOTYPE_CREATE_METHOD);
58 }
59
60
61
62
63 @Override
64 protected boolean handleIsFinderMethod()
65 {
66 return this.hasStereotype(UMLProfile.STEREOTYPE_FINDER_METHOD) || this.isQuery();
67 }
68
69
70
71
72 @Override
73 protected boolean handleIsPrePersist()
74 {
75 return this.hasStereotype(EJB3Profile.STEREOTYPE_PRE_PERSIST);
76 }
77
78
79
80
81 @Override
82 protected boolean handleIsPostPersist()
83 {
84 return this.hasStereotype(EJB3Profile.STEREOTYPE_POST_PERSIST);
85 }
86
87
88
89
90 @Override
91 protected boolean handleIsPreRemove()
92 {
93 return this.hasStereotype(EJB3Profile.STEREOTYPE_PRE_REMOVE);
94 }
95
96
97
98
99 @Override
100 protected boolean handleIsPostRemove()
101 {
102 return this.hasStereotype(EJB3Profile.STEREOTYPE_POST_REMOVE);
103 }
104
105
106
107
108 @Override
109 protected boolean handleIsPreUpdate()
110 {
111 return this.hasStereotype(EJB3Profile.STEREOTYPE_PRE_UPDATE);
112 }
113
114
115
116
117 @Override
118 protected boolean handleIsPostUpdate()
119 {
120 return this.hasStereotype(EJB3Profile.STEREOTYPE_POST_UPDATE);
121 }
122
123
124
125
126 @Override
127 protected boolean handleIsPostLoad()
128 {
129 return this.hasStereotype(EJB3Profile.STEREOTYPE_POST_LOAD);
130 }
131
132
133
134
135 @Override
136 protected boolean handleIsLifecycleCallback()
137 {
138 return this.isPostLoad() ||
139 this.isPostPersist() ||
140 this.isPostRemove() ||
141 this.isPostUpdate() ||
142 this.isPrePersist() ||
143 this.isPreRemove() ||
144 this.isPreUpdate();
145 }
146
147
148
149
150 @Override
151 protected String handleGetImplementationName()
152 {
153 return this.getImplementationOperationName(StringUtils.capitalize(this.getName()));
154 }
155
156
157
158
159 @Override
160 protected String handleGetImplementationCall()
161 {
162 return this.getImplementationOperationName(StringUtils.capitalize(this.getCall()));
163 }
164
165
166
167
168 @Override
169 protected String handleGetImplementationSignature()
170 {
171 return this.getImplementationOperationName(StringUtils.capitalize(this.getSignature()));
172 }
173
174
175
176
177
178
179
180
181 private String getImplementationOperationName(final String replacement)
182 {
183 String implementationNamePattern =
184 (String)this.getConfiguredProperty(EJB3Globals.IMPLEMENTATION_OPERATION_NAME_PATTERN);
185
186 return MessageFormat.format(
187 implementationNamePattern,
188 StringUtils.trimToEmpty(replacement));
189 }
190 }