001package org.andromda.cartridges.jbpm.metafacades;
002
003import org.andromda.cartridges.jbpm.JBpmProfile;
004import org.andromda.metafacades.uml.UseCaseFacade;
005import org.andromda.utils.StringUtilsHelper;
006import org.apache.commons.lang.StringUtils;
007
008/**
009 * MetafacadeLogic implementation for org.andromda.cartridges.jbpm.metafacades.JBpmSwimlane.
010 *
011 * @see org.andromda.cartridges.jbpm.metafacades.JBpmSwimlane
012 */
013public class JBpmSwimlaneLogicImpl
014    extends JBpmSwimlaneLogic
015{
016    private static final long serialVersionUID = 34L;
017    /**
018     * @param metaObject
019     * @param context
020     */
021    public JBpmSwimlaneLogicImpl(Object metaObject, String context)
022    {
023        super(metaObject, context);
024    }
025
026    /**
027     * @see org.andromda.cartridges.jbpm.metafacades.JBpmSwimlaneLogic#handleIsContainedInBusinessProcess()
028     */
029    protected boolean handleIsContainedInBusinessProcess()
030    {
031        return this.getActivityGraph().getUseCase() instanceof JBpmProcessDefinition;
032    }
033
034    /**
035     * @see org.andromda.cartridges.jbpm.metafacades.JBpmSwimlaneLogic#handleGetAssignmentExpression()
036     */
037    protected String handleGetAssignmentExpression()
038    {
039        return (String)findTaggedValue(JBpmProfile.TAGGEDVALUE_ASSIGNMENT_EXPRESSION);
040    }
041
042    /**
043     * @see org.andromda.cartridges.jbpm.metafacades.JBpmSwimlaneLogic#handleGetClazz()
044     */
045    protected String handleGetClazz()
046    {
047        String assignmentHandlerClass = null;
048
049        final StringBuilder clazzBuffer = new StringBuilder();
050        if (StringUtils.isNotBlank(this.getAssignmentHandlerPackageName()))
051        {
052            clazzBuffer.append(this.getAssignmentHandlerPackageName());
053            clazzBuffer.append('.');
054        }
055        clazzBuffer.append(this.getAssignmentHandlerClassName());
056        assignmentHandlerClass = clazzBuffer.toString();
057
058        return assignmentHandlerClass;
059    }
060
061    /**
062     * @see org.andromda.cartridges.jbpm.metafacades.JBpmSwimlaneLogic#handleGetAssignmentHandlerClassName()
063     */
064    protected String handleGetAssignmentHandlerClassName()
065    {
066        return StringUtilsHelper.upperCamelCaseName(this.getName() + "Assignment");
067    }
068
069    /**
070     * @see org.andromda.cartridges.jbpm.metafacades.JBpmSwimlaneLogic#handleGetAssignmentHandlerPackageName()
071     */
072    protected String handleGetAssignmentHandlerPackageName()
073    {
074        String packageName = null;
075
076        final UseCaseFacade useCase = this.getActivityGraph().getUseCase();
077        if (useCase != null)
078        {
079            packageName = useCase.getPackageName();
080        }
081
082        return packageName;
083    }
084
085    /**
086     * @see org.andromda.cartridges.jbpm.metafacades.JBpmSwimlaneLogic#handleGetAssignmentHandlerFullPath()
087     */
088    protected String handleGetAssignmentHandlerFullPath()
089    {
090        return StringUtils.replace(this.getClazz(), ".", "/");
091    }
092}