DecisionServiceBase.java

// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by SpringServiceBase.vsl in andromda-spring-cartridge. Do not modify by hand!.
//
/**
 * TEMPLATE:    SpringServiceBase.vsl in andromda-spring cartridge
 * MODEL CLASS: AnimalQuiz::org.andromda.samples.animalquiz::decisiontree::DecisionService
 * STEREOTYPE:  Service
 * STEREOTYPE:  WebService
 */
package org.andromda.samples.animalquiz.decisiontree;

import java.security.Principal;
import java.util.Locale;
import org.andromda.samples.animalquiz.BeanLocator;
import org.andromda.samples.animalquiz.PrincipalStore;
import org.springframework.context.MessageSource;

/**
 * <p>
 * Spring Service base class for <code>DecisionService</code>,
 * provides access to all services and entities referenced by this service.
 * </p>
 *
 * @see DecisionService
 */
public abstract class DecisionServiceBase
    implements DecisionService
{
    private DecisionItemDao decisionItemDao;

    /**
     * Sets the reference to <code>decisionItem</code>'s DAO.
     * @param decisionItemDaoIn
     */
    public void setDecisionItemDao(DecisionItemDao decisionItemDaoIn)
    {
        this.decisionItemDao = decisionItemDaoIn;
    }

    /**
     * Gets the reference to <code>decisionItem</code>'s DAO.
     * @return decisionItemDao
     */
    protected DecisionItemDao getDecisionItemDao()
    {
        return this.decisionItemDao;
    }

    private AnimalDao animalDao;

    /**
     * Sets the reference to <code>animal</code>'s DAO.
     * @param animalDaoIn
     */
    public void setAnimalDao(AnimalDao animalDaoIn)
    {
        this.animalDao = animalDaoIn;
    }

    /**
     * Gets the reference to <code>animal</code>'s DAO.
     * @return animalDao
     */
    protected AnimalDao getAnimalDao()
    {
        return this.animalDao;
    }

    private QuestionDao questionDao;

    /**
     * Sets the reference to <code>question</code>'s DAO.
     * @param questionDaoIn
     */
    public void setQuestionDao(QuestionDao questionDaoIn)
    {
        this.questionDao = questionDaoIn;
    }

    /**
     * Gets the reference to <code>question</code>'s DAO.
     * @return questionDao
     */
    protected QuestionDao getQuestionDao()
    {
        return this.questionDao;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public VODecisionItem getFirstQuestion()
        throws DecisionException
    {
        try
        {
            return this.handleGetFirstQuestion();
        }
        catch (DecisionException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new DecisionServiceException(
                "Error performing 'DecisionService.getFirstQuestion()' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #getFirstQuestion()}
     * @return VODecisionItem
     * @throws Exception
     */
    protected abstract VODecisionItem handleGetFirstQuestion()
        throws Exception;

    /**
     * {@inheritDoc}
     */
    @Override
    public VODecisionItem getNextQuestion(final Long itemId)
        throws DecisionException
    {
        try
        {
            return this.handleGetNextQuestion(itemId);
        }
        catch (DecisionException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new DecisionServiceException(
                "Error performing 'DecisionService.getNextQuestion(Long itemId)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #getNextQuestion(Long)}
     * @param itemId Long <p>
TODO: Model Documentation for itemId
</p>
     * @return VODecisionItem
     * @throws Exception
     */
    protected abstract VODecisionItem handleGetNextQuestion(Long itemId)
        throws Exception;

    /**
     * {@inheritDoc}
     */
    @Override
    public void addNewAnimalWithQuestion(final String animalName, final String promptForYes, final Long idOfLastNoDecision)
        throws DecisionException
    {
        try
        {
            this.handleAddNewAnimalWithQuestion(animalName, promptForYes, idOfLastNoDecision);
        }
        catch (DecisionException ex)
        {
            throw ex;
        }
        catch (Throwable th)
        {
            throw new DecisionServiceException(
                "Error performing 'DecisionService.addNewAnimalWithQuestion(String animalName, String promptForYes, Long idOfLastNoDecision)' --> " + th,
                th);
        }
    }

    /**
     * Performs the core logic for {@link #addNewAnimalWithQuestion(String, String, Long)}
     * @param animalName String <p>
TODO: Model Documentation for animalName
</p>
     * @param promptForYes String <p>
TODO: Model Documentation for promptForYes
</p>
     * @param idOfLastNoDecision Long <p>
TODO: Model Documentation for idOfLastNoDecision
</p>
     * @return void
     * @throws Exception
     */
    protected abstract void handleAddNewAnimalWithQuestion(String animalName, String promptForYes, Long idOfLastNoDecision)
        throws Exception;

    /**
     * Gets the current <code>principal</code> if one has been set,
     * otherwise returns <code>null</code>.
     *
     * @return the current principal
     */
    protected Principal getPrincipal()
    {
        return PrincipalStore.get();
    }

    /**
     * Gets the message source available to this service.
     * @return MessageSource
     */
    protected MessageSource getMessages()
    {
        return (MessageSource)
            BeanLocator.instance().getBean("messageSource");
    }

    /**
     * Gets the message having the given <code>key</code> in the underlying message bundle.
     *
     * @param key the key of the message in the messages.properties message bundle.
     * @return String
     */
    protected String getMessage(final String key)
    {
        return this.getMessages().getMessage(key, null, null);
    }

    /**
     * Gets the message having the given <code>key</code> and <code>arguments</code> in the
     * underlying message bundle.
     *
     * @param key the key of the message in the messages.properties message bundle.
     * @param arguments any arguments to substitute when resolving the message.
     * @return String
     */
    protected String getMessage(final String key, final Object[] arguments)
    {
        return this.getMessages().getMessage(key, arguments, null);
    }

    /**
     * Gets the message having the given <code>key</code> using the given <code>arguments</code>
     * for the given <code>locale</code>.
     *
     * @param key the key of the message in the messages.properties message bundle.
     * @param arguments any arguments to substitute when resolving the message.
     * @param locale the locale of the messages to retrieve.
     * @return String
     */
    protected String getMessage(
        final String key, final Object[] arguments,
        final Locale locale)
    {
        return this.getMessages().getMessage(key, arguments, locale);
    }


// spring-service-base merge-point
}