public class FormPropertiesManager extends AbstractLogEnabled implements Serviceable, Component, PluginAware
Modifier and Type | Field and Description |
---|---|
protected String |
_pluginName
The plugin name.
|
protected Repository |
_repository
The JCR repository.
|
protected AmetysObjectResolver |
_resolver
The resolver for ametys objects
|
protected SiteManager |
_siteManager
The Site manager.
|
static String |
FIELD_PROPERTY_ID
"ID" field property name.
|
static String |
FIELD_PROPERTY_LABEL
"Label" field property name.
|
static String |
FIELD_PROPERTY_NAME
"Name" field property name.
|
static String |
FIELD_PROPERTY_PREFIX
Field properties prefix.
|
static String |
FIELD_PROPERTY_TYPE
"Type" field property name.
|
static String |
FORM_PROPERTY_EMAILS
"Emails" property name.
|
static String |
FORM_PROPERTY_ID
"ID" property name.
|
static String |
FORM_PROPERTY_LABEL
"Label" property name.
|
static String |
FORM_PROPERTY_RECEIPT_BODY
"Receipt field ID" property name.
|
static String |
FORM_PROPERTY_RECEIPT_FIELD_ID
"Receipt field ID" property name.
|
static String |
FORM_PROPERTY_RECEIPT_FROM_ADDRESS
"Receipt field ID" property name.
|
static String |
FORM_PROPERTY_RECEIPT_SUBJECT
"Receipt field ID" property name.
|
static String |
FORM_PROPERTY_REDIRECT_TO
The uuid of the page where to redirect to
|
static String |
FORM_PROPERTY_WORKFLOW_NAME
"Workflow name" property name.
|
static String |
FORMS_NODE
Forms node name.
|
static String |
LANGUAGE_PROPERTY
Language property
|
static Pattern |
OPTION_VALUE_PATTERN
Pattern for options value
|
static String |
PLUGINS_NODE
Plugins root node name.
|
static String |
ROLE
The avalon component ROLE.
|
static String |
ROOT_REPO
JCR relative path to root node.
|
static String |
SITE_PROPERTY
Site property
|
Constructor and Description |
---|
FormPropertiesManager() |
Modifier and Type | Method and Description |
---|---|
protected Node |
_createOrGetFormsNode(Node baseNode)
Get or create the forms node in a content node.
|
protected Field |
_extractField(Node fieldNode)
Extracts a field from a JCR Node.
|
protected void |
_extractFields(Node formNode,
Form form)
Extracts a form from a JCR Node.
|
protected Form |
_extractForm(Node formNode)
Extracts a form from a JCR Node.
|
protected void |
_fillFieldNode(Node fieldNode,
Field field)
Fill a field node.
|
protected void |
_fillFormNode(Node formNode,
Form form)
Fill a form node.
|
protected Map<String,String> |
_getFieldProperties(Node node)
Get additional configuration from properties.
|
protected Collection<String> |
_getMultipleProperty(Node node,
String propertyName)
Get the values of a string array property.
|
protected String |
_getNotExistingNodeName(Node container,
String baseName)
Get a name for a node which doesn't already exist in this node.
|
protected String |
_getSingleProperty(Node node,
String propertyName,
String defaultValue)
Get a single property value.
|
protected Node |
_storeField(Node formNode,
Field field)
Store a field node.
|
protected Node |
_storeForm(Node contentNode,
Form form)
Persist the form in a repository node.
|
protected void |
_updateFields(Form form,
Node formNode)
Update the field nodes of a form.
|
void |
createForm(String siteName,
Form form,
Content content)
Store the properties of a form in the repository.
|
String |
getDisplayValue(Field field,
String value)
Get the value for display
|
Form |
getForm(String id)
Get a form from the repository.
|
Form |
getForm(String siteName,
String id)
Get a form from the repository.
|
Content |
getFormContent(String formId)
Get the content containing the form with the given id
|
List<Node> |
getFormContentNodes(String siteName,
String language)
Get all the contents containing at least one form of the given site with the given language
|
List<Form> |
getForms(Content content)
Get the forms in a specified content.
|
List<Form> |
getForms(Node node)
Extract all the form objects from a node
|
Node |
getMostRecentFormFrozenContent(String formId)
Get the most recent frozen node that contain the form of the given id
|
void |
remove(Form form,
Content content)
Remove a form
|
void |
service(ServiceManager serviceManager) |
void |
setPluginInfo(String pluginName,
String featureName,
String id)
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level. |
void |
updateForm(String siteName,
Form form,
Content content)
Update the properties of a form in the repository.
|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
public static final Pattern OPTION_VALUE_PATTERN
public static final String ROOT_REPO
public static final String PLUGINS_NODE
public static final String FORMS_NODE
public static final String LANGUAGE_PROPERTY
public static final String SITE_PROPERTY
public static final String FORM_PROPERTY_ID
public static final String FORM_PROPERTY_LABEL
public static final String FORM_PROPERTY_RECEIPT_FIELD_ID
public static final String FORM_PROPERTY_RECEIPT_FROM_ADDRESS
public static final String FORM_PROPERTY_RECEIPT_SUBJECT
public static final String FORM_PROPERTY_RECEIPT_BODY
public static final String FORM_PROPERTY_REDIRECT_TO
public static final String FORM_PROPERTY_EMAILS
public static final String FORM_PROPERTY_WORKFLOW_NAME
public static final String FIELD_PROPERTY_ID
public static final String FIELD_PROPERTY_TYPE
public static final String FIELD_PROPERTY_NAME
public static final String FIELD_PROPERTY_LABEL
public static final String FIELD_PROPERTY_PREFIX
protected Repository _repository
protected SiteManager _siteManager
protected AmetysObjectResolver _resolver
protected String _pluginName
public FormPropertiesManager()
public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
ServiceException
public void setPluginInfo(String pluginName, String featureName, String id)
PluginAware
setPluginInfo
in interface PluginAware
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this componentpublic Form getForm(String id) throws FormsException
id
- the form ID.FormsException
- if an error occurs.public Form getForm(String siteName, String id) throws FormsException
siteName
- the site name.id
- the form ID.FormsException
- if an error occurs.public Node getMostRecentFormFrozenContent(String formId) throws FormsException
formId
- the id of the formFormsException
- if an error occurs while retrieving the forms' frozen content nodespublic List<Form> getForms(Content content) throws FormsException
content
- the content.FormsException
- if an error occurs.public List<Node> getFormContentNodes(String siteName, String language) throws FormsException
siteName
- the site name.language
- the languageFormsException
- if an error occurs.public Content getFormContent(String formId) throws FormsException
formId
- the id of the formContent
containing the form or null
if not foundFormsException
- if something goes wrong when either querying the form JCR node or finding its parent Content
public List<Form> getForms(Node node) throws FormsException, RepositoryException
node
- the nodeFormsException
- if an error occursRepositoryException
- if an error occurs when getting the properties of a nodepublic void createForm(String siteName, Form form, Content content) throws FormsException
siteName
- the site name.form
- the form object.content
- the form content.FormsException
- if an error occurs storing the form.public void updateForm(String siteName, Form form, Content content) throws FormsException
siteName
- the site name.form
- the form object.content
- the form content.FormsException
- if an error occurs storing the form.public String getDisplayValue(Field field, String value)
field
- The fieldvalue
- The valueprotected Form _extractForm(Node formNode) throws RepositoryException
formNode
- the form node.RepositoryException
- if a repository error occurs.protected void _extractFields(Node formNode, Form form) throws RepositoryException
formNode
- the form node.form
- the form object.RepositoryException
- if a repository error occurs.protected Field _extractField(Node fieldNode) throws RepositoryException
fieldNode
- the field node.RepositoryException
- if a repository error occurs.protected Node _storeForm(Node contentNode, Form form) throws RepositoryException
contentNode
- the content node in which the form is to be stored.form
- the form object to persist.RepositoryException
- if a repository error occurs while filling the node.protected void _fillFormNode(Node formNode, Form form) throws RepositoryException, FormsException
formNode
- the form node.form
- the form object.RepositoryException
- if a repository error occurs while filling the node.FormsException
- if a forms error occurs while filling the node.protected Node _storeField(Node formNode, Field field) throws RepositoryException, FormsException
formNode
- the form node.field
- the field.RepositoryException
- if a repository error occurs while filling the node.FormsException
- if a forms error occurs while filling the node.protected void _fillFieldNode(Node fieldNode, Field field) throws RepositoryException, FormsException
fieldNode
- the field node.field
- the field object.RepositoryException
- if a repository error occurs while filling the node.FormsException
- if a forms error occurs while filling the node.protected void _updateFields(Form form, Node formNode) throws RepositoryException, FormsException
form
- the new form object.formNode
- the node of the form to update.RepositoryException
- if a repository error occurs while updating the fields.FormsException
- if a forms error occurs while updating the fields.protected String _getNotExistingNodeName(Node container, String baseName) throws RepositoryException
container
- the container node.baseName
- the base wanted node name.RepositoryException
- if a repository error occurs.protected String _getSingleProperty(Node node, String propertyName, String defaultValue) throws RepositoryException
node
- the JCR node.propertyName
- the name of the property to get.defaultValue
- the default value if the property does not exist.RepositoryException
- if a repository error occurs.protected Collection<String> _getMultipleProperty(Node node, String propertyName) throws RepositoryException
node
- the node.propertyName
- the name of the property to get.RepositoryException
- if a repository error occurs.protected Map<String,String> _getFieldProperties(Node node) throws RepositoryException
node
- the JCR node.RepositoryException
- if a repository error occurs.public void remove(Form form, Content content) throws FormsException
form
- The form to removecontent
- The content holding the formFormsException
- of an exception occurs when manipulating the forms' repository nodesprotected Node _createOrGetFormsNode(Node baseNode) throws RepositoryException
baseNode
- the content base node.RepositoryException
- if an error occurs.