Package org.ametys.plugins.forms.dao
Class FormQuestionDAO
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.forms.dao.FormQuestionDAO
- All Implemented Interfaces:
LogEnabled
,Component
,Contextualizable
,Serviceable
public class FormQuestionDAO
extends AbstractLogEnabled
implements Serviceable, Component, Contextualizable
DAO for manipulating form questions
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
Record for entry values coming from input or from the entry -
Field Summary
Modifier and TypeFieldDescriptionprotected ChoiceSourceTypeExtensionPoint
The choice source type extension pointprotected Context
The cocoon contextprotected Context
The Avalon contextprotected CopyFormUpdaterExtensionPoint
The copy form updater extension pointprotected CurrentUserProvider
The current user provider.protected FormDAO
The form DAOprotected FormQuestionTypeExtensionPoint
The form question type extension pointprotected I18nUtils
I18n Utilsprotected JSONUtils
JSON helperprotected ObservationManager
Observer manager.protected ParametersManager
The parameters managerprotected AmetysObjectResolver
Ametys object resolver.protected RightManager
The right managerprotected UploadManager
Manager for retrieving uploaded filesstatic final String
The Avalon rolestatic final String
Name for rules root jcr node -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected List<FormQuestion>
_getActiveQuestions
(Form form, FormQuestionDAO.FormEntryValues entryValues, Optional<Long> currentStepId, boolean onlyWritableQuestion, boolean onlyReadableQuestion) Get a list of the form questions not being hidden by a ruleprotected UserIdentity
Provides the current user._getPageTitlesWithRule
(FormQuestion question) Get the page titles having rule concerning the given question_getQuestionTitlesWithRule
(FormQuestion question) Get the question titles having rule concerning the given question_getUserRights
(FormQuestion question) Get user rights for the given form questionaddPageRule
(String id, String option, String rule, String page) Adds a new rule to a question.void
contextualize
(Context context) copyQuestion
(String pageId, String questionId) Copies and pastes a form question.createQuestion
(String pageId, String typeId) Creates aFormQuestion
.deletePageRule
(String id, String option) Deletes a rule to a question.deleteQuestion
(String id) Deletes aFormQuestion
.editQuestion
(String questionId, Map<String, Object> values) Edits aFormQuestion
.getChoiceListQuestionOptions
(String questionId) Get options from the choice list questiongetQuestionParametersDefinitions
(String typeID, String formId) Get view for question typegetQuestionParametersValues
(String questionID) Get questions parameters valuesGets properties of a form questiongetQuestionProperties
(FormQuestion question, boolean withRight) Gets properties of a form questiongetRuleFilteredQuestions
(Form form, FormQuestionDAO.FormEntryValues entryValues, Optional<Long> currentStepId, boolean onlyWritableQuestion, boolean onlyReadableQuestion) Get the list of active question depending of the form rulesGets the page rules for a form question.renameQuestion
(String id, String newName) Rename aFormQuestion
void
service
(ServiceManager serviceManager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The Avalon role -
RULES_ROOT
Name for rules root jcr node- See Also:
-
_resolver
Ametys object resolver. -
_observationManager
Observer manager. -
_currentUserProvider
The current user provider. -
_uploadManager
Manager for retrieving uploaded files -
_jsonUtils
JSON helper -
_i18nUtils
I18n Utils -
_formQuestionTypeExtensionPoint
The form question type extension point -
_parametersManager
The parameters manager -
_context
The Avalon context -
_cocoonContext
The cocoon context -
_choiceSourceTypeExtensionPoint
The choice source type extension point -
_formDAO
The form DAO -
_rightManager
The right manager -
_copyFormEP
The copy form updater extension point
-
-
Constructor Details
-
FormQuestionDAO
public FormQuestionDAO()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
_getCurrentUser
Provides the current user.- Returns:
- the user which cannot be
null
.
-
getQuestionProperties
Gets properties of a form question- Parameters:
id
- The id of the form question- Returns:
- The properties
-
getQuestionProperties
Gets properties of a form question- Parameters:
question
- The form questionwithRight
-true
to have the rights in the properties- Returns:
- The properties
-
getChoiceListQuestionOptions
Get options from the choice list question- Parameters:
questionId
- the choice list question id- Returns:
- the map of option
-
_getUserRights
Get user rights for the given form question- Parameters:
question
- the form question- Returns:
- the set of rights
-
_getQuestionTitlesWithRule
Get the question titles having rule concerning the given question- Parameters:
question
- the question- Returns:
- the list of question titles
-
_getPageTitlesWithRule
Get the page titles having rule concerning the given question- Parameters:
question
- the question- Returns:
- the list of page titles
-
getQuestionParametersDefinitions
public Map<String,Object> getQuestionParametersDefinitions(String typeID, String formId) throws ProcessingException Get view for question type- Parameters:
typeID
- id of the question typeformId
- id of the form- Returns:
- the view parsed in json for configurableFormPanel
- Throws:
ProcessingException
- error while parsing view to json
-
getQuestionParametersValues
Get questions parameters values- Parameters:
questionID
- id of current question- Returns:
- map of question parameters value
-
createQuestion
Creates aFormQuestion
.- Parameters:
pageId
- id of current pagetypeId
- id of FormQuestionType- Returns:
- The id of the created form question, the id of the page and the id of the form
-
renameQuestion
Rename aFormQuestion
- Parameters:
id
- The id of the questionnewName
- The new name of the question- Returns:
- A result map
-
editQuestion
Edits aFormQuestion
.- Parameters:
questionId
- id of current questionvalues
- The question's values- Returns:
- The id of the edited form question, the id of the page and the id of the form
-
deleteQuestion
Deletes aFormQuestion
.- Parameters:
id
- The id of the form question to delete- Returns:
- The id of the form question, the id of the page and the id of the form
-
copyQuestion
Copies and pastes a form 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 form
-
getRules
Gets the page rules for a form question.- Parameters:
id
- The id of the form question.number
- The question number- Returns:
- The rules
- Throws:
Exception
- error while getting choice options
-
addPageRule
Adds a new rule to a question.- Parameters:
id
- The question idoption
- The optionrule
- The rule typepage
- The page to jump or skip- Returns:
- An empty map, or an error
-
deletePageRule
Deletes a rule to a question.- Parameters:
id
- The question idoption
- The option to delete- Returns:
- An empty map
-
getRuleFilteredQuestions
public List<FormQuestion> getRuleFilteredQuestions(Form form, FormQuestionDAO.FormEntryValues entryValues, Optional<Long> currentStepId, boolean onlyWritableQuestion, boolean onlyReadableQuestion) Get the list of active question depending of the form rules- Parameters:
form
- the formentryValues
- the entry values to compute rulescurrentStepId
- the current step id. Can be empty if the form has no workflowonlyWritableQuestion
-true
to have only writable questiononlyReadableQuestion
-true
to have only readable question- Returns:
- the list of active question depending of the form rules
-
_getActiveQuestions
protected List<FormQuestion> _getActiveQuestions(Form form, FormQuestionDAO.FormEntryValues entryValues, Optional<Long> currentStepId, boolean onlyWritableQuestion, boolean onlyReadableQuestion) Get a list of the form questions not being hidden by a rule- Parameters:
form
- the current formentryValues
- the entry valuescurrentStepId
- current step of the entry. Can be empty if the form has no workflowonlyWritableQuestion
-true
to have only writable questiononlyReadableQuestion
-true
to have only readable question- Returns:
- a list of visible questions
-