Class SurveyQuestion
- java.lang.Object
-
- org.ametys.plugins.repository.AbstractAmetysObject
-
- org.ametys.plugins.repository.jcr.SimpleAmetysObject<F>
-
- org.ametys.plugins.repository.jcr.DefaultTraversableAmetysObject<F>
-
- org.ametys.plugins.survey.repository.AbstractSurveyElement<SurveyQuestionFactory>
-
- org.ametys.plugins.survey.repository.SurveyQuestion
-
- All Implemented Interfaces:
ACLAmetysObject
,AmetysObject
,CopiableAmetysObject
,DataAwareAmetysObject
,ModelLessDataAwareAmetysObject
,ModifiableModelLessDataAwareAmetysObject
,DataHolder
,ModelLessDataHolder
,ModifiableDataHolder
,ModifiableModelLessDataHolder
,JCRAmetysObject
,JCRTraversableAmetysObject
,MetadataAwareAmetysObject
,ModifiableMetadataAwareAmetysObject
,ModifiableACLAmetysObject
,ModifiableAmetysObject
,ModifiableTraversableAmetysObject
,RemovableAmetysObject
,TraversableAmetysObject
public class SurveyQuestion extends AbstractSurveyElement<SurveyQuestionFactory>
AmetysObject
for storing survey
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SurveyQuestion.QuestionType
Type of a page.
-
Field Summary
Fields Modifier and Type Field Description static String
OPTION_NAME_PREFIX
Prefix for options-
Fields inherited from class org.ametys.plugins.survey.repository.AbstractSurveyElement
PROPERTY_PICTURE, PROPERTY_PICTURE_ALTERNATIVE, PROPERTY_PICTURE_ID, PROPERTY_PICTURE_TYPE
-
-
Constructor Summary
Constructors Constructor Description SurveyQuestion(Node node, String parentPath, SurveyQuestionFactory factory)
Creates aSurveyQuestion
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRules(String option, SurveyRule.RuleType ruleType, String page)
Add a rule for branchingSurveyQuestion
copyTo(ModifiableTraversableAmetysObject parent, String name)
Copy the currentAmetysObject
to the given object.SurveyQuestion
copyTo(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo)
Copy the currentAmetysObject
to the given object if it is not in the restriction list.void
deleteRule(String option)
Delete a ruleMap<String,String>
getColumns()
Get columnsString
getLabel()
Retrieves the label.Map<String,String>
getOptions()
Get optionsString
getRegExpPattern()
Get the validation pattern.String
getRegExpType()
Retrieves the regexp type.List<SurveyRule>
getRules()
Get the rulesSurvey
getSurvey()
Get the survey to which this question belongs.SurveyPage
getSurveyPage()
Get the page to which this question belongs.String
getTitle()
Retrieves the title.SurveyQuestion.QuestionType
getType()
Retrieves the type.boolean
hasOtherOption()
Determines if the question has a "other" optionboolean
hasRule(String option)
Determines if a rule with given option existsboolean
isMandatory()
Determines if the question is mandatory.void
setColumns(Map<String,String> columns)
Set columnsvoid
setLabel(String label)
Set the label.void
setMandatory(boolean mandatory)
Set the mandatory.void
setOptions(Map<String,String> options)
Set optionsvoid
setOtherOption(boolean other)
Set the "other" option.void
setRegExpType(String regexp)
Set the regexp type.void
setTitle(String title)
Set the title.void
setType(SurveyQuestion.QuestionType type)
Set the type.-
Methods inherited from class org.ametys.plugins.survey.repository.AbstractSurveyElement
copyPictureTo, getDataHolder, getExternalPicture, getPictureAlternative, getPictureType, getResourcePictureId, removePictureMetas, setExternalPicture, setNoPicture, setPictureAlternative, setPictureType, setResourcePicture
-
Methods inherited from class org.ametys.plugins.repository.jcr.DefaultTraversableAmetysObject
addAllowedGroups, addAllowedProfilesForAnonymous, addAllowedProfilesForAnyConnectedUser, addAllowedUsers, addDeniedGroups, addDeniedProfilesForAnonymous, addDeniedProfilesForAnyConnectedUser, addDeniedUsers, createChild, disallowInheritance, getChild, getChildren, getProfilesForAnonymousAndAnyConnectedUser, getProfilesForGroups, getProfilesForUsers, hasChild, isInheritanceDisallowed, removeAllowedGroups, removeAllowedGroups, removeAllowedProfilesForAnonymous, removeAllowedProfilesForAnyConnectedUser, removeAllowedUsers, removeAllowedUsers, removeDeniedGroups, removeDeniedGroups, removeDeniedProfilesForAnonymous, removeDeniedProfilesForAnyConnectedUser, removeDeniedUsers, removeDeniedUsers
-
Methods inherited from class org.ametys.plugins.repository.jcr.SimpleAmetysObject
_getFactory, _invalidateName, _invalidateParentPath, getId, getMetadataHolder, getName, getNode, getParent, getParentPath, getPath, needsSave, remove, rename, revertChanges, saveChanges
-
Methods inherited from class org.ametys.plugins.repository.AbstractAmetysObject
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ametys.plugins.repository.AmetysObject
equals, getId, getName, getParent, getParentPath, getPath, hashCode
-
Methods inherited from interface org.ametys.plugins.repository.data.ametysobject.DataAwareAmetysObject
copyTo, dataToSAX, dataToSAX, getDataNames
-
Methods inherited from interface org.ametys.plugins.repository.jcr.JCRAmetysObject
getNode
-
Methods inherited from interface org.ametys.plugins.repository.data.ametysobject.ModelLessDataAwareAmetysObject
dataToSAX, getType, getValue, getValue, getValueOfType, getValueOfType, hasValue, hasValueOrEmpty, isMultiple
-
Methods inherited from interface org.ametys.plugins.repository.data.holder.ModelLessDataHolder
dataToSAX, hasValue, hasValueOrEmpty
-
Methods inherited from interface org.ametys.plugins.repository.ModifiableAmetysObject
needsSave, rename, revertChanges, saveChanges
-
Methods inherited from interface org.ametys.plugins.repository.metadata.ModifiableMetadataAwareAmetysObject
getMetadataHolder
-
Methods inherited from interface org.ametys.plugins.repository.data.ametysobject.ModifiableModelLessDataAwareAmetysObject
getComposite, getComposite, getParentDataHolder, getRepositoryData, getRootDataHolder, removeValue, setValue, setValue, synchronizeValues
-
Methods inherited from interface org.ametys.plugins.repository.RemovableAmetysObject
remove
-
Methods inherited from interface org.ametys.plugins.repository.TraversableAmetysObject
getChildAt, getChildPosition
-
-
-
-
Field Detail
-
OPTION_NAME_PREFIX
public static final String OPTION_NAME_PREFIX
Prefix for options- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SurveyQuestion
public SurveyQuestion(Node node, String parentPath, SurveyQuestionFactory factory)
Creates aSurveyQuestion
.- Parameters:
node
- the node backing thisAmetysObject
.parentPath
- the parent path in the Ametys hierarchy.factory
- theSurveyFactory
which creates the AmetysObject.
-
-
Method Detail
-
getLabel
public String getLabel() throws AmetysRepositoryException
Retrieves the label.- Returns:
- the label.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setLabel
public void setLabel(String label) throws AmetysRepositoryException
Set the label.- Parameters:
label
- the label.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getTitle
public String getTitle() throws AmetysRepositoryException
Retrieves the title.- Returns:
- the title.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setTitle
public void setTitle(String title) throws AmetysRepositoryException
Set the title.- Parameters:
title
- the title.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getType
public SurveyQuestion.QuestionType getType() throws AmetysRepositoryException
Retrieves the type.- Returns:
- the type.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setType
public void setType(SurveyQuestion.QuestionType type) throws AmetysRepositoryException
Set the type.- Parameters:
type
- the type.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getRegExpType
public String getRegExpType() throws AmetysRepositoryException
Retrieves the regexp type.- Returns:
- the regexp type.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setRegExpType
public void setRegExpType(String regexp) throws AmetysRepositoryException
Set the regexp type.- Parameters:
regexp
- the regexp type.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getRegExpPattern
public String getRegExpPattern() throws AmetysRepositoryException
Get the validation pattern.- Returns:
- the validation pattern.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
isMandatory
public boolean isMandatory() throws AmetysRepositoryException
Determines if the question is mandatory.- Returns:
- true if the question is mandatory.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setMandatory
public void setMandatory(boolean mandatory) throws AmetysRepositoryException
Set the mandatory.- Parameters:
mandatory
- true for mandatory- Throws:
AmetysRepositoryException
- if an error occurs.
-
hasOtherOption
public boolean hasOtherOption()
Determines if the question has a "other" option- Returns:
- true if the question has a "other" option
-
setOtherOption
public void setOtherOption(boolean other)
Set the "other" option. To be used only for single or multiple choice question- Parameters:
other
- true to add the "other" option
-
setOptions
public void setOptions(Map<String,String> options) throws AmetysRepositoryException
Set options- Parameters:
options
- the options as a Map of key, value- Throws:
AmetysRepositoryException
- if an error occurs.
-
getOptions
public Map<String,String> getOptions() throws AmetysRepositoryException
Get options- Returns:
- the options as a Map of key, value
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setColumns
public void setColumns(Map<String,String> columns) throws AmetysRepositoryException
Set columns- Parameters:
columns
- the columns as a Map of key, value- Throws:
AmetysRepositoryException
- if an error occurs.
-
getColumns
public Map<String,String> getColumns() throws AmetysRepositoryException
Get columns- Returns:
- the columns as a Map of key, value
- Throws:
AmetysRepositoryException
- if an error occurs.
-
addRules
public void addRules(String option, SurveyRule.RuleType ruleType, String page) throws AmetysRepositoryException
Add a rule for branching- Parameters:
option
- the chosen optionruleType
- the rule typepage
- the page to jump or skip. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.
-
hasRule
public boolean hasRule(String option) throws AmetysRepositoryException
Determines if a rule with given option exists- Parameters:
option
- the option- Returns:
- true if teh rule exists
- Throws:
AmetysRepositoryException
- if an error occurs.
-
deleteRule
public void deleteRule(String option) throws AmetysRepositoryException
Delete a rule- Parameters:
option
- the option to delete- Throws:
AmetysRepositoryException
- if an error occurs.
-
getRules
public List<SurveyRule> getRules() throws AmetysRepositoryException
Get the rules- Returns:
- the rules
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getSurveyPage
public SurveyPage getSurveyPage() throws AmetysRepositoryException
Get the page to which this question belongs.- Returns:
- the page to which this question belongs.
- Throws:
AmetysRepositoryException
- if a repository error occurs when retrieving the page attached to a survey
-
getSurvey
public Survey getSurvey() throws AmetysRepositoryException
Get the survey to which this question belongs.- Returns:
- the survey to which this question belongs.
- Throws:
AmetysRepositoryException
- if a repository error occurs when retrieving a survey
-
copyTo
public SurveyQuestion copyTo(ModifiableTraversableAmetysObject parent, String name) throws AmetysRepositoryException
Description copied from interface:CopiableAmetysObject
Copy the currentAmetysObject
to the given object. Be careful, this method save changes.- Parameters:
parent
- The parent of the new object. Can not be null.name
- Name of the new object. Can be null. If null, the new name will be get from the copied object- Returns:
- the created object
- Throws:
AmetysRepositoryException
- if an error occurs.
-
copyTo
public SurveyQuestion copyTo(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo) throws AmetysRepositoryException
Description copied from interface:CopiableAmetysObject
Copy the currentAmetysObject
to the given object if it is not in the restriction list. Be careful, this method save changes.- Parameters:
parent
- The parent of the new object. Can not be null.name
- Name of the new object. Can be null. If null, the new name will be get from the copied objectrestrictTo
- A restrict list ofCopiableAmetysObject
authorized to be copied- Returns:
- the created object
- Throws:
AmetysRepositoryException
- if an error occurs.
-
-