1 package org.andromda.cartridges.jsf.metafacades;
2
3 import org.andromda.cartridges.jsf.JSFGlobals;
4 import org.andromda.metafacades.uml.ClassifierFacade;
5 import org.andromda.metafacades.uml.Entity;
6 import org.andromda.metafacades.uml.ManageableEntity;
7 import org.andromda.utils.StringUtilsHelper;
8 import org.apache.commons.lang.ObjectUtils;
9 import org.apache.commons.lang.StringUtils;
10
11
12
13
14
15
16 public class JSFManageableEntityAssociationEndLogicImpl
17 extends JSFManageableEntityAssociationEndLogic
18 {
19 private static final long serialVersionUID = 34L;
20
21
22
23
24 public JSFManageableEntityAssociationEndLogicImpl(Object metaObject, String context)
25 {
26 super(metaObject, context);
27 }
28
29
30
31
32
33 protected String handleGetMessageKey()
34 {
35 final StringBuilder messageKeyBuffer = new StringBuilder();
36
37 final ClassifierFacade ownerType = this.getOtherEnd().getType();
38 if (ownerType instanceof ManageableEntity)
39 {
40 messageKeyBuffer.append(ownerType.getName());
41 }
42 else
43 {
44 messageKeyBuffer.append(ownerType.getName());
45 }
46
47 messageKeyBuffer.append('.');
48 messageKeyBuffer.append(this.getName());
49
50 return StringUtilsHelper.toResourceMessageKey(messageKeyBuffer.toString());
51 }
52
53
54
55
56
57 protected String handleGetMessageValue()
58 {
59 String messageValue = null;
60
61 final ClassifierFacade type = this.getType();
62 if (type instanceof Entity)
63 {
64 messageValue = this.getName();
65 }
66
67 return StringUtilsHelper.toPhrase(messageValue);
68 }
69
70
71
72
73
74 protected String handleGetOnlineHelpKey()
75 {
76 return this.getMessageKey() + ".online.help";
77 }
78
79
80
81
82
83 protected String handleGetOnlineHelpValue()
84 {
85 final String value = StringUtilsHelper.toResourceMessage(this.getDocumentation("", 64, false));
86 return (value == null) ? "No field documentation has been specified" : value;
87 }
88
89
90
91
92
93 protected String handleGetBackingListName()
94 {
95 final String backingListName =
96 StringUtils.replace(
97 ObjectUtils.toString(this.getConfiguredProperty(JSFGlobals.BACKING_LIST_PATTERN)),
98 "{0}",
99 this.getName());
100 return org.andromda.utils.StringUtilsHelper.lowerCamelCaseName(backingListName);
101 }
102
103
104
105
106
107 protected String handleGetValueListName()
108 {
109 return ObjectUtils.toString(this.getConfiguredProperty(JSFGlobals.VALUE_LIST_PATTERN)).replaceAll(
110 "\\{0\\}",
111 this.getName());
112 }
113
114
115
116
117
118 protected String handleGetLabelListName()
119 {
120 return ObjectUtils.toString(this.getConfiguredProperty(JSFGlobals.LABEL_LIST_PATTERN)).replaceAll(
121 "\\{0\\}",
122 this.getName());
123 }
124 }