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.
-
Field Details
-
VAR_NAME_SELECTED_ANSWER_ID
public static final java.lang.String VAR_NAME_SELECTED_ANSWER_ID- See Also:
- Constant Field Values
-
VAR_NAME_FLOWABLE_PROCESS_DEFINITION_ID
public static final java.lang.String VAR_NAME_FLOWABLE_PROCESS_DEFINITION_ID- See Also:
- Constant Field Values
-
VAR_NAME_FLOWABLE_TASK_DEFINITION_ID
public static final java.lang.String VAR_NAME_FLOWABLE_TASK_DEFINITION_ID- See Also:
- Constant Field Values
-
VAR_NAME_TASK_MODEL_ID
public static final java.lang.String VAR_NAME_TASK_MODEL_ID- See Also:
- Constant Field Values
-
VAR_NAME_QUESTIONS
public static final java.lang.String VAR_NAME_QUESTIONS- See Also:
- Constant Field Values
-
VAR_NAME_PARAMETERS
public static final java.lang.String VAR_NAME_PARAMETERS- See Also:
- Constant Field Values
-
VAR_NAME_QUESTION_TASK_ID
public static final java.lang.String VAR_NAME_QUESTION_TASK_ID- See Also:
- Constant Field Values
-
VAR_NAME_START
public static final java.lang.String VAR_NAME_START- See Also:
- Constant Field Values
-
VAR_NAME_ANSWER_VARIABLE
public static final java.lang.String VAR_NAME_ANSWER_VARIABLE- See Also:
- Constant Field Values
-
VAR_NAME_MODEL_STARTS
public static final java.lang.String VAR_NAME_MODEL_STARTS- See Also:
- Constant Field Values
-
VAR_PROCESS_TYPE
public static final java.lang.String VAR_PROCESS_TYPE- See Also:
- Constant Field Values
-
QUESTIONNAIRE_PROCESS_TYPE
public static final java.lang.String QUESTIONNAIRE_PROCESS_TYPE- See Also:
- Constant Field Values
-
PARAM_NAME_CONVERSATION_ID
public static final java.lang.String PARAM_NAME_CONVERSATION_ID- See Also:
- Constant Field Values
-
repositoryService
protected final org.flowable.engine.RepositoryService repositoryService -
runtimeService
protected final org.flowable.engine.RuntimeService runtimeService -
taskService
protected final org.flowable.engine.TaskService taskService -
historyService
protected final org.flowable.engine.HistoryService historyService -
objectMapper
protected final com.fasterxml.jackson.databind.ObjectMapper objectMapper
-
-
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
Description copied from interface:QuestionnaireService
Returns a list of available questionnaire models to start questionnaire instances for.- Specified by:
getQuestionnaireModels
in interfaceQuestionnaireService
- 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 interfaceQuestionnaireService
- Parameters:
modelKey
- the global id or model name of the questionnaire model to return its starting optionslang
- 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 interfaceQuestionnaireService
- Parameters:
key
- the global id of the questionnaire model to start a new instance forparameters
- the optional map of parameters to be set on the questionnaire instancelanguage
- 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 interfaceQuestionnaireService
- Parameters:
id
- the id of the questionnaire to be returnedonlyCurrentQuestion
-true
if only the current question should be returned,false
if all the previous and answered questions should be returned as welllang
- 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 interfaceQuestionnaireService
- Parameters:
id
- the id of the questionnaire to be returnedonlyCurrentQuestion
-true
if only the current question should be returned,false
if all the previous and answered questions should be returned as welllang
- 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 interfaceQuestionnaireService
- Parameters:
questionnaireId
- the id of the questionnaire to answer the current questionanswerId
- the id of the answer to select for the current questionparameters
- the optional map of parameters attached to the answer, if neededonlyCurrentQuestion
-true
if only the next question should be returned,false
if all the previous and answered questions should be returned as welllang
- 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 interfaceQuestionnaireService
- Parameters:
id
- the id of the questionnaire instance to be deleted
-