Class QuestionnaireServiceImpl

java.lang.Object
com.flowable.questionnaire.service.QuestionnaireServiceImpl
All Implemented Interfaces:
QuestionnaireService

@Transactional(readOnly=true)
public class QuestionnaireServiceImpl
extends java.lang.Object
implements QuestionnaireService
A default implementation for the questionnaire service.
Author:
Filip Hrisafov, Micha Kiener
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected org.flowable.engine.HistoryService historyService  
    protected com.fasterxml.jackson.databind.ObjectMapper objectMapper  
    static java.lang.String PARAM_NAME_CONVERSATION_ID  
    static java.lang.String QUESTIONNAIRE_PROCESS_TYPE  
    protected org.flowable.engine.RepositoryService repositoryService  
    protected org.flowable.engine.RuntimeService runtimeService  
    protected org.flowable.engine.TaskService taskService  
    static java.lang.String VAR_NAME_ANSWER_VARIABLE  
    static java.lang.String VAR_NAME_FLOWABLE_PROCESS_DEFINITION_ID  
    static java.lang.String VAR_NAME_FLOWABLE_TASK_DEFINITION_ID  
    static java.lang.String VAR_NAME_MODEL_STARTS  
    static java.lang.String VAR_NAME_PARAMETERS  
    static java.lang.String VAR_NAME_QUESTION_TASK_ID  
    static java.lang.String VAR_NAME_QUESTIONS  
    static java.lang.String VAR_NAME_SELECTED_ANSWER_ID  
    static java.lang.String VAR_NAME_START  
    static java.lang.String VAR_NAME_TASK_MODEL_ID  
    static java.lang.String VAR_PROCESS_TYPE  
  • Constructor Summary

    Constructors 
    Constructor Description
    QuestionnaireServiceImpl​(org.flowable.engine.RepositoryService repositoryService, org.flowable.engine.RuntimeService runtimeService, org.flowable.engine.TaskService taskService, org.flowable.engine.HistoryService historyService, com.fasterxml.jackson.databind.ObjectMapper objectMapper)  
  • Method Summary

    Modifier and Type Method Description
    void deleteQuestionnaire​(java.lang.String id)
    Deletes the selected questionnaire instance with the given id.
    protected com.flowable.questionnaire.service.ProcessInstanceWrapper findProcessInstance​(java.lang.String id)  
    Questionnaire findQuestionnaire​(java.lang.String id, boolean onlyCurrentQuestion, java.lang.String lang)
    Returns the questionnaire instance with the given id, containing the current question (if still at least one open) and optionally the previous questions as well, if requested.
    protected Questionnaire getQuestionnaire​(java.lang.String id, boolean onlyCurrentQuestion, com.flowable.questionnaire.service.ProcessInstanceWrapper processInstance, org.flowable.bpmn.model.BpmnModel model, java.lang.String lang)  
    Questionnaire getQuestionnaire​(java.lang.String id, boolean onlyCurrentQuestion, java.lang.String lang)
    Returns the questionnaire instance with the given id, containing the current question (if still at least one open) and optionally the previous questions as well, if requested.
    java.util.List<QuestionnaireModel> getQuestionnaireModels​(java.lang.String lang)
    Returns a list of available questionnaire models to start questionnaire instances for.
    java.util.List<java.lang.String> getQuestionnaireStartingOptions​(java.lang.String modelKey, java.lang.String lang)
    Returns the list of available starting options for the requested questionnaire.
    protected java.util.List<? extends org.flowable.task.api.TaskInfo> getTasks​(java.lang.String questionnaireId, boolean onlyCurrentQuestion)  
    Questionnaire selectAnswer​(java.lang.String questionnaireId, java.lang.String answerId, java.util.Map<java.lang.String,​java.lang.Object> parameters, boolean onlyCurrentQuestion, java.lang.String lang)
    Selects an answer of the current question for the specified questionnaire given by its id with optional parameters if needed and returns the questionnaire data with the next question to be answered.
    protected Questionnaire startQuestionnaire​(java.lang.String modelId, java.lang.String modelKey, java.lang.String parentId, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.lang.String language, java.lang.String start)  
    Questionnaire startQuestionnaireByModelKey​(java.lang.String key, java.lang.String parentId, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.lang.String language, java.lang.String start)
    Starts a new questionnaire instance based on the specified model given by its global id with an optional map of parameters added to the questionnaire instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • QuestionnaireServiceImpl

      public QuestionnaireServiceImpl​(org.flowable.engine.RepositoryService repositoryService, org.flowable.engine.RuntimeService runtimeService, org.flowable.engine.TaskService taskService, org.flowable.engine.HistoryService historyService, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • getQuestionnaireModels

      public java.util.List<QuestionnaireModel> getQuestionnaireModels​(java.lang.String lang)
      Description copied from interface: QuestionnaireService
      Returns a list of available questionnaire models to start questionnaire instances for.
      Specified by:
      getQuestionnaireModels in interface QuestionnaireService
      Parameters:
      lang - the optional language in which the starting options need to be returned (defaults to the language of the edoras one user)
      Returns:
      the list of available questionnaire models
    • getQuestionnaireStartingOptions

      public java.util.List<java.lang.String> getQuestionnaireStartingOptions​(java.lang.String modelKey, java.lang.String lang)
      Description copied from interface: QuestionnaireService
      Returns the list of available starting options for the requested questionnaire. One of the returned starting options might be used as the start parameter when starting (creating) a new questionnaire.
      Specified by:
      getQuestionnaireStartingOptions in interface QuestionnaireService
      Parameters:
      modelKey - the global id or model name of the questionnaire model to return its starting options
      lang - the optional language in which the starting options need to be returned (defaults to the language of the edoras one user)
      Returns:
      the list of available starting options, must not be empty or null
    • startQuestionnaireByModelKey

      @Transactional public Questionnaire startQuestionnaireByModelKey​(java.lang.String key, java.lang.String parentId, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.lang.String language, java.lang.String start)
      Description copied from interface: QuestionnaireService
      Starts a new questionnaire instance based on the specified model given by its global id with an optional map of parameters added to the questionnaire instance.
      Specified by:
      startQuestionnaireByModelKey in interface QuestionnaireService
      Parameters:
      key - the global id of the questionnaire model to start a new instance for
      parameters - the optional map of parameters to be set on the questionnaire instance
      language - the optional language to set the questionnaire instance to (defaults to 'en' if not set)
      start - the optional starting point for the questionnaire instance, defaults to 'default', if not provided
      Returns:
      the questionnaire instance being started, containing the first question to be answered
    • startQuestionnaire

      protected Questionnaire startQuestionnaire​(java.lang.String modelId, java.lang.String modelKey, java.lang.String parentId, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.lang.String language, java.lang.String start)
    • getQuestionnaire

      public Questionnaire getQuestionnaire​(java.lang.String id, boolean onlyCurrentQuestion, java.lang.String lang)
      Description copied from interface: QuestionnaireService
      Returns the questionnaire instance with the given id, containing the current question (if still at least one open) and optionally the previous questions as well, if requested.
      Specified by:
      getQuestionnaire in interface QuestionnaireService
      Parameters:
      id - the id of the questionnaire to be returned
      onlyCurrentQuestion - true if only the current question should be returned, false if all the previous and answered questions should be returned as well
      lang - the optional language in which the starting options need to be returned (defaults to the language of the edoras one user)
      Returns:
      the questionnaire instance
    • findQuestionnaire

      public Questionnaire findQuestionnaire​(java.lang.String id, boolean onlyCurrentQuestion, java.lang.String lang)
      Description copied from interface: QuestionnaireService
      Returns the questionnaire instance with the given id, containing the current question (if still at least one open) and optionally the previous questions as well, if requested.
      Specified by:
      findQuestionnaire in interface QuestionnaireService
      Parameters:
      id - the id of the questionnaire to be returned
      onlyCurrentQuestion - true if only the current question should be returned, false if all the previous and answered questions should be returned as well
      lang - the optional language in which the starting options need to be returned (defaults to the language of the edoras one user)
      Returns:
      the questionnaire instance
    • getQuestionnaire

      protected Questionnaire getQuestionnaire​(java.lang.String id, boolean onlyCurrentQuestion, com.flowable.questionnaire.service.ProcessInstanceWrapper processInstance, org.flowable.bpmn.model.BpmnModel model, java.lang.String lang)
    • findProcessInstance

      protected com.flowable.questionnaire.service.ProcessInstanceWrapper findProcessInstance​(java.lang.String id)
    • getTasks

      protected java.util.List<? extends org.flowable.task.api.TaskInfo> getTasks​(java.lang.String questionnaireId, boolean onlyCurrentQuestion)
    • selectAnswer

      @Transactional public Questionnaire selectAnswer​(java.lang.String questionnaireId, java.lang.String answerId, java.util.Map<java.lang.String,​java.lang.Object> parameters, boolean onlyCurrentQuestion, java.lang.String lang)
      Description copied from interface: QuestionnaireService
      Selects an answer of the current question for the specified questionnaire given by its id with optional parameters if needed and returns the questionnaire data with the next question to be answered.
      Specified by:
      selectAnswer in interface QuestionnaireService
      Parameters:
      questionnaireId - the id of the questionnaire to answer the current question
      answerId - the id of the answer to select for the current question
      parameters - the optional map of parameters attached to the answer, if needed
      onlyCurrentQuestion - true if only the next question should be returned, false if all the previous and answered questions should be returned as well
      lang - the optional language in which the starting options need to be returned (defaults to the language of the edoras one user)
      Returns:
      the questionnaire data with the next current question to be answered and optional with all previous questions and answers selected
    • deleteQuestionnaire

      @Transactional public void deleteQuestionnaire​(java.lang.String id)
      Description copied from interface: QuestionnaireService
      Deletes the selected questionnaire instance with the given id.
      Specified by:
      deleteQuestionnaire in interface QuestionnaireService
      Parameters:
      id - the id of the questionnaire instance to be deleted