001package org.andromda.cartridges.jsf2.metafacades; 002 003import org.andromda.cartridges.jsf2.JSFGlobals; 004import org.andromda.metafacades.uml.ClassifierFacade; 005import org.andromda.metafacades.uml.Entity; 006import org.andromda.metafacades.uml.ManageableEntity; 007import org.andromda.utils.StringUtilsHelper; 008import org.apache.commons.lang.ObjectUtils; 009import org.apache.commons.lang.StringUtils; 010 011/** 012 * MetafacadeLogic implementation for org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd. 013 * 014 * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd 015 */ 016public class JSFManageableEntityAssociationEndLogicImpl 017 extends JSFManageableEntityAssociationEndLogic 018{ 019 private static final long serialVersionUID = 34L; 020 /** 021 * @param metaObject 022 * @param context 023 */ 024 public JSFManageableEntityAssociationEndLogicImpl(Object metaObject, String context) 025 { 026 super(metaObject, context); 027 } 028 029 /** 030 * @return messageKey 031 * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getMessageKey() 032 */ 033 protected String handleGetMessageKey() 034 { 035 final StringBuilder messageKeyBuffer = new StringBuilder(); 036 037 final ClassifierFacade ownerType = this.getOtherEnd().getType(); 038 if (ownerType instanceof ManageableEntity) 039 { 040 messageKeyBuffer.append(ownerType.getName()); 041 } 042 else 043 { 044 messageKeyBuffer.append(ownerType.getName()); 045 } 046 047 messageKeyBuffer.append('.'); 048 messageKeyBuffer.append(this.getName()); 049 050 return StringUtilsHelper.toResourceMessageKey(messageKeyBuffer.toString()); 051 } 052 053 /** 054 * @return messageValue 055 * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getMessageValue() 056 */ 057 protected String handleGetMessageValue() 058 { 059 String messageValue = null; 060 061 final ClassifierFacade type = this.getType(); 062 if (type instanceof Entity) 063 { 064 messageValue = this.getName(); 065 } 066 067 return StringUtilsHelper.toPhrase(messageValue); 068 } 069 070 /** 071 * @return getMessageKey() + ".online.help" 072 * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getOnlineHelpKey() 073 */ 074 protected String handleGetOnlineHelpKey() 075 { 076 return this.getMessageKey() + ".online.help"; 077 } 078 079 /** 080 * @return onlineHelpValue 081 * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getOnlineHelpValue() 082 */ 083 protected String handleGetOnlineHelpValue() 084 { 085 final String value = StringUtilsHelper.toResourceMessage(this.getDocumentation("", 64, false)); 086 return (value == null) ? "No field documentation has been specified" : value; 087 } 088 089 /** 090 * @return backingListName 091 * @see org.andromda.cartridges.jsf2.metafacades.JSFManageableEntityAssociationEnd#getBackingListName() 092 */ 093 protected String handleGetBackingListName() 094 { 095 final String backingListName = 096 StringUtils.replace( 097 ObjectUtils.toString(this.getConfiguredProperty(JSFGlobals.BACKING_LIST_PATTERN)), 098 "{0}", 099 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}