1 package org.andromda.cartridges.jsf2.metafacades;
2
3 import org.andromda.cartridges.jsf2.JSFGlobals;
4 import org.andromda.metafacades.uml.ModelElementFacade;
5 import org.apache.commons.lang.ObjectUtils;
6 import org.apache.commons.lang.StringUtils;
7
8
9
10
11
12
13 public class JSFControllerOperationLogicImpl
14 extends JSFControllerOperationLogic
15 {
16 private static final long serialVersionUID = 34L;
17
18
19
20
21 public JSFControllerOperationLogicImpl(Object metaObject, String context)
22 {
23 super(metaObject, context);
24 }
25
26
27
28
29
30 protected String handleGetFormName()
31 {
32 final String pattern = ObjectUtils.toString(this.getConfiguredProperty(JSFGlobals.FORM_PATTERN));
33 return pattern.replaceFirst("\\{0\\}", StringUtils.capitalize(this.getName()));
34 }
35
36
37
38
39
40 protected String handleGetFullyQualifiedFormName()
41 {
42 final StringBuilder fullyQualifiedName = new StringBuilder();
43 final String packageName = this.getPackageName();
44 if (StringUtils.isNotBlank(packageName))
45 {
46 fullyQualifiedName.append(packageName + '.');
47 }
48 return fullyQualifiedName.append(StringUtils.capitalize(this.getFormName())).toString();
49 }
50
51
52
53
54
55 protected String handleGetFullyQualifiedFormPath()
56 {
57 return this.getFullyQualifiedFormName().replace('.', '/');
58 }
59
60
61
62
63
64 protected String handleGetFormCall()
65 {
66 final StringBuilder call = new StringBuilder();
67 call.append(this.getName());
68 call.append("(");
69 if (!this.getFormFields().isEmpty())
70 {
71 call.append("form");
72 }
73 call.append(")");
74 return call.toString();
75 }
76
77
78
79
80
81 protected String handleGetImplementationFormSignature()
82 {
83 return this.getFormSignature(false);
84 }
85
86
87
88
89
90 protected String handleGetFormSignature()
91 {
92 return this.getFormSignature(true);
93 }
94
95
96
97
98
99
100
101 private String getFormSignature(boolean isAbstract)
102 {
103 final StringBuilder signature = new StringBuilder();
104 signature.append(this.getVisibility() + ' ');
105 if (isAbstract)
106 {
107 signature.append("abstract ");
108 }
109 final ModelElementFacade returnType = this.getReturnType();
110 signature.append(returnType != null ? returnType.getFullyQualifiedName() : null);
111 signature.append(" " + this.getName() + "(");
112 if (!this.getFormFields().isEmpty())
113 {
114 signature.append(this.getFormName() + " form");
115 }
116 signature.append(")");
117 return signature.toString();
118 }
119 }