1 package org.andromda.cartridges.ejb3.metafacades;
2
3 import java.text.MessageFormat;
4 import java.util.ArrayList;
5 import java.util.Collection;
6 import java.util.Iterator;
7 import java.util.LinkedHashSet;
8 import java.util.List;
9 import org.andromda.cartridges.ejb3.EJB3Globals;
10 import org.andromda.cartridges.ejb3.EJB3Profile;
11 import org.andromda.metafacades.uml.DependencyFacade;
12 import org.andromda.metafacades.uml.ModelElementFacade;
13 import org.andromda.metafacades.uml.OperationFacade;
14 import org.andromda.metafacades.uml.ParameterFacade;
15 import org.andromda.metafacades.uml.Role;
16 import org.apache.commons.collections.Closure;
17 import org.apache.commons.collections.CollectionUtils;
18 import org.apache.commons.collections.Predicate;
19 import org.apache.commons.collections.Transformer;
20 import org.apache.commons.lang.BooleanUtils;
21 import org.apache.commons.lang.StringUtils;
22
23
24
25
26
27
28 public class EJB3SessionOperationFacadeLogicImpl
29 extends EJB3SessionOperationFacadeLogic
30 {
31 private static final long serialVersionUID = 34L;
32
33
34
35 private static final String SERVICE_OPERATION_TEST_NAME_PATTERN = "serviceOperationTestNamePattern";
36
37
38
39
40
41 public EJB3SessionOperationFacadeLogicImpl(final Object metaObject, final String context)
42 {
43 super (metaObject, context);
44 }
45
46
47
48
49 @Override
50 protected String handleGetViewType()
51 {
52 String viewType = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_VIEWTYPE);
53 if (StringUtils.isBlank(viewType))
54 {
55 EJB3SessionFacade sessionFacade = (EJB3SessionFacade)this.getOwner();
56 if (StringUtils.isNotBlank(sessionFacade.getViewType()))
57 {
58 viewType = sessionFacade.getViewType();
59 }
60 else
61 {
62 viewType = EJB3Globals.VIEW_TYPE_BOTH;
63 }
64 }
65 return viewType;
66 }
67
68
69
70
71 @Override
72 protected boolean handleIsViewTypeRemote()
73 {
74 boolean isRemote = false;
75 if (this.getViewType().equalsIgnoreCase(EJB3Globals.VIEW_TYPE_REMOTE))
76 {
77 isRemote = true;
78 }
79 return isRemote;
80 }
81
82
83
84
85 @Override
86 protected boolean handleIsViewTypeLocal()
87 {
88 boolean isLocal = false;
89 if (this.getViewType().equalsIgnoreCase(EJB3Globals.VIEW_TYPE_LOCAL))
90 {
91 isLocal = true;
92 }
93 return isLocal;
94 }
95
96
97
98
99 @Override
100 protected boolean handleIsViewTypeBoth()
101 {
102 boolean isBoth = false;
103 if (this.getViewType().equalsIgnoreCase(EJB3Globals.VIEW_TYPE_BOTH))
104 {
105 isBoth = true;
106 }
107 return isBoth;
108 }
109
110
111
112
113 @Override
114 protected boolean handleIsViewTypeStrictlyLocal()
115 {
116 boolean isViewTypeStrictlyLocal = false;
117 String viewType = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_VIEWTYPE);
118 if (StringUtils.equalsIgnoreCase(viewType, EJB3Globals.VIEW_TYPE_LOCAL) || this.isViewTypeStrictlyBoth())
119 {
120 isViewTypeStrictlyLocal = true;
121 }
122 return isViewTypeStrictlyLocal;
123 }
124
125
126
127
128 @Override
129 protected boolean handleIsViewTypeStrictlyRemote()
130 {
131 boolean isViewTypeStrictlyRemote = false;
132 String viewType = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_VIEWTYPE);
133 if (StringUtils.equalsIgnoreCase(viewType, EJB3Globals.VIEW_TYPE_REMOTE) || this.isViewTypeStrictlyBoth())
134 {
135 isViewTypeStrictlyRemote = true;
136 }
137 return isViewTypeStrictlyRemote;
138 }
139
140
141
142
143 @Override
144 protected boolean handleIsViewTypeStrictlyBoth()
145 {
146 boolean isViewTypeStrictlyBoth = false;
147 String viewType = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_VIEWTYPE);
148 if (StringUtils.equalsIgnoreCase(viewType, EJB3Globals.VIEW_TYPE_BOTH))
149 {
150 isViewTypeStrictlyBoth = true;
151 }
152 return isViewTypeStrictlyBoth;
153 }
154
155
156
157
158 @Override
159 protected boolean handleIsViewTypeAbsoluteLocal()
160 {
161 boolean isViewTypeAsbolutelyLocal = false;
162 EJB3SessionFacade session = (EJB3SessionFacade)this.getOwner();
163 if (!this.isLifecycleCallback() &&
164 StringUtils.equalsIgnoreCase(this.getVisibility(), "public") &&
165 ((session.isViewTypeBoth() &&
166 ((session.isViewTypeStrictlyRemote() && this.isViewTypeStrictlyLocal()) ||
167 ((session.isViewTypeStrictlyLocal() || session.isViewTypeStrictlyBoth()) &&
168 !this.isViewTypeStrictlyRemote()))) ||
169 (session.isViewTypeStrictlyLocal() && !this.isViewTypeStrictlyRemote()) ||
170 this.isViewTypeStrictlyBoth()))
171 {
172 isViewTypeAsbolutelyLocal = true;
173 }
174 return isViewTypeAsbolutelyLocal;
175 }
176
177
178
179
180 @Override
181 protected boolean handleIsViewTypeAbsoluteRemote()
182 {
183 boolean isViewTypeAsbolutelyRemote = false;
184 EJB3SessionFacade session = (EJB3SessionFacade)this.getOwner();
185 if (!this.isLifecycleCallback() &&
186 StringUtils.equalsIgnoreCase(this.getVisibility(), "public") &&
187 ((session.isViewTypeBoth() &&
188 ((session.isViewTypeStrictlyLocal() && this.isViewTypeStrictlyRemote()) ||
189 ((session.isViewTypeStrictlyRemote() || session.isViewTypeStrictlyBoth()) &&
190 !this.isViewTypeStrictlyLocal()))) ||
191 (session.isViewTypeStrictlyRemote() && !this.isViewTypeStrictlyLocal()) ||
192 this.isViewTypeStrictlyBoth()))
193 {
194 isViewTypeAsbolutelyRemote = true;
195 }
196 return isViewTypeAsbolutelyRemote;
197 }
198
199
200
201
202 @Override
203 protected boolean handleIsViewTypeAbsoluteBoth()
204 {
205 boolean isViewTypeAbsolutelyBoth = false;
206 if (this.isViewTypeAbsoluteLocal() && this.isViewTypeAbsoluteRemote())
207 {
208 isViewTypeAbsolutelyBoth = true;
209 }
210 return isViewTypeAbsolutelyBoth;
211 }
212
213
214
215
216
217
218
219 public String getSignature()
220 {
221 String signature = super.getSignature();
222 if (this.isTimeoutCallback())
223 {
224 final StringBuilder timeoutSignature = new StringBuilder(this.getName());
225 timeoutSignature.append("(");
226 timeoutSignature.append("javax.ejb.Timer timer");
227 timeoutSignature.append(")");
228 signature = timeoutSignature.toString();
229 }
230 return signature;
231 }
232
233
234
235
236 @Override
237 protected String handleGetTestSignature()
238 {
239 return this.getTestName() + "()";
240 }
241
242
243
244
245 @Override
246 protected String handleGetTestName()
247 {
248 String serviceOperationTestNamePattern =
249 (String)this.getConfiguredProperty(SERVICE_OPERATION_TEST_NAME_PATTERN);
250
251 String name = this.getName();
252
253 List<OperationFacade> operations = this.getOwner().getOperations();
254 for (OperationFacade operation : operations)
255 {
256 if (operation.getName().equals(name) &&
257 !operation.getArgumentNames().equals(this.getArgumentNames()))
258 {
259
260 for (ParameterFacade argument : this.getArguments())
261 {
262 name += StringUtils.capitalize(argument.getName());
263 }
264 }
265 }
266
267
268 return MessageFormat.format(
269 serviceOperationTestNamePattern,
270 StringUtils.trimToEmpty(StringUtils.capitalize(name)));
271 }
272
273
274
275
276
277
278
279 public String getCall()
280 {
281 String call = super.getCall();
282 if (this.isTimeoutCallback())
283 {
284 final StringBuilder buffer = new StringBuilder(this.getName());
285 buffer.append("(");
286 buffer.append("timer");
287 buffer.append(")");
288 call = buffer.toString();
289 }
290 return call;
291 }
292
293
294
295
296
297
298 @Override
299 protected String handleGetTransactionType()
300 {
301 String transType = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_TRANSACTION_TYPE);
302 if (StringUtils.isNotBlank(transType))
303 {
304 transType = EJB3MetafacadeUtils.convertTransactionType(transType);
305 }
306 else
307 {
308 EJB3SessionFacade session = (EJB3SessionFacade)this.getOwner();
309 transType = session.getTransactionType();
310 }
311 return transType;
312 }
313
314
315
316
317 @Override
318 protected boolean handleIsBusinessOperation()
319 {
320 return !this.hasStereotype(EJB3Profile.STEREOTYPE_CREATE_METHOD);
321 }
322
323
324
325
326 @Override
327 protected String handleGetRolesAllowed()
328 {
329 StringBuilder rolesAllowed = null;
330 String separator = "";
331
332 for (final Iterator iter = this.getNonRunAsRoles().iterator(); iter.hasNext(); )
333 {
334 if (rolesAllowed == null)
335 {
336 rolesAllowed = new StringBuilder();
337 }
338 rolesAllowed.append(separator);
339 Role role = (Role)iter.next();
340 rolesAllowed.append('"');
341 rolesAllowed.append(role.getName());
342 rolesAllowed.append('"');
343 separator = ", ";
344 }
345 return rolesAllowed != null ? rolesAllowed.toString() : null;
346 }
347
348
349
350
351 @Override
352 protected boolean handleIsPermitAll()
353 {
354 boolean permitAll = false;
355 String permitAllStr = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_SECURITY_PERMIT_ALL);
356 if (StringUtils.isNotBlank(permitAllStr))
357 {
358 permitAll = BooleanUtils.toBoolean(permitAllStr);
359 }
360 return permitAll;
361 }
362
363
364
365
366 @Override
367 protected boolean handleIsDenyAll()
368 {
369 boolean denyAll = false;
370 String denyAllStr = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_SECURITY_DENY_ALL);
371 if (StringUtils.isNotBlank(denyAllStr))
372 {
373 denyAll = BooleanUtils.toBoolean(denyAllStr);
374 }
375 return denyAll;
376 }
377
378
379
380
381 @Override
382 protected String handleGetFlushMode()
383 {
384 return (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_EJB_PERSISTENCE_FLUSH_MODE);
385 }
386
387
388
389
390 @Override
391 protected String handleGetThrowsClause()
392 {
393 StringBuilder throwsClause = null;
394 if (this.isExceptionsPresent())
395 {
396 throwsClause = new StringBuilder(this.getExceptionList());
397 }
398 if (throwsClause != null)
399 {
400 throwsClause.insert(0, "throws ");
401 }
402 return throwsClause != null ? throwsClause.toString() : null;
403 }
404
405
406
407
408 @Override
409 protected String handleGetThrowsClause(String initialExceptions)
410 {
411 final StringBuilder throwsClause = new StringBuilder(initialExceptions);
412 if (this.getThrowsClause() != null)
413 {
414 throwsClause.insert(0, ", ");
415 throwsClause.insert(0, this.getThrowsClause());
416 }
417 else
418 {
419 throwsClause.insert(0, "throws ");
420 }
421 return throwsClause.toString();
422 }
423
424
425
426
427 protected Collection<Role> handleGetNonRunAsRoles()
428 {
429 final Collection<Role> roles = new LinkedHashSet<Role>();
430 if (this.getOwner() instanceof EJB3SessionFacade)
431 {
432 roles.addAll(((EJB3SessionFacade)this.getOwner()).getNonRunAsRoles());
433 }
434 Collection operationRoles = this.getTargetDependencies();
435 CollectionUtils.filter(
436 operationRoles,
437 new Predicate()
438 {
439 public boolean evaluate(Object object)
440 {
441 DependencyFacade dependency = (DependencyFacade)object;
442 return dependency != null
443 && dependency.getSourceElement() != null
444 && Role.class.isAssignableFrom(dependency.getSourceElement().getClass())
445 && !dependency.hasStereotype(EJB3Profile.STEREOTYPE_SECURITY_RUNAS);
446 }
447 });
448 CollectionUtils.transform(
449 operationRoles,
450 new Transformer()
451 {
452 public Object transform(Object object)
453 {
454 return ((DependencyFacade)object).getSourceElement();
455 }
456 });
457 roles.addAll(operationRoles);
458 final Collection allRoles = new LinkedHashSet(roles);
459
460
461 CollectionUtils.forAllDo(
462 roles,
463 new Closure()
464 {
465 public void execute(Object object)
466 {
467 if (object instanceof Role)
468 {
469 allRoles.addAll(((Role)object).getAllSpecializations());
470 }
471 }
472 });
473 return allRoles;
474 }
475
476
477
478
479 @Override
480 protected boolean handleIsTimeoutCallback()
481 {
482 return this.hasStereotype(EJB3Profile.STEREOTYPE_SERVICE_TIMER_TIMEOUT);
483 }
484
485
486
487
488 @Override
489 protected String handleGetImplementationName()
490 {
491 return this.getImplementationOperationName(StringUtils.capitalize(this.getName()));
492 }
493
494
495
496
497 @Override
498 protected String handleGetImplementationCall()
499 {
500 return this.getImplementationOperationName(StringUtils.capitalize(this.getCall()));
501 }
502
503
504
505
506 @Override
507 protected String handleGetImplementationSignature()
508 {
509 return ("public".equalsIgnoreCase(this.getVisibility()) ?
510 this.getImplementationOperationName(StringUtils.capitalize(this.getSignature())) :
511 this.getSignature());
512 }
513
514
515
516
517
518
519
520
521 private String getImplementationOperationName(String replacement)
522 {
523 String implementationNamePattern =
524 (String)this.getConfiguredProperty(EJB3Globals.IMPLEMENTATION_OPERATION_NAME_PATTERN);
525
526 return MessageFormat.format(
527 implementationNamePattern,
528 StringUtils.trimToEmpty(replacement));
529 }
530
531
532
533
534 protected Collection handleGetInterceptorReferences()
535 {
536 Collection references = this.getSourceDependencies();
537 CollectionUtils.filter(
538 references,
539 new Predicate()
540 {
541 public boolean evaluate(Object object)
542 {
543 DependencyFacade dependency = (DependencyFacade)object;
544 ModelElementFacade targetElement = dependency.getTargetElement();
545 return (targetElement != null && targetElement.hasStereotype(EJB3Profile.STEREOTYPE_INTERCEPTOR));
546 }
547 });
548 CollectionUtils.transform(
549 references,
550 new Transformer()
551 {
552 public Object transform(final Object object)
553 {
554 return ((DependencyFacade)object).getTargetElement();
555 }
556 });
557 final Collection interceptors = new LinkedHashSet(references);
558 CollectionUtils.forAllDo(
559 references,
560 new Closure()
561 {
562 public void execute(Object object)
563 {
564 if (object instanceof EJB3InterceptorFacade)
565 {
566 interceptors.addAll(((EJB3InterceptorFacade)object).getInterceptorReferences());
567 }
568 }
569 });
570 return interceptors;
571 }
572
573
574
575
576 @Override
577 protected boolean handleIsExcludeDefaultInterceptors()
578 {
579 boolean excludeDefault = false;
580 String excludeDefaultStr =
581 (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SERVICE_INTERCEPTOR_EXCLUDE_DEFAULT);
582 if (excludeDefaultStr != null)
583 {
584 excludeDefault = BooleanUtils.toBoolean(excludeDefaultStr);
585 }
586 return excludeDefault;
587 }
588
589
590
591
592 @Override
593 protected boolean handleIsExcludeClassInterceptors()
594 {
595 boolean excludeClass = false;
596 String excludeClassStr =
597 (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SERVICE_INTERCEPTOR_EXCLUDE_CLASS);
598 if (excludeClassStr != null)
599 {
600 excludeClass = BooleanUtils.toBoolean(excludeClassStr);
601 }
602 return excludeClass;
603 }
604
605
606
607
608 @Override
609 protected boolean handleIsPostConstruct()
610 {
611 return this.hasStereotype(EJB3Profile.STEREOTYPE_POST_CONSTRUCT);
612 }
613
614
615
616
617 @Override
618 protected boolean handleIsPreDestroy()
619 {
620 return this.hasStereotype(EJB3Profile.STEREOTYPE_PRE_DESTROY);
621 }
622
623
624
625
626 @Override
627 protected boolean handleIsPostActivate()
628 {
629 return this.hasStereotype(EJB3Profile.STEREOTYPE_POST_ACTIVATE);
630 }
631
632
633
634
635 @Override
636 protected boolean handleIsPrePassivate()
637 {
638 return this.hasStereotype(EJB3Profile.STEREOTYPE_PRE_PASSIVATE);
639 }
640
641
642
643
644 @Override
645 protected boolean handleIsLifecycleCallback()
646 {
647 return this.isPostConstruct() || this.isPreDestroy() || this.isPostActivate() || this.isPrePassivate();
648 }
649
650
651
652
653 @Override
654 protected boolean handleIsSeamValidationValidator()
655 {
656 boolean isSeamValidorMethod = false;
657 if (this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_VALIDATION_VALIDATOR))
658 {
659 isSeamValidorMethod = true;
660 }
661 return isSeamValidorMethod;
662 }
663
664
665
666
667 @Override
668 protected String handleGetSeamValidationOutcome()
669 {
670 String validationOutcome = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_VALIDATION_OUTCOME);
671 if (StringUtils.isNotBlank(validationOutcome) &&
672 !StringUtils.equals(validationOutcome, "org.jboss.seam.annotations.Outcome.REDISPLAY"))
673 {
674 validationOutcome = "\"" + validationOutcome + "\"";
675 }
676 return validationOutcome;
677 }
678
679
680
681
682 @Override
683 protected boolean handleIsSeamValidationRefreshEntities()
684 {
685 return BooleanUtils.toBoolean(
686 (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_VALIDATION_REFRESH_ENTITIES));
687 }
688
689
690
691
692 @Override
693 protected boolean handleIsSeamLifecycleCreate()
694 {
695 boolean isSeamLifecycleCreate = false;
696 if (this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_LIFECYCLE_CREATE))
697 {
698 isSeamLifecycleCreate = true;
699 }
700 return isSeamLifecycleCreate;
701 }
702
703
704
705
706 @Override
707 protected boolean handleIsSeamLifecycleDestroy()
708 {
709 boolean isSeamLifecycleCreate = false;
710 if (this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_LIFECYCLE_DESTROY))
711 {
712 isSeamLifecycleCreate = true;
713 }
714 return isSeamLifecycleCreate;
715 }
716
717
718
719
720 @Override
721 protected boolean handleIsSeamObserver()
722 {
723 boolean isSeamObserver = false;
724 if (this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_LIFECYCLE_OBSERVER_EVENT) != null)
725 {
726 isSeamObserver = true;
727 }
728 return isSeamObserver;
729 }
730
731
732
733
734 @Override
735 protected String handleGetSeamObserverEventName()
736 {
737 return "(\"" + this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_LIFECYCLE_OBSERVER_EVENT) + "\")";
738 }
739
740
741
742
743 @Override
744 protected boolean handleIsSeamAsynchronous()
745 {
746 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_ASYNCHRONOUS);
747 }
748
749
750
751
752 @Override
753 protected boolean handleIsSeamBijectionFactory()
754 {
755 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_BIJECTION_FACTORY);
756 }
757
758
759
760
761 @Override
762 protected String handleGetSeamBijectionFactoryParameters()
763 {
764 List<String> parameters = new ArrayList<String>();
765 String value = (String) this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_FACTORY_VALUE);
766 if(StringUtils.isNotBlank(value))
767 {
768 parameters.add("value = \"" + value + "\"");
769 }
770
771 String scope = (String) this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_BIJECTION_FACTORY_SCOPE_TYPE);
772 if(StringUtils.isNotBlank(scope))
773 {
774 parameters.add("scope = org.jboss.seam.ScopeType." + scope);
775 }
776
777 return EJB3MetafacadeUtils.buildAnnotationParameters(parameters);
778 }
779
780
781
782
783 @Override
784 protected boolean handleIsSeamConversationBegin()
785 {
786 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_CONVERSATION_BEGIN);
787 }
788
789
790
791
792 @Override
793 protected String handleGetSeamConversationBeginParameters()
794 {
795 if(!this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_CONVERSATION_BEGIN))
796 {
797 return null;
798 }
799 else
800 {
801 List<String> parameters = new ArrayList<String>();
802 String flushMode = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_BEGIN_FLUSH_MODE);
803 if(StringUtils.isNotBlank(flushMode))
804 {
805 parameters.add("flushMode = org.jboss.seam.annotations.FlushModeType." + flushMode);
806 }
807
808 String pageflow = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_BEGIN_PAGEFLOW);
809 if(StringUtils.isNotBlank(pageflow))
810 {
811 parameters.add("pageflow = \"" + pageflow + "\"");
812 }
813
814 String join = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_BEGIN_JOIN);
815 if(StringUtils.isNotBlank(join))
816 {
817 parameters.add("join = " + join.toLowerCase());
818 }
819
820 String nested = (String)this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_BEGIN_NESTED);
821 if(StringUtils.isNotBlank(nested))
822 {
823 parameters.add("nested = " + nested.toLowerCase());
824 }
825
826 Collection ifOutcome = this.findTaggedValues(EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_BEGIN_IF_OUTCOME);
827 if(ifOutcome != null && !ifOutcome.isEmpty())
828 {
829 parameters.add(EJB3MetafacadeUtils.buildAnnotationMultivalueParameter("ifOutcome", ifOutcome));
830 }
831 return EJB3MetafacadeUtils.buildAnnotationParameters(parameters);
832 }
833 }
834
835
836
837
838 @Override
839 protected boolean handleIsSeamConversationBeginTask()
840 {
841 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_CONVERSATION_BEGIN_TASK);
842 }
843
844
845
846
847 @Override
848 protected String handleGetSeamConversationBeginTaskParameters()
849 {
850 if(!this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_CONVERSATION_BEGIN_TASK))
851 {
852 return null;
853 }
854 else
855 {
856 List<String> parameters = new ArrayList<String>();
857 String flushMode = (String)this.findTaggedValue(
858 EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_BEGIN_TASK_FLUSH_MODE);
859 if(StringUtils.isNotBlank(flushMode))
860 {
861 parameters.add("flushMode = org.jboss.seam.annotations.FlushModeType." + flushMode + "\"");
862 }
863
864 String taskIdParameter = (String)this.findTaggedValue(
865 EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_BEGIN_TASK_ID_PARAMETER);
866 if(StringUtils.isNotBlank(taskIdParameter))
867 {
868 parameters.add("taskIdParameter = \"" + taskIdParameter + "\"");
869 }
870 return EJB3MetafacadeUtils.buildAnnotationParameters(parameters);
871 }
872 }
873
874
875
876
877 @Override
878 protected boolean handleIsSeamConversationCreateProcess()
879 {
880 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_CONVERSATION_CREATE_PROCESS);
881 }
882
883
884
885
886 @Override
887 protected String handleGetSeamConversationCreateProcessParameters()
888 {
889 return "(definition = \"" +
890 this.findTaggedValue(EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_CREATE_PROCESS_DEFINITION) + "\")";
891 }
892
893
894
895
896 @Override
897 protected boolean handleIsSeamConversationEnd()
898 {
899 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_CONVERSATION_END);
900 }
901
902
903
904
905 @Override
906 protected String handleGetSeamConversationEndParameters()
907 {
908 if(!this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_CONVERSATION_END))
909 {
910 return null;
911 }
912 else
913 {
914 List<String> parameters = new ArrayList<String>();
915 String beforeRedirect = (String)this.findTaggedValue(
916 EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_END_TASK_BEFORE_REDIRECT);
917 if(StringUtils.isNotBlank(beforeRedirect))
918 {
919 parameters.add("beforeRedirect = " + beforeRedirect.toLowerCase());
920 }
921
922 Collection ifOutcome = this.findTaggedValues(EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_END_IF_OUTCOME);
923 if(ifOutcome != null && !ifOutcome.isEmpty())
924 {
925 parameters.add(EJB3MetafacadeUtils.buildAnnotationMultivalueParameter("ifOutcome", ifOutcome));
926 }
927
928 Collection exceptions = this.findTaggedValues(
929 EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_END_EVEN_IF_EXCEPTION);
930 if(exceptions != null && !exceptions.isEmpty())
931 {
932 parameters.add(
933 EJB3MetafacadeUtils.buildAnnotationMultivalueParameter(
934 "ifOutcome",
935 ifOutcome,
936 false,
937 ".class"));
938 }
939 return EJB3MetafacadeUtils.buildAnnotationParameters(parameters);
940 }
941 }
942
943
944
945 @Override
946 protected boolean handleIsSeamConversationEndTask()
947 {
948 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_CONVERSATION_END_TASK);
949 }
950
951
952
953
954 @Override
955 protected String handleGetSeamConversationEndTaskParameters()
956 {
957 if(!this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_CONVERSATION_END_TASK))
958 {
959 return null;
960 }
961 else
962 {
963 List<String> parameters = new ArrayList<String>();
964 String transition = (String)this.findTaggedValue(
965 EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_END_TASK_TRANSITION_NAME);
966 if(StringUtils.isNotBlank(transition))
967 {
968 parameters.add("transition = \"" + transition + "\"");
969 }
970
971 String beforeRedirect = (String)this.findTaggedValue(
972 EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_END_TASK_BEFORE_REDIRECT);
973 if(StringUtils.isNotBlank(beforeRedirect))
974 {
975 parameters.add("beforeRedirect = " + beforeRedirect.toLowerCase());
976 }
977 Collection ifOutcome = this.findTaggedValues(EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_END_TASK_IF_OUTCOME);
978 if(ifOutcome != null && !ifOutcome.isEmpty())
979 {
980 parameters.add(EJB3MetafacadeUtils.buildAnnotationMultivalueParameter("ifOutcome", ifOutcome));
981 }
982 return EJB3MetafacadeUtils.buildAnnotationParameters(parameters);
983 }
984 }
985
986
987
988
989 @Override
990 protected boolean handleIsSeamConversationResumeProcess()
991 {
992 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_CONVERSATION_RESUME_PROCESS);
993 }
994
995
996
997
998 @Override
999 protected String handleGetSeamConversationResumeProcessParameters()
1000 {
1001 return "(processIdParameter = \"" +
1002 this.findTaggedValue(
1003 EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_RESUME_PROCESS_PROCESS_ID_PARAMETER) + "\")";
1004 }
1005
1006
1007
1008
1009 @Override
1010 protected boolean handleIsSeamConversationStartTask()
1011 {
1012 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_CONVERSATION_START_TASK);
1013 }
1014
1015
1016
1017
1018 @Override
1019 protected String handleGetSeamConversationStartTaskParameters()
1020 {
1021 if (!this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_CONVERSATION_START_TASK))
1022 {
1023 return null;
1024 }
1025 else
1026 {
1027 List<String> parameters = new ArrayList<String>();
1028 String flushMode = (String)this.findTaggedValue(
1029 EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_START_TASK_FLUSH_MODE);
1030 if (StringUtils.isNotBlank(flushMode))
1031 {
1032 parameters.add("flushMode = org.jboss.seam.annotations.FlushModeType." + flushMode);
1033 }
1034
1035 String taskIdParameter = (String)this.findTaggedValue(
1036 EJB3Profile.TAGGEDVALUE_SEAM_CONVERSATION_START_TASK_ID_PARAMETER);
1037 if (StringUtils.isNotBlank(taskIdParameter))
1038 {
1039 parameters.add("taskIdParameter = \"" + taskIdParameter + "\"");
1040 }
1041
1042 return EJB3MetafacadeUtils.buildAnnotationParameters(parameters);
1043 }
1044 }
1045
1046
1047
1048
1049 @Override
1050 protected boolean handleIsSeamTransactional()
1051 {
1052 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_TRANSACTION_TRANSACTIONAL);
1053 }
1054
1055
1056
1057
1058 @Override
1059 protected boolean handleIsSeamTransactionRollback()
1060 {
1061 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_TRANSACTION_ROLLBACK);
1062 }
1063
1064
1065
1066
1067 @Override
1068 protected String handleGetSeamTransactionRollbackParameters()
1069 {
1070 Collection outcomes = this.findTaggedValues(EJB3Profile.TAGGEDVALUE_SEAM_TRANSACTION_ROLLBACK_IF_OUTCOME);
1071 if (outcomes == null || outcomes.isEmpty())
1072 {
1073 return null;
1074 }
1075 else
1076 {
1077 return "(" + EJB3MetafacadeUtils.buildAnnotationMultivalueParameter("ifOutcome", outcomes) + ")";
1078 }
1079 }
1080
1081
1082
1083
1084 @Override
1085 protected boolean handleIsSeamWebRemote()
1086 {
1087 return this.hasStereotype(EJB3Profile.STEREOTYPE_SEAM_WEBREMOTE);
1088 }
1089
1090
1091
1092
1093 @Override
1094 protected String handleGetSeamWebRemoteParameters()
1095 {
1096 Collection excludes = this.findTaggedValues(EJB3Profile.TAGGEDVALUE_SEAM_WEBREMOTE_EXCLUDE);
1097 if(excludes == null || excludes.isEmpty())
1098 {
1099 return null;
1100 }
1101 else
1102 {
1103 return "(" + EJB3MetafacadeUtils.buildAnnotationMultivalueParameter("exclude", excludes) + ")";
1104 }
1105 }
1106 }