View Javadoc
1   package org.andromda.cartridges.jsf2.metafacades;
2   
3   import org.andromda.cartridges.jsf2.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   * MetafacadeLogic implementation for org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd.
13   *
14   * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd
15   */
16  public class JSFManageableEntityAssociationEndLogicImpl
17      extends JSFManageableEntityAssociationEndLogic
18  {
19      private static final long serialVersionUID = 34L;
20      /**
21       * @param metaObject
22       * @param context
23       */
24      public JSFManageableEntityAssociationEndLogicImpl(Object metaObject, String context)
25      {
26          super(metaObject, context);
27      }
28  
29      /**
30       * @return messageKey
31       * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getMessageKey()
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       * @return messageValue
55       * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getMessageValue()
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       * @return getMessageKey() + ".online.help"
72       * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getOnlineHelpKey()
73       */
74      protected String handleGetOnlineHelpKey()
75      {
76          return this.getMessageKey() + ".online.help";
77      }
78  
79      /**
80       * @return onlineHelpValue
81       * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getOnlineHelpValue()
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       * @return backingListName
91       * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getBackingListName()
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      * @return valueListName
105      * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getValueListName()
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      * @return labelListName
116      * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getLabelListName()
117      */
118     protected String handleGetLabelListName()
119     {
120         return ObjectUtils.toString(this.getConfiguredProperty(JSFGlobals.LABEL_LIST_PATTERN)).replaceAll(
121             "\\{0\\}",
122             this.getName());
123     }
124     
125     //TODO should go to ancestor
126     @Override
127     public boolean isDisplay()
128     {
129         return super.isDisplay() && (getType() instanceof ManageableEntity);
130     }
131 }