Class Form
java.lang.Object
org.ametys.plugins.repository.AbstractAmetysObject
org.ametys.plugins.repository.jcr.SimpleAmetysObject<F>
org.ametys.plugins.repository.jcr.DefaultTraversableAmetysObject<FormFactory>
org.ametys.plugins.forms.repository.Form
- All Implemented Interfaces:
ModelAwareDataAwareAmetysObject
,ModifiableModelAwareDataAwareAmetysObject
,IndexableDataHolder
,ModifiableIndexableDataHolder
,ACLAmetysObject
,AmetysObject
,CopiableAmetysObject
,DataAwareAmetysObject
,ModelAwareDataAwareAmetysObject
,ModifiableModelAwareDataAwareAmetysObject
,DataHolder
,ModelAwareDataHolder
,ModifiableDataHolder
,ModifiableModelAwareDataHolder
,JCRAmetysObject
,JCRTraversableAmetysObject
,MetadataAwareAmetysObject
,ModifiableMetadataAwareAmetysObject
,ModifiableACLAmetysObject
,ModifiableAmetysObject
,ModifiableTraversableAmetysObject
,MovableAmetysObject
,RemovableAmetysObject
,TraversableAmetysObject
,SiteAwareAmetysObject
public class Form
extends DefaultTraversableAmetysObject<FormFactory>
implements ModifiableModelAwareDataAwareAmetysObject, MovableAmetysObject, SiteAwareAmetysObject, CopiableAmetysObject
Class representing a form, backed by a JCR node.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Property name for form entries admin emailsstatic final String
Property name for form authorstatic final String
Property name for form displayed message when closed because of limited number of entriesstatic final String
Property name for form last contributorstatic final String
Property name for form creation datestatic final String
Property name for form descriptionstatic final String
Property name for form end datestatic final String
Property name for form last modification datestatic final String
Property name for form to limit the entriesstatic final String
Property name for form to limit one entry by userstatic final String
Property name for form's authorized max number of entriesstatic final String
Property name for form acknowledgement of queue's bodystatic final String
Property name for form displayed message when closed because of limited number of entries and a queue is enabledstatic final String
Property name for form to enable queuestatic final String
Property name for form acknowledgement of queue's receiverstatic final String
Property name for form acknowledgement of queue's senderstatic final String
Property name for form's queue sizestatic final String
Property name for form acknowledgement of queue's subjectstatic final String
Property name for form acknowledgement of receipt's bodystatic final String
Property name for form acknowledgement of receipt's receiverstatic final String
Property name for form acknowledgement of receipt's senderstatic final String
Property name for form acknowledgement of receipt's subjectstatic final String
Property name for form displayed message when entries are limited in numberstatic final String
Property name for form start datestatic final String
Property name for form displayed namestatic final String
Property name for form workflow nameFields inherited from interface org.ametys.plugins.repository.data.holder.ModelAwareDataHolder
ALTERNATIVE_SUFFIX, COMMENTS_SUFFIX, STATUS_SUFFIX
Fields inherited from interface org.ametys.web.repository.SiteAwareAmetysObject
METADATA_SITE
-
Constructor Summary
ConstructorDescriptionForm
(javax.jcr.Node node, String parentPath, FormFactory factory) Creates anForm
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canMoveTo
(AmetysObject newParent) Test if a move can be a success or if it is impossible (e.g.copyTo
(ModifiableTraversableAmetysObject parent, String name) Copy the currentAmetysObject
to the given object.copyTo
(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo) Copy the currentAmetysObject
to the given object if it is not in the restriction list.void
deleteQuestionsRule
(String sourceQuestionId) Delete the rules having sourceQuestionId as sourceIdvoid
enableQueue
(boolean enabled) Enable of not the queuefindUniqueQuestionName
(String originalName) Returns a unique question name in the formfindUniqueQuestionTitle
(String originalTitle) Returns a unique question title in the formGet the active form entries.Get the admin emailsGet the author of the formGet the message that will be displayed to users when the entries limit is reachedGet the message that will be displayed to users when the entries limit is reached and a queue is enabledGet the last contributor of the formGet the date of the last modification of the formReturns theDataHolder
of thisAmetysObject
.Get the description of the formGet the end dateGet the form entries.Get the date of the last modification of the formGet the max number limit for entries in this formgetPages()
Get the form pages.getQuestion
(String name) Get a question by its name.Get the form questions.Get all the nameForForms of the questions in this formgetQuestionsRule
(String sourceQuestionId) Get the rules having sourceQuestionId as sourceIdGet the email's body for notifying exit of queue.Get the email's receiver for notifying exit of queue.Get the email's sender for notifying exit of queue.Get the email's subject for notifying exit of queue.Get the queue max size in this formGet the receipt's body of this form.Get the receipt's receiver of this form.Get the receipt's sender of this form.Get the receipt's subject of this form.Get the message that will be displayed to users when filling the form if a max entries limit is setgetSite()
Returns this object's site.Returns this object's site name.Get the start dategetTitle()
Get the title of the formGet the name of the workflow applied to the formboolean
true
if the form has entriesboolean
true
if the form has a workflowboolean
Returns true if the form is cacheable.boolean
Get if the form entries are limitedboolean
Get if this form is limited to one entry by userboolean
Indicate is this form can be considered as a mini surveyboolean
isQuestionNameUnique
(String uniqueName) Verify that no question has the same JCR id as the current questionboolean
Get if a queue is enabledvoid
limitEntries
(boolean limitEntries) Limit or not the entries of the formvoid
limitToOneEntryByUser
(boolean limit) Limit or not to one entry by uservoid
moveTo
(AmetysObject newParent, boolean renameIfExist) Move the current object as a new child of the given object.void
orderBefore
(AmetysObject siblingNode) Order a node before another sibling node (or as the last node)void
setAdminEmails
(String[] emails) Set the admin emailsvoid
setAuthor
(UserIdentity author) Set the author of this form.void
setClosedMessage
(String msg) Set the message that will be displayed to users when the entries limit is reachedvoid
Set the message that will be displayed to users when the entries limit is reached and a queue is enabledvoid
setContributor
(UserIdentity contributor) Set the last contributor of this form.void
setCreationDate
(ZonedDateTime creationDate) Set the date of the creation.void
setDescription
(String description) Set the description of this form.void
setEndDate
(LocalDate date) Set the end datevoid
setLastModificationDate
(ZonedDateTime lastModificationDate) Set the date of the last modification.void
setMaxEntries
(Long max) Set the max number limit for entries in this formvoid
setQueueMailBody
(String body) Set the email's body for notifying exit of queue.void
setQueueMailSender
(String sender) Set the email's sender for notifying exit of queue.void
setQueueMailSubject
(String subject) Set the email's subject for notifying exit of queue.void
setQueueMailtReceiver
(String receiver) Set the email's receiver for notifying exit of queue.void
setQueueSize
(Long max) Set the queue max size in this formvoid
setReceiptBody
(String body) Set the receipt's body of this form.void
setReceiptReceiver
(String receiver) Set the receipt's receiver of this form.void
setReceiptSender
(String sender) Set the receipt's sender of this form.void
setReceiptSubject
(String subject) Set the receipt's subject of this form.void
Set the message that will be displayed to users when filling the form if a max entries limit is setvoid
setStartDate
(LocalDate date) Set the start datevoid
Set the title of this form.void
setWorkflowName
(String workflowName) Set the name of the workflow.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, dataToJSON, dataToJSON, dataToSAX, dataToSAX
Methods inherited from interface org.ametys.plugins.repository.jcr.JCRAmetysObject
getNode
Methods inherited from interface org.ametys.cms.data.ametysobject.ModelAwareDataAwareAmetysObject
getSystemPropertyExtensionPoint, indexData, indexData
Methods inherited from interface org.ametys.plugins.repository.data.ametysobject.ModelAwareDataAwareAmetysObject
dataToJSON, dataToJSONForEdition, dataToMap, dataToSAX, dataToSAXForEdition, getComments, getDataNames, getDefinition, getExternalValue, getLocalValue, getModel, getStatus, getValue, getValue, hasComments, hasDefinition, hasExternalValue, hasExternalValueOrEmpty, hasLocalValue, hasLocalValueOrEmpty, hasValue, hasValueOrEmpty
Methods inherited from interface org.ametys.plugins.repository.data.holder.ModelAwareDataHolder
commentsToSAX, dataToJSON, dataToJSON, dataToJSON, dataToMap, dataToMap, dataToMap, dataToSAX, dataToSAX, dataToSAX, getDataNames, getType, getValue, hasValue, hasValueOrEmpty, isMultiple
Methods inherited from interface org.ametys.plugins.repository.ModifiableAmetysObject
needsSave, rename, revertChanges, saveChanges
Methods inherited from interface org.ametys.plugins.repository.data.holder.ModifiableDataHolder
getRepositoryData
Methods inherited from interface org.ametys.plugins.repository.metadata.ModifiableMetadataAwareAmetysObject
getMetadataHolder
Methods inherited from interface org.ametys.cms.data.ametysobject.ModifiableModelAwareDataAwareAmetysObject
getComposite, getComposite, getExternalComposite, getExternalComposite, getExternalRepeater, getExternalRepeater, getLocalComposite, getLocalComposite, getLocalRepeater, getLocalRepeater, getParentDataHolder, getRepeater, getRepeater, getRootDataHolder
Methods inherited from interface org.ametys.plugins.repository.data.ametysobject.ModifiableModelAwareDataAwareAmetysObject
getRepositoryData, removeExternalizableMetadataIfExists, removeExternalValue, removeLocalValue, removeValue, setComments, setExternalValue, setLocalValue, setStatus, setValue, synchronizeValues, synchronizeValues, synchronizeValues, synchronizeValues
Methods inherited from interface org.ametys.plugins.repository.RemovableAmetysObject
remove
Methods inherited from interface org.ametys.plugins.repository.TraversableAmetysObject
getChildAt, getChildPosition
-
Field Details
-
TITLE
Property name for form displayed name- See Also:
-
DESCRIPTION
Property name for form description- See Also:
-
AUTHOR
Property name for form author- See Also:
-
CONTRIBUTOR
Property name for form last contributor- See Also:
-
CREATIONDATE
Property name for form creation date- See Also:
-
LASTMODIFICATIONDATE
Property name for form last modification date- See Also:
-
WORKFLOWNAME
Property name for form workflow name- See Also:
-
LIMIT_TO_ONE_ENTRY_BY_USER
Property name for form to limit one entry by user- See Also:
-
LIMIT_ENTRIES_ENABLED
Property name for form to limit the entries- See Also:
-
QUEUE_ENABLED
Property name for form to enable queue- See Also:
-
QUEUE_SIZE
Property name for form's queue size- See Also:
-
QUEUE_CLOSED_MSG
Property name for form displayed message when closed because of limited number of entries and a queue is enabled- See Also:
-
MAX_ENTRIES
Property name for form's authorized max number of entries- See Also:
-
REMAINING_MSG
Property name for form displayed message when entries are limited in number- See Also:
-
CLOSED_MSG
Property name for form displayed message when closed because of limited number of entries- See Also:
-
ADMIN_EMAILS
Property name for form entries admin emails- See Also:
-
RECEIPT_SENDER
Property name for form acknowledgement of receipt's sender- See Also:
-
RECEIPT_RECEIVER
Property name for form acknowledgement of receipt's receiver- See Also:
-
RECEIPT_SUBJECT
Property name for form acknowledgement of receipt's subject- See Also:
-
RECEIPT_BODY
Property name for form acknowledgement of receipt's body- See Also:
-
QUEUE_SENDER
Property name for form acknowledgement of queue's sender- See Also:
-
QUEUE_RECEIVER
Property name for form acknowledgement of queue's receiver- See Also:
-
QUEUE_SUBJECT
Property name for form acknowledgement of queue's subject- See Also:
-
QUEUE_BODY
Property name for form acknowledgement of queue's body- See Also:
-
START_DATE
Property name for form start date- See Also:
-
END_DATE
Property name for form end date- See Also:
-
-
Constructor Details
-
Form
Creates anForm
.- Parameters:
node
- the node backing thisAmetysObject
parentPath
- the parentPath in the Ametys hierarchyfactory
- the DefaultAmetysObjectFactory which created the AmetysObject
-
-
Method Details
-
setTitle
Set the title of this form.- Parameters:
title
- the short title
-
setDescription
Set the description of this form.- Parameters:
description
- the description
-
setAuthor
Set the author of this form.- Parameters:
author
- the author
-
setContributor
Set the last contributor of this form.- Parameters:
contributor
- the last contributor
-
setCreationDate
Set the date of the creation.- Parameters:
creationDate
- the last modification date to set.
-
setLastModificationDate
Set the date of the last modification.- Parameters:
lastModificationDate
- the last modification date to set.
-
getTitle
Get the title of the form- Returns:
- The title
-
getDescription
Get the description of the form- Returns:
- The description
-
getAuthor
Get the author of the form- Returns:
- The author
-
getContributor
Get the last contributor of the form- Returns:
- The contributor
-
getCreationDate
Get the date of the last modification of the form- Returns:
- The date
-
getLastModificationDate
Get the date of the last modification of the form- Returns:
- The date
-
getWorkflowName
Get the name of the workflow applied to the form- Returns:
- The workflow name
-
setWorkflowName
Set the name of the workflow.- Parameters:
workflowName
- the name of the workflow to set.
-
getReceiptSender
Get the receipt's sender of this form.- Returns:
- The receipt's sender
-
setReceiptSender
Set the receipt's sender of this form.- Parameters:
sender
- The receipt's sender
-
getReceiptReceiver
Get the receipt's receiver of this form.- Returns:
- The receipt's receiver
-
setReceiptReceiver
Set the receipt's receiver of this form.- Parameters:
receiver
- The receipt's receiver
-
getReceiptSubject
Get the receipt's subject of this form.- Returns:
- The receipt's subject
-
setReceiptSubject
Set the receipt's subject of this form.- Parameters:
subject
- The receipt's subject
-
getReceiptBody
Get the receipt's body of this form.- Returns:
- The receipt's body
-
setReceiptBody
Set the receipt's body of this form.- Parameters:
body
- The receipt's body
-
isMiniSurvey
Indicate is this form can be considered as a mini survey- Returns:
- true if the form as only one question of type list and is limited to one answer by user
-
isLimitedToOneEntryByUser
Get if this form is limited to one entry by user- Returns:
true
if the form is limited to one entry by user
-
limitToOneEntryByUser
Limit or not to one entry by user- Parameters:
limit
-true
to limit to one entry by user
-
isEntriesLimited
Get if the form entries are limited- Returns:
true
if the form entries are limited
-
limitEntries
Limit or not the entries of the form- Parameters:
limitEntries
-true
to limit the entries
-
isQueueEnabled
Get if a queue is enabled- Returns:
true
if a queue is enabled
-
enableQueue
Enable of not the queue- Parameters:
enabled
-true
to enable the queue
-
getMaxEntries
Get the max number limit for entries in this form- Returns:
- the max number
-
setMaxEntries
Set the max number limit for entries in this form- Parameters:
max
- The max number
-
getRemainingMessage
Get the message that will be displayed to users when filling the form if a max entries limit is set- Returns:
- a message for users
-
setRemainingMessage
Set the message that will be displayed to users when filling the form if a max entries limit is set- Parameters:
msg
- The message for users
-
getClosedMessage
Get the message that will be displayed to users when the entries limit is reached- Returns:
- a message for users
-
setClosedMessage
Set the message that will be displayed to users when the entries limit is reached- Parameters:
msg
- The message for users
-
getQueueSize
Get the queue max size in this form- Returns:
- the max number
-
setQueueSize
Set the queue max size in this form- Parameters:
max
- The max number
-
getClosedQueueMessage
Get the message that will be displayed to users when the entries limit is reached and a queue is enabled- Returns:
- a message for users
-
setClosedQueueMessage
Set the message that will be displayed to users when the entries limit is reached and a queue is enabled- Parameters:
msg
- The message for users
-
getQueueMailSender
Get the email's sender for notifying exit of queue.- Returns:
- The email's sender
-
setQueueMailSender
Set the email's sender for notifying exit of queue.- Parameters:
sender
- The email's sender
-
getQueueMailReceiver
Get the email's receiver for notifying exit of queue.- Returns:
- The email's receiver
-
setQueueMailtReceiver
Set the email's receiver for notifying exit of queue.- Parameters:
receiver
- The email's receiver
-
getQueueMailSubject
Get the email's subject for notifying exit of queue.- Returns:
- The email's subject
-
setQueueMailSubject
Set the email's subject for notifying exit of queue.- Parameters:
subject
- The email's subject
-
getQueueMailBody
Get the email's body for notifying exit of queue.- Returns:
- The email's body
-
setQueueMailBody
Set the email's body for notifying exit of queue.- Parameters:
body
- The email's body
-
getAdminEmails
Get the admin emails- Returns:
- the admin emails
-
setAdminEmails
Set the admin emails- Parameters:
emails
- the admin emails
-
setStartDate
Set the start date- Parameters:
date
- The start date
-
getStartDate
Get the start date- Returns:
- The the start date
-
setEndDate
Set the end date- Parameters:
date
- The end date
-
getEndDate
Get the end date- Returns:
- The the end date
-
getDataHolder
Description copied from interface:DataAwareAmetysObject
Returns theDataHolder
of thisAmetysObject
.- Specified by:
getDataHolder
in interfaceDataAwareAmetysObject
- Specified by:
getDataHolder
in interfaceModelAwareDataAwareAmetysObject
- Specified by:
getDataHolder
in interfaceModelAwareDataAwareAmetysObject
- Specified by:
getDataHolder
in interfaceModifiableModelAwareDataAwareAmetysObject
- Specified by:
getDataHolder
in interfaceModifiableModelAwareDataAwareAmetysObject
- Returns:
- the
DataHolder
of thisAmetysObject
-
getSiteName
Description copied from interface:SiteAwareAmetysObject
Returns this object's site name.- Specified by:
getSiteName
in interfaceSiteAwareAmetysObject
- Returns:
- this object's site name.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getSite
Description copied from interface:SiteAwareAmetysObject
Returns this object's site.- Specified by:
getSite
in interfaceSiteAwareAmetysObject
- Returns:
- this object's site
- Throws:
AmetysRepositoryException
- if an error occurs.
-
copyTo
public Form 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.- Specified by:
copyTo
in interfaceCopiableAmetysObject
- 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 AmetysObject 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.- Specified by:
copyTo
in interfaceCopiableAmetysObject
- 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.
-
getPages
Get the form pages.- Returns:
- the form pages.
- Throws:
AmetysRepositoryException
- if an error occurs when retrieving the pages of the form
-
hasEntries
true
if the form has entries- Returns:
true
if the form has entries
-
getEntries
Get the form entries.- Returns:
- the form entries.
- Throws:
AmetysRepositoryException
- if an error occurs when retrieving the entries of the form
-
getActiveEntries
Get the active form entries.- Returns:
- a list of the active form entries.
- Throws:
AmetysRepositoryException
- if an error occurs when retrieving the entries of the form
-
getQuestion
Get a question by its name.- Parameters:
name
- the question name.- Returns:
- the question.
- Throws:
AmetysRepositoryException
- if an error occurs when retrieving a question of a form
-
getQuestions
Get the form questions.- Returns:
- the form questions.
- Throws:
AmetysRepositoryException
- if an error occurs when retrieving all the questions of a form
-
findUniqueQuestionName
Returns a unique question name in the form- Parameters:
originalName
- The original name- Returns:
- a unique question name
-
isQuestionNameUnique
Verify that no question has the same JCR id as the current question- Parameters:
uniqueName
- jcr name for the current question- Returns:
- false if id already exist, true if not
-
getQuestionsNames
Get all the nameForForms of the questions in this form- Returns:
- a list of the names for form
-
findUniqueQuestionTitle
Returns a unique question title in the form- Parameters:
originalTitle
- The original title- Returns:
- a unique question title
-
getQuestionsRule
Get the rules having sourceQuestionId as sourceId- Parameters:
sourceQuestionId
- The source question- Returns:
- a map of question target's name for form and associated rule
-
deleteQuestionsRule
Delete the rules having sourceQuestionId as sourceId- Parameters:
sourceQuestionId
- The source question
-
hasWorkflow
true
if the form has a workflow- Returns:
true
if the form has a workflow
-
canMoveTo
Description copied from interface:MovableAmetysObject
Test if a move can be a success or if it is impossible (e.g. due to the implementation of the target)- Specified by:
canMoveTo
in interfaceMovableAmetysObject
- Parameters:
newParent
- See moveTo.- Returns:
- true if the move operation may succeed. If false is returned and you call moveTo anyway, you may encontered a RuntimeException (such as UnsupportedOperationException)
- Throws:
AmetysRepositoryException
- if an error occurs.
-
moveTo
public void moveTo(AmetysObject newParent, boolean renameIfExist) throws AmetysRepositoryException, RepositoryIntegrityViolationException Description copied from interface:MovableAmetysObject
Move the current object as a new child of the given object. This node will be the last child. You should call canMoveTo to know if this is a supported operation.- Specified by:
moveTo
in interfaceMovableAmetysObject
- Parameters:
newParent
- The new parent for the current object. Can not be null. Can not be a child of the current node. Must be a TraversableAmetyObject.renameIfExist
- true to rename moved page if a page with same name already exist- Throws:
AmetysRepositoryException
- if an error occurs.RepositoryIntegrityViolationException
- if a page with the same name already exists.
-
orderBefore
Description copied from interface:MovableAmetysObject
Order a node before another sibling node (or as the last node)- Specified by:
orderBefore
in interfaceMovableAmetysObject
- Parameters:
siblingNode
- The node that will be the next sibling node of the current node. Must have the same parent as the current node. Can be null to set the current node as the last node.- Throws:
AmetysRepositoryException
- if an error occurs.
-
isCacheable
Returns true if the form is cacheable.- Returns:
- true if the form is cacheable.
-