001package org.andromda.cartridges.bpm4struts.metafacades;
002
003import org.andromda.cartridges.bpm4struts.Bpm4StrutsUtils;
004import org.andromda.metafacades.uml.ClassifierFacade;
005import org.andromda.metafacades.uml.Entity;
006import org.andromda.utils.StringUtilsHelper;
007
008/**
009 * MetafacadeLogic implementation for org.andromda.cartridges.bpm4struts.metafacades.StrutsManageableEntityAssociationEnd.
010 *
011 * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsManageableEntityAssociationEnd
012 */
013public class StrutsManageableEntityAssociationEndLogicImpl
014    extends StrutsManageableEntityAssociationEndLogic
015{
016    private static final long serialVersionUID = 34L;
017    /**
018     * @param metaObject
019     * @param context
020     */
021    public StrutsManageableEntityAssociationEndLogicImpl(
022        Object metaObject,
023        String context)
024    {
025        super(metaObject, context);
026    }
027
028    /**
029     * @return messageKey
030     * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsManageableEntityAssociationEnd#getMessageKey()
031     */
032    protected String handleGetMessageKey()
033    {
034        final StringBuilder messageKeyBuffer = new StringBuilder();
035
036        final ClassifierFacade ownerType = this.getOtherEnd().getType();
037        messageKeyBuffer.append(ownerType.getName());
038        messageKeyBuffer.append('.');
039        messageKeyBuffer.append(this.getName());
040
041        return StringUtilsHelper.toResourceMessageKey(messageKeyBuffer.toString());
042    }
043
044    /**
045     * @return messageValue
046     * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsManageableEntityAssociationEnd#getMessageValue()
047     */
048    protected String handleGetMessageValue()
049    {
050        String messageValue = null;
051
052        final ClassifierFacade type = this.getType();
053        if (type instanceof Entity)
054        {
055            messageValue = this.getName();
056        }
057
058        return StringUtilsHelper.toPhrase(messageValue);
059    }
060
061    /**
062     * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsManageableEntityAssociationEndLogic#handleIsSafeNamePresent()
063     */
064    protected boolean handleIsSafeNamePresent()
065    {
066        return Bpm4StrutsUtils.isSafeName(this.getName());
067    }
068
069    /**
070     * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsManageableEntityAssociationEndLogic#handleGetOnlineHelpKey()
071     */
072    protected String handleGetOnlineHelpKey()
073    {
074        return this.getMessageKey() + ".online.help";
075    }
076
077    /**
078     * @see org.andromda.cartridges.bpm4struts.metafacades.StrutsManageableEntityAssociationEndLogic#handleGetOnlineHelpValue()
079     */
080    protected String handleGetOnlineHelpValue()
081    {
082        return (!this.isDocumentationPresent()) ? "No field documentation has been specified" :
083            StringUtilsHelper.toResourceMessage(this.getDocumentation("", 64, false));
084    }
085}