View Javadoc
1   package org.andromda.cartridges.ejb3.metafacades;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   import org.andromda.cartridges.ejb3.EJB3Profile;
6   import org.apache.commons.lang.BooleanUtils;
7   import org.apache.commons.lang.StringUtils;
8   
9   /**
10   * MetafacadeLogic implementation for org.andromda.cartridges.ejb3.metafacades.EJB3SessionAttributeFacade.
11   *
12   * @see EJB3SessionAttributeFacade
13   */
14  public class EJB3SessionAttributeFacadeLogicImpl
15      extends EJB3SessionAttributeFacadeLogic
16  {
17      private static final long serialVersionUID = 34L;
18      // ---------------- constructor -------------------------------
19  
20      /**
21       * @param metaObject
22       * @param context
23       */
24      public EJB3SessionAttributeFacadeLogicImpl(final Object metaObject, final String context)
25      {
26          super (metaObject, context);
27      }
28  
29      // ---------------- methods -------------------------------
30  
31      /**
32       * @see EJB3SessionAttributeFacade#getTransactionType()
33       */
34      @Override
35      protected String handleGetTransactionType()
36      {
37          return (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_TRANSACTION_TYPE, true);
38      }
39  
40      /**
41       * @see EJB3SessionAttributeFacadeLogic#handleIsSeamAttribute()
42       */
43      @Override
44      protected boolean handleIsSeamAttribute()
45      {
46          boolean isSeamAttribute = false;
47          if (this.isSeamBijectionIn() ||
48                  this.isSeamBijectionLogger() ||
49                  this.isSeamBijectionOut() ||
50                  this.isSeamBijectionRequestParameter() ||
51                  this.isSeamDataModel() ||
52                  this.isSeamDataModelSelection())
53          {
54              isSeamAttribute = true;
55          }
56          return isSeamAttribute;
57      }
58  
59      /**
60       * @see EJB3SessionAttributeFacadeLogic#handleIsSeamBijectionIn()
61       */
62      @Override
63      protected boolean handleIsSeamBijectionIn()
64      {
65          return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_BIJECTION_IN);
66      }
67  
68      /**
69       * @see EJB3SessionAttributeFacadeLogic#handleGetSeamBijectionInParameters()
70       */
71      @Override
72      protected String handleGetSeamBijectionInParameters()
73      {
74          List<String> parameters = new ArrayList<String>();
75          if (!super.isRequired())
76          {
77              parameters.add("required = false");
78          }
79          else
80          {
81              if (BooleanUtils.toBoolean(
82                      (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_IN_CREATE, true)))
83              {
84                  parameters.add("create = true");
85              }
86          }
87          String value = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_IN_VALUE, true);
88          if (StringUtils.isNotBlank(value))
89          {
90              parameters.add("value = \"" + value + '\"');
91          }
92  
93          return EJB3MetafacadeUtils.buildAnnotationParameters(parameters);
94      }
95  
96      /**
97       * @see EJB3SessionAttributeFacadeLogic#handleIsSeamBijectionOut()
98       */
99      @Override
100     protected boolean handleIsSeamBijectionOut()
101     {
102         return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_BIJECTION_OUT);
103     }
104 
105     /**
106      * @see EJB3SessionAttributeFacadeLogic#handleGetSeamBijectionOutParameters()
107      */
108     @Override
109     protected String handleGetSeamBijectionOutParameters()
110     {
111         List<String> parameters = new ArrayList<String>();
112         if (!super.isRequired())
113         {
114             parameters.add("required = false");
115         }
116 
117         String scope = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_OUT_SCOPE_TYPE, true);
118         if (StringUtils.isNotBlank(scope))
119         {
120             parameters.add("scope = org.jboss.seam.ScopeType." + scope);
121         }
122 
123         String value = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_OUT_VALUE, true);
124         if (StringUtils.isNotBlank(value))
125         {
126             parameters.add("value = \"" + value + '\"');
127         }
128 
129         return EJB3MetafacadeUtils.buildAnnotationParameters(parameters);
130     }
131 
132     /**
133      * @see EJB3SessionAttributeFacadeLogic#handleIsSeamValidationValid()
134      */
135     @Override
136     protected boolean handleIsSeamValidationValid()
137     {
138         boolean isSeamValidComponent = false;
139         if (this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_VALIDATION_VALID))
140         {
141             isSeamValidComponent = true;
142         }
143         return isSeamValidComponent;
144     }
145 
146     /**
147      * @see EJB3SessionAttributeFacadeLogic#handleIsSeamDataModel()
148      */
149     @Override
150     protected boolean handleIsSeamDataModel()
151     {
152         return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_DATA_DATAMODEL);
153     }
154 
155     /**
156      * @see EJB3SessionAttributeFacadeLogic#handleGetSeamDataModelParameters()
157      */
158     @Override
159     protected String handleGetSeamDataModelParameters()
160     {
161         List<String> parameters = new ArrayList<String>();
162         String value = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_DATA_DATAMODEL_VALUE, true);
163         if (StringUtils.isNotBlank(value))
164         {
165             parameters.add("value = \"" + value + '\"');
166         }
167         String scope = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_DATA_DATAMODEL_SCOPE_TYPE, true);
168         if (StringUtils.isNotBlank(scope))
169         {
170             parameters.add("scope = org.jboss.seam.ScopeType." + scope);
171         }
172 
173         return EJB3MetafacadeUtils.buildAnnotationParameters(parameters);
174     }
175 
176     /**
177      * @see EJB3SessionAttributeFacadeLogic#handleIsSeamDataModelSelection()
178      */
179     @Override
180     protected boolean handleIsSeamDataModelSelection()
181     {
182         return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_DATA_DATAMODEL_SELECTION);
183     }
184 
185     /**
186      * @see EJB3SessionAttributeFacadeLogic#handleGetSeamDataModelSelectionParameters()
187      */
188     @Override
189     protected String handleGetSeamDataModelSelectionParameters()
190     {
191         List<String> parameters = new ArrayList<String>();
192         String value = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_DATA_DATAMODEL_SELECTION_VALUE, true);
193         if (StringUtils.isNotBlank(value))
194         {
195             parameters.add("value = \"" + value + '\"');
196         }
197 
198         return EJB3MetafacadeUtils.buildAnnotationParameters(parameters);
199     }
200 
201     /**
202      * @see EJB3SessionAttributeFacadeLogic#handleIsSeamDataModelSelection()
203      */
204     @Override
205     protected boolean handleIsSeamDataModelSelectionIndex()
206     {
207         return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_DATA_DATAMODEL_SELECTION_INDEX);
208     }
209 
210     /**
211      * @see EJB3SessionAttributeFacadeLogic#handleGetSeamDataModelSelectionIndexParameters()
212      */
213     @Override
214     protected String handleGetSeamDataModelSelectionIndexParameters()
215     {
216         List<String> parameters = new ArrayList<String>();
217         String value = (String)this.findTaggedValue(
218                 EJB3Profile.TAGGEDVALUE_SEAM_DATA_DATAMODEL_SELECTION_INDEX_VALUE, true);
219         if (StringUtils.isNotBlank(value))
220         {
221             parameters.add("value = \"" + value + '\"');
222         }
223 
224         return EJB3MetafacadeUtils.buildAnnotationParameters(parameters);
225     }
226 
227     /**
228      * @see EJB3SessionAttributeFacadeLogic#handleIsSeamBijectionLogger()
229      */
230     @Override
231     protected boolean handleIsSeamBijectionLogger()
232     {
233         return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_BIJECTION_LOGGER);
234     }
235 
236     /**
237      * @see EJB3SessionAttributeFacadeLogic#handleGetSeamBijectionLoggerParameters()
238      */
239     @Override
240     protected String handleGetSeamBijectionLoggerParameters()
241     {
242         if (!this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_BIJECTION_LOGGER))
243         {
244             return null;
245         }
246         List<String> parameters = new ArrayList<String>();
247         String value = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_LOGGER_VALUE, true);
248         if (StringUtils.isNotBlank(value))
249         {
250             parameters.add("value = \"" + value + '\"');
251         }
252 
253         return EJB3MetafacadeUtils.buildAnnotationParameters(parameters);
254     }
255 
256     /**
257      * @see EJB3SessionAttributeFacadeLogic#handleIsSeamBijectionRequestParameter()
258      */
259     @Override
260     protected boolean handleIsSeamBijectionRequestParameter()
261     {
262         return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_BIJECTION_REQUEST_PARAMETER);
263     }
264 
265     /**
266      * @see EJB3SessionAttributeFacadeLogic#handleGetSeamBijectionRequestParameterParameters()
267      */
268     @Override
269     protected String handleGetSeamBijectionRequestParameterParameters()
270     {
271         List<String> parameters = new ArrayList<String>();
272         String value = (String)this.findTaggedValue(
273                 EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_REQUEST_PARAMETER_VALUE, true);
274         if (StringUtils.isNotBlank(value))
275         {
276             parameters.add("value = \"" + value + '\"');
277         }
278 
279         return EJB3MetafacadeUtils.buildAnnotationParameters(parameters);
280     }
281 }