Package org.ametys.plugins.forms.helper
Class FormAdminDashboardHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.forms.helper.FormAdminDashboardHelper
- All Implemented Interfaces:
LogEnabled,Component,Serviceable
The helper to handle admin dashboard
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA record grouping all parameters needed for searching form entries in the admin dashboardstatic final recordRecord representing a column for form entry display -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AdvancedQueryBuilderThe builder of advanced queriesprotected ModelItemTypeExtensionPointThe criterion type extension pointprotected FormDAOThe form DAOprotected FormEntriesSearchHelperThe form entries search helperprotected FormEntryDAOThe form entry DAOprotected JSONUtilsThe JSON utilsprotected AmetysObjectResolverThe Ametys Object resolverprotected TreeMakerThe tree makerprotected UserManagerThe user managerstatic final StringThe name of the column to display form entry actionsstatic final StringPrefix for the name of column based on form entry.static final StringThe id of the right to access the dashboard configuration.static final StringThe name of the column to display form entry historystatic final StringThe name of the column to display form entry datastatic final StringPrefix for the name of column based on form question.static final StringAvalon ROLE. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanactionableEntriesOnly(ZoneItem zoneItem) trueif the dashboard should display only entries on which the current user has at least one available action,falseif it should display all entries on which the current user has read rights.createCriterionTree(Form form, Map<String, Object> contextualParameters) Create the criterion tree for a form based on the search criteria JSON stored on the form.Get all criterion definitions for a given form.getCriteriaValues(Request request, Form form) Get a map of criterion name / criterion value from the request parametersgetDashboardAdminParameters(Request request, ZoneItem zoneItem, Form form, Map<String, Object> contextualParameters) Get the parameters needed for the admin dashboard, based on the request parameters and the form configuration.String[]getDefaultColumns(Form form) Get the default columns to display for a form in the admin dashboard.getDefaultCriteriaAsJson(Form form) Get the default search criteria for a form as a JSON string.protected List<AbstractFormEntrySearchCriterionDefinition> Get form common criterion definitions for a given form.getFormCriterionDefinitions(String formId) Gets the criterion definitions for a given form.getFormEntryColumns(Form form) Get all form entry columns for a given formprotected List<FormQuestionSearchCriterionDefinition> Get form question criterion definitions for a given form.Get the accessible forms from admin dashboard for current user ie, forms with at least one entry on which the current user can perform an actiongetFormSearchConfiguration(String formId) Gets the column definitions for a given form and the saved search configuration if exists.protected List<AbstractFormEntrySearchCriterionDefinition> Get form workflow criterion definitions for a given form.getQuery(AbstractTreeNode<SearchServiceCriterion<?>> tree, Map<String, Object> criteriaValues, String lang, Map<String, Object> contextualParameters) Build a query from a criterion tree and user criteria values.getSortDefinitions(FormAdminDashboardHelper.DashboardAdminParameters dashboardAdminParameters) Get a map of column name / sort definition from the request parametersvoidsaveSearchConfiguration(String formId, String criteriaJson, List<String> columns, String initialSortColumn, String initialSortOrder) Save the search configuration (criteria and columns) on a form.voidservice(ServiceManager manager) voidupdateDashboardConfigOnQuestionDelete(Form form, String questionName) Update the dashboard configuration of a form when a question is deleted.voidupdateDashboardConfigOnQuestionRename(Form form, String oldQuestionName, String newQuestionName) Update the dashboard configuration of a form when a question is renamed.Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
Avalon ROLE. -
COLUMN_NAME_PREFIX
Prefix for the name of column based on form entry.- See Also:
-
QUESTION_COLUMN_NAME_PREFIX
Prefix for the name of column based on form question.- See Also:
-
LABEL_COLUMN_NAME
The name of the column to display form entry data- See Also:
-
HISTORY_COLUMN_NAME
The name of the column to display form entry history- See Also:
-
ACTIONS_COLUMN_NAME
The name of the column to display form entry actions- See Also:
-
CONFIGURE_DASHBOARD_RIGHT_ID
The id of the right to access the dashboard configuration.- See Also:
-
_resolver
The Ametys Object resolver -
_criterionTypeExtensionPoint
The criterion type extension point -
_treeMaker
The tree maker -
_json
The JSON utils -
_advancedQueryBuilder
The builder of advanced queries -
_formEntryDAO
The form entry DAO -
_formDAO
The form DAO -
_userManager
The user manager -
_formEntriesSearchHelper
The form entries search helper
-
-
Constructor Details
-
FormAdminDashboardHelper
public FormAdminDashboardHelper()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
getDashboardAdminParameters
public FormAdminDashboardHelper.DashboardAdminParameters getDashboardAdminParameters(Request request, ZoneItem zoneItem, Form form, Map<String, Object> contextualParameters) Get the parameters needed for the admin dashboard, based on the request parameters and the form configuration.- Parameters:
request- the request containing the search parameterszoneItem- the zone item holding the admin dashboardform- the formcontextualParameters- the contextual parameters- Returns:
- the dashboard search parameters built from the request parameters and the form configuration
-
actionableEntriesOnly
trueif the dashboard should display only entries on which the current user has at least one available action,falseif it should display all entries on which the current user has read rights.- Parameters:
zoneItem- the zone item holding the admin dashboard- Returns:
trueif the dashboard should display only entries on which the current user has at least one available action,falseif it should display all entries on which the current user has read rights
-
getSortDefinitions
public Map<String,SearcherFactory.SortDefinition> getSortDefinitions(FormAdminDashboardHelper.DashboardAdminParameters dashboardAdminParameters) Get a map of column name / sort definition from the request parameters- Parameters:
dashboardAdminParameters- the dashboard admin parameters- Returns:
- a map of column name / sort definition from the request parameters
-
getCriteriaValues
Get a map of criterion name / criterion value from the request parameters- Parameters:
request- the requestform- the form- Returns:
- a map of criterion name / criterion value from the request parameters
-
createCriterionTree
public AbstractTreeNode<SearchServiceCriterion<?>> createCriterionTree(Form form, Map<String, Object> contextualParameters) Create the criterion tree for a form based on the search criteria JSON stored on the form.- Parameters:
form- the formcontextualParameters- the contextual parameters- Returns:
- the criterion tree
-
getQuery
public Query getQuery(AbstractTreeNode<SearchServiceCriterion<?>> tree, Map<String, Object> criteriaValues, String lang, Map<String, Object> contextualParameters) Build a query from a criterion tree and user criteria values.- Parameters:
tree- the criterion treecriteriaValues- the user criteria values, as a map of criterion name to valuelang- the language to use for building the querycontextualParameters- the contextual parameters- Returns:
- the built query
-
getFormCommonCriterionDefinitions
protected List<AbstractFormEntrySearchCriterionDefinition> getFormCommonCriterionDefinitions(Form form) Get form common criterion definitions for a given form.- Parameters:
form- the form- Returns:
- the list of form common criterion definitions
-
getFormWorkflowCriterionDefinitions
protected List<AbstractFormEntrySearchCriterionDefinition> getFormWorkflowCriterionDefinitions(Form form) Get form workflow criterion definitions for a given form.- Parameters:
form- the form- Returns:
- the list of form workflow criterion definitions
-
getFormQuestionCriterionDefinitions
protected List<FormQuestionSearchCriterionDefinition> getFormQuestionCriterionDefinitions(Form form) Get form question criterion definitions for a given form.- Parameters:
form- the form- Returns:
- the list of form question criterion definitions
-
getAllCriterionDefinitions
Get all criterion definitions for a given form.- Parameters:
form- the form- Returns:
- the list of all criterion definition
-
getFormEntryColumns
Get all form entry columns for a given form- Parameters:
form- the given form- Returns:
- the form entry columns
-
getFormCriterionDefinitions
Gets the criterion definitions for a given form.- Parameters:
formId- The id of the form- Returns:
- the criterion definitions as a map of criterion id to criterion properties
-
getFormSearchConfiguration
Gets the column definitions for a given form and the saved search configuration if exists.- Parameters:
formId- The id of the form- Returns:
- a map with "columns" (list of column definitions) and "savedConfiguration" (map with "criteria", "columns", "initialSortColumn", "initialSortOrder")
-
saveSearchConfiguration
public void saveSearchConfiguration(String formId, String criteriaJson, List<String> columns, String initialSortColumn, String initialSortOrder) Save the search configuration (criteria and columns) on a form.- Parameters:
formId- The id of the formcriteriaJson- The criteria as a JSON stringcolumns- The list of column namesinitialSortColumn- The initial sort column name. Can be null or emptyinitialSortOrder- The initial sort order (ASC or DESC). Can be null or empty
-
getForms
Get the accessible forms from admin dashboard for current user ie, forms with at least one entry on which the current user can perform an action- Parameters:
siteName- the sitenameactionableEntriesOnly-trueif the dashboard should display only entries on which the current user has at least one available action,falseif it should display all entries on which the current user has read rights- Returns:
- the accessible forms from admin dasboard for current user
-
getDefaultCriteriaAsJson
Get the default search criteria for a form as a JSON string.- Parameters:
form- the form- Returns:
- the default search criteria for a form as a JSON string
-
getDefaultColumns
Get the default columns to display for a form in the admin dashboard.- Parameters:
form- the form- Returns:
- the default columns to display for a form in the admin dashboard
-
updateDashboardConfigOnQuestionRename
public void updateDashboardConfigOnQuestionRename(Form form, String oldQuestionName, String newQuestionName) Update the dashboard configuration of a form when a question is renamed.- Parameters:
form- the formoldQuestionName- the old name of the questionnewQuestionName- the new name of the question
-
updateDashboardConfigOnQuestionDelete
Update the dashboard configuration of a form when a question is deleted.- Parameters:
form- the formquestionName- the name of the deleted question
-