Package org.ametys.cms.scripts
Class CmsScriptHandler
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.core.ui.script.ScriptHandler
org.ametys.cms.scripts.CmsScriptHandler
- All Implemented Interfaces:
LogEnabled,Component,Contextualizable,Serviceable
Content aware script handler using search model
-
Nested Class Summary
Nested classes/interfaces inherited from class org.ametys.plugins.core.ui.script.ScriptHandler
ScriptHandler.ResultProcessor -
Field Summary
Fields inherited from class org.ametys.plugins.core.ui.script.ScriptHandler
_context, _i18nUtils, _scriptBindingEP, RIGHT_EXECUTE_SCRIPTS, ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SearchUIModel_createModel(ThreadSafeComponentManager<SearchUIModel> localSearchModelManager, String defaultModelId, Collection<String> columns, Collection<Content> contents) Create and return a dynamic model based on desired columns or return a default model.protected ScriptExecArgumentsbuildExecArguments(Map<String, Object> arguments) Builds theScriptExecArgumentsobject from the untyped JS object (seen as a Map in Java)content2Json(Content content, ViewItemContainer resultItems, ContentValuesExtractorFactory.SearchModelContentValuesExtractor extractor) Convert content to jsongetOrCreateModel(Collection<String> columns, List<Content> contents, String defaultModelId) Computes the model associated with the given contents and result columns.
Used by scripts functions creating reports or search results.protected ScriptHandler.ResultProcessorReturns theScriptHandler.ResultProcessorused to process script result.protected ObjectprocessScriptResult(Map<String, Object> results, Object scriptResult, ScriptExecArguments execArgs) Process the result of the scriptvoidservice(ServiceManager serviceManager) Methods inherited from class org.ametys.plugins.core.ui.script.ScriptHandler
_executeScript, contextualize, executeScript, executeScript, executeScript, executeScript, getScriptBindingDescription, getWorkspaceNameMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Constructor Details
-
CmsScriptHandler
public CmsScriptHandler()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classScriptHandler- Throws:
ServiceException
-
buildExecArguments
Description copied from class:ScriptHandlerBuilds theScriptExecArgumentsobject from the untyped JS object (seen as a Map in Java)- Overrides:
buildExecArgumentsin classScriptHandler- Parameters:
arguments- The untyped JS object- Returns:
- the
ScriptExecArguments
-
processScriptResult
protected Object processScriptResult(Map<String, Object> results, Object scriptResult, ScriptExecArguments execArgs) Description copied from class:ScriptHandlerProcess the result of the script- Overrides:
processScriptResultin classScriptHandler- Parameters:
results- The results map, available to fillscriptResult- The result of the scriptexecArgs- The script execution arguments- Returns:
- The processed result
-
getProcessor
Description copied from class:ScriptHandlerReturns theScriptHandler.ResultProcessorused to process script result.- Overrides:
getProcessorin classScriptHandler- Returns:
- the
ScriptHandler.ResultProcessor.
-
getOrCreateModel
public SearchUIModel getOrCreateModel(Collection<String> columns, List<Content> contents, String defaultModelId) throws Exception Computes the model associated with the given contents and result columns.
Used by scripts functions creating reports or search results.- Parameters:
columns- the columns of the resultscontents- the contents for the results (one content per line)defaultModelId- the fallback model- Returns:
- the computed search model
- Throws:
Exception- if something went wrong.
-
_createModel
protected SearchUIModel _createModel(ThreadSafeComponentManager<SearchUIModel> localSearchModelManager, String defaultModelId, Collection<String> columns, Collection<Content> contents) throws Exception Create and return a dynamic model based on desired columns or return a default model.- Parameters:
localSearchModelManager- The local search managerdefaultModelId- The default model idcolumns- The columnscontents- The contents- Returns:
- The search model
- Throws:
Exception- If an error occurred
-
content2Json
public Map<String,Object> content2Json(Content content, ViewItemContainer resultItems, ContentValuesExtractorFactory.SearchModelContentValuesExtractor extractor) Convert content to json- Parameters:
content- The contentresultItems- The result items, to know which value to fillextractor- The properties extractor- Returns:
- The json data
-