public class SurveyQuestion extends AbstractSurveyElement<SurveyQuestionFactory>
AmetysObject
for storing surveyModifier and Type | Class and Description |
---|---|
static class |
SurveyQuestion.QuestionType
Type of a page.
|
Modifier and Type | Field and Description |
---|---|
private static String |
__NODE_NAME_COLUMNS
Constants for columns metadata.
|
private static String |
__NODE_NAME_OPTIONS
Constants for options metadata.
|
private static String |
__NODE_NAME_RULES
Constants for rules metadata.
|
private static String |
__PROPERTY_LABEL
Constants for title metadata.
|
private static String |
__PROPERTY_MANDATORY
Constants for mandatory metadata.
|
private static String |
__PROPERTY_OTHER_OPTION
Constants for other option metadata.
|
private static String |
__PROPERTY_REGEXP
Constants for regexp metadata.
|
private static String |
__PROPERTY_RULE_OPTION |
private static String |
__PROPERTY_RULE_PAGE |
private static String |
__PROPERTY_RULE_TYPE
Constants for rule metadata.
|
private static String |
__PROPERTY_TITLE
Constants for title metadata.
|
private static String |
__PROPERTY_TYPE
Constants for type metadata.
|
static String |
OPTION_NAME_PREFIX
Prefix for options
|
PROPERTY_PICTURE, PROPERTY_PICTURE_ALTERNATIVE, PROPERTY_PICTURE_ID, PROPERTY_PICTURE_TYPE
Constructor and Description |
---|
SurveyQuestion(Node node,
String parentPath,
SurveyQuestionFactory factory)
Creates a
SurveyQuestion . |
Modifier and Type | Method and Description |
---|---|
void |
addRules(String option,
SurveyRule.RuleType ruleType,
String page)
Add a rule for branching
|
SurveyQuestion |
copyTo(ModifiableTraversableAmetysObject parent,
String name)
Copy the current
AmetysObject to the given object. |
SurveyQuestion |
copyTo(ModifiableTraversableAmetysObject parent,
String name,
List<String> restrictTo)
Copy the current
AmetysObject to the given object if it is not in the restriction list. |
void |
deleteRule(String option)
Delete a rule
|
Map<String,String> |
getColumns()
Get columns
|
String |
getLabel()
Retrieves the label.
|
Map<String,String> |
getOptions()
Get options
|
String |
getRegExpPattern()
Get the validation pattern.
|
String |
getRegExpType()
Retrieves the regexp type.
|
List<SurveyRule> |
getRules()
Get the rules
|
Survey |
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" option
|
boolean |
hasRule(String option)
Determines if a rule with given option exists
|
boolean |
isMandatory()
Determines if the question is mandatory.
|
void |
setColumns(Map<String,String> columns)
Set columns
|
void |
setLabel(String label)
Set the label.
|
void |
setMandatory(boolean mandatory)
Set the mandatory.
|
void |
setOptions(Map<String,String> options)
Set options
|
void |
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.
|
copyPictureTo, getExternalPicture, getPictureAlternative, getPictureType, getResourcePictureId, removePictureMetas, setExternalPicture, setNoPicture, setPictureAlternative, setPictureType, setResourcePicture
addAllowedGroups, addAllowedProfilesForAnonymous, addAllowedProfilesForAnyConnectedUser, addAllowedUsers, addDeniedGroups, addDeniedProfilesForAnonymous, addDeniedProfilesForAnyConnectedUser, addDeniedUsers, createChild, getAllowedGroups, getAllowedProfilesForAnonymous, getAllowedProfilesForAnyConnectedUser, getAllowedProfilesForGroups, getAllowedProfilesForUser, getAllowedProfilesForUsers, getAllowedUsers, getChild, getChildren, getDeniedGroups, getDeniedProfilesForAnonymous, getDeniedProfilesForAnyConnectedUser, getDeniedProfilesForGroups, getDeniedProfilesForUser, getDeniedProfilesForUsers, getDeniedUsers, hasChild, removeAllowedGroups, removeAllowedGroups, removeAllowedProfilesForAnonymous, removeAllowedProfilesForAnyConnectedUser, removeAllowedUsers, removeAllowedUsers, removeDeniedGroups, removeDeniedGroups, removeDeniedProfilesForAnonymous, removeDeniedProfilesForAnyConnectedUser, removeDeniedUsers, removeDeniedUsers
_getFactory, _invalidateName, _invalidateParentPath, getId, getMetadataHolder, getName, getNode, getParent, getParentPath, getPath, needsSave, remove, rename, revertChanges, saveChanges
equals, hashCode, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
equals, getId, getName, getParent, getParentPath, getPath, hashCode
getNode
getMetadataHolder
needsSave, rename, revertChanges, saveChanges
remove
getChildAt, getChildPosition
public static final String OPTION_NAME_PREFIX
private static final String __PROPERTY_LABEL
private static final String __PROPERTY_TITLE
private static final String __PROPERTY_TYPE
private static final String __PROPERTY_REGEXP
private static final String __PROPERTY_MANDATORY
private static final String __PROPERTY_OTHER_OPTION
private static final String __NODE_NAME_OPTIONS
private static final String __NODE_NAME_COLUMNS
private static final String __NODE_NAME_RULES
private static final String __PROPERTY_RULE_TYPE
private static final String __PROPERTY_RULE_OPTION
private static final String __PROPERTY_RULE_PAGE
public SurveyQuestion(Node node, String parentPath, SurveyQuestionFactory factory)
SurveyQuestion
.node
- the node backing this AmetysObject
.parentPath
- the parent path in the Ametys hierarchy.factory
- the SurveyFactory
which creates the AmetysObject.public String getLabel() throws AmetysRepositoryException
AmetysRepositoryException
- if an error occurs.public void setLabel(String label) throws AmetysRepositoryException
label
- the label.AmetysRepositoryException
- if an error occurs.public String getTitle() throws AmetysRepositoryException
AmetysRepositoryException
- if an error occurs.public void setTitle(String title) throws AmetysRepositoryException
title
- the title.AmetysRepositoryException
- if an error occurs.public SurveyQuestion.QuestionType getType() throws AmetysRepositoryException
AmetysRepositoryException
- if an error occurs.public void setType(SurveyQuestion.QuestionType type) throws AmetysRepositoryException
type
- the type.AmetysRepositoryException
- if an error occurs.public String getRegExpType() throws AmetysRepositoryException
AmetysRepositoryException
- if an error occurs.public void setRegExpType(String regexp) throws AmetysRepositoryException
regexp
- the regexp type.AmetysRepositoryException
- if an error occurs.public String getRegExpPattern() throws AmetysRepositoryException
AmetysRepositoryException
- if an error occurs.public boolean isMandatory() throws AmetysRepositoryException
AmetysRepositoryException
- if an error occurs.public void setMandatory(boolean mandatory) throws AmetysRepositoryException
mandatory
- true for mandatoryAmetysRepositoryException
- if an error occurs.public boolean hasOtherOption()
public void setOtherOption(boolean other)
other
- true to add the "other" optionpublic void setOptions(Map<String,String> options) throws AmetysRepositoryException
options
- the options as a Map of key, valueAmetysRepositoryException
- if an error occurs.public Map<String,String> getOptions() throws AmetysRepositoryException
AmetysRepositoryException
- if an error occurs.public void setColumns(Map<String,String> columns) throws AmetysRepositoryException
columns
- the columns as a Map of key, valueAmetysRepositoryException
- if an error occurs.public Map<String,String> getColumns() throws AmetysRepositoryException
AmetysRepositoryException
- if an error occurs.public void addRules(String option, SurveyRule.RuleType ruleType, String page) throws AmetysRepositoryException
option
- the chosen optionruleType
- the rule typepage
- the page to jump or skip. Can be null.AmetysRepositoryException
- if an error occurs.public boolean hasRule(String option) throws AmetysRepositoryException
option
- the optionAmetysRepositoryException
- if an error occurs.public void deleteRule(String option) throws AmetysRepositoryException
option
- the option to deleteAmetysRepositoryException
- if an error occurs.public List<SurveyRule> getRules() throws AmetysRepositoryException
AmetysRepositoryException
- if an error occurs.public SurveyPage getSurveyPage() throws AmetysRepositoryException
AmetysRepositoryException
- if a repository error occurs when retrieving the page attached to a surveypublic Survey getSurvey() throws AmetysRepositoryException
AmetysRepositoryException
- if a repository error occurs when retrieving a surveypublic SurveyQuestion copyTo(ModifiableTraversableAmetysObject parent, String name) throws AmetysRepositoryException
CopiableAmetysObject
AmetysObject
to the given object. Be careful, this method save changes.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 objectAmetysRepositoryException
- if an error occurs.public SurveyQuestion copyTo(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo) throws AmetysRepositoryException
CopiableAmetysObject
AmetysObject
to the given object if it is not in the restriction list. Be careful, this method save changes.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 of CopiableAmetysObject
authorized to be copiedAmetysRepositoryException
- if an error occurs.