Package org.ametys.plugins.survey.dao
Class QuestionDAO
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.survey.dao.AbstractDAO
-
- org.ametys.plugins.survey.dao.QuestionDAO
-
- All Implemented Interfaces:
LogEnabled,Component,Contextualizable,Serviceable
public class QuestionDAO extends AbstractDAO
DAO for manipulating survey questions.
-
-
Field Summary
Fields Modifier and Type Field Description static StringROLEThe Avalon role-
Fields inherited from class org.ametys.plugins.survey.dao.AbstractDAO
_cocoonContext, _context, _currentUserProvider, _jsonUtils, _observationManager, _resolver, _siteManager, _uploadManager
-
-
Constructor Summary
Constructors Constructor Description QuestionDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void_setValues(SurveyQuestion question, Map<String,Object> values)Map<String,Object>addRule(String id, String option, String rule, String page)Adds a new rule to a question.Map<String,String>copyQuestion(String pageId, String questionId)Copies and pastes a survey question.Map<String,String>createQuestion(Map<String,Object> values)Creates a survey question.Map<String,String>deleteQuestion(String id)Deletes a survey question.Map<String,Object>deleteRule(String id, String option)Deletes a rule to a question.Map<String,String>editQuestion(Map<String,Object> values)Edits a survey question.Map<String,Object>getQuestion(String id)Gets properties of a survey questionMap<String,Object>getQuestion(SurveyQuestion question)Gets properties of a survey questionMap<String,Object>getRules(String id, int number)Gets the rules for a survey question.-
Methods inherited from class org.ametys.plugins.survey.dao.AbstractDAO
_getCurrentUser, contextualize, getPictureInfo, getSurveyRootNode, service, setPicture, updateReferencesAfterCopy, updateReferencesAfterCopy, updateReferencesAfterCopy
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Constructor Detail
-
QuestionDAO
public QuestionDAO()
-
-
Method Detail
-
getQuestion
public Map<String,Object> getQuestion(String id)
Gets properties of a survey question- Parameters:
id- The id of the survey question- Returns:
- The properties
-
getQuestion
public Map<String,Object> getQuestion(SurveyQuestion question)
Gets properties of a survey question- Parameters:
question- The survey question- Returns:
- The properties
-
createQuestion
public Map<String,String> createQuestion(Map<String,Object> values)
Creates a survey question.- Parameters:
values- The question's values- Returns:
- The id of the created survey question, the id of the page and the id of the survey
-
editQuestion
public Map<String,String> editQuestion(Map<String,Object> values)
Edits a survey question.- Parameters:
values- The question's values- Returns:
- The id of the edited survey question, the id of the page and the id of the survey
-
_setValues
private void _setValues(SurveyQuestion question, Map<String,Object> values)
-
copyQuestion
public Map<String,String> copyQuestion(String pageId, String questionId)
Copies and pastes a survey question.- Parameters:
pageId- The id of the page, target of the copyquestionId- The id of the question to copy- Returns:
- The id of the created question, the id of the page and the id of the survey
-
deleteQuestion
public Map<String,String> deleteQuestion(String id)
Deletes a survey question.- Parameters:
id- The id of the survey question to delete- Returns:
- The id of the deleted survey question, the id of the page and the id of the survey
-
addRule
public Map<String,Object> addRule(String id, String option, String rule, String page)
Adds a new rule to a question.- Parameters:
id- _resolver.resolveById(id);option- The optionrule- The rule typepage- The page to jump or skip- Returns:
- An empty map, or an error
-
deleteRule
public Map<String,Object> deleteRule(String id, String option)
Deletes a rule to a question.- Parameters:
id- _resolver.resolveById(id);option- The option to delete- Returns:
- An empty map
-
-