Package org.alfresco.repo.web.scripts
Class DeclarativeSpreadsheetWebScript
java.lang.Object
org.springframework.extensions.webscripts.AbstractWebScript
org.springframework.extensions.webscripts.DeclarativeWebScript
org.alfresco.repo.web.scripts.DeclarativeSpreadsheetWebScript
- All Implemented Interfaces:
org.springframework.extensions.webscripts.WebScript
- Direct Known Subclasses:
UserCSVUploadGet
public abstract class DeclarativeSpreadsheetWebScript
extends org.springframework.extensions.webscripts.DeclarativeWebScript
Parent of Declarative Webscripts that generate Excel files, usually based on some sort of dictionary model.
- Author:
- Nick Burch
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.springframework.extensions.webscripts.AbstractWebScript
org.springframework.extensions.webscripts.AbstractWebScript.ScriptDetails -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleanIf the format is requested as HTML, should an exception be raised, or should an HTML version be called?buildPropertiesForHeader(Object resource, String format, org.springframework.extensions.webscripts.WebScriptRequest req) Returns the QNames of the model properties to be output in the header, and if they're required or notcreateTemplateParameters(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, Map<String, Object> customParams) executeImpl(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.Status status) voidgenerateSpreadsheet(Object resource, String format, org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.Status status, Map<String, Object> model) Generates the spreadsheet, based on the properties in the header and a callback for the body.org.apache.commons.csv.CSVFormatGet the CSVFormat.protected abstract ObjectidentifyResource(String format, org.springframework.extensions.webscripts.WebScriptRequest req) Identifies the resource for the webscript.protected abstract voidpopulateBody(Object resource, org.apache.commons.csv.CSVPrinter csv, List<org.alfresco.service.namespace.QName> properties) Populates the body of the CSV file, once the header has been output.protected abstract voidpopulateBody(Object resource, org.apache.poi.ss.usermodel.Workbook workbook, org.apache.poi.ss.usermodel.Sheet sheet, List<org.alfresco.service.namespace.QName> properties) Populates the body of the Excel Workbook, once the header has been output.voidsetCsvFormat(org.apache.commons.csv.CSVFormat csvFormat) Set the CSVFormatvoidsetDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService) Methods inherited from class org.springframework.extensions.webscripts.DeclarativeWebScript
execute, executeFinallyImpl, executeImpl, executeImpl, getTemplateModel, renderFormatTemplateMethods inherited from class org.springframework.extensions.webscripts.AbstractWebScript
addModuleBundleToCache, checkModuleBundleCache, createArgs, createArgsM, createHeaders, createHeadersM, createScriptParameters, createStatusException, executeScript, getContainer, getDescription, getExecuteScript, getResources, getStatusTemplate, init, renderString, renderString, renderTemplate, sendStatus, setURLModelFactory, toString
-
Field Details
-
MODEL_CSV
- See Also:
-
MODEL_EXCEL
- See Also:
-
PARAM_REQ_DELIMITER
- See Also:
-
dictionaryService
protected org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService -
filenameBase
-
-
Constructor Details
-
DeclarativeSpreadsheetWebScript
public DeclarativeSpreadsheetWebScript()
-
-
Method Details
-
setDictionaryService
public void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService) - Parameters:
dictionaryService- the DictionaryService to set
-
identifyResource
protected abstract Object identifyResource(String format, org.springframework.extensions.webscripts.WebScriptRequest req) Identifies the resource for the webscript. -
allowHtmlFallback
protected abstract boolean allowHtmlFallback()If the format is requested as HTML, should an exception be raised, or should an HTML version be called? -
buildPropertiesForHeader
protected abstract List<Pair<org.alfresco.service.namespace.QName,Boolean>> buildPropertiesForHeader(Object resource, String format, org.springframework.extensions.webscripts.WebScriptRequest req) Returns the QNames of the model properties to be output in the header, and if they're required or not -
populateBody
protected abstract void populateBody(Object resource, org.apache.poi.ss.usermodel.Workbook workbook, org.apache.poi.ss.usermodel.Sheet sheet, List<org.alfresco.service.namespace.QName> properties) throws IOException Populates the body of the Excel Workbook, once the header has been output. This is called if the format is .xls or .xlsx- Throws:
IOException
-
populateBody
protected abstract void populateBody(Object resource, org.apache.commons.csv.CSVPrinter csv, List<org.alfresco.service.namespace.QName> properties) throws IOException Populates the body of the CSV file, once the header has been output. This is called if the format is .csv- Throws:
IOException
-
setCsvFormat
public void setCsvFormat(org.apache.commons.csv.CSVFormat csvFormat) Set the CSVFormat- Parameters:
csvFormat- CSVFormat
-
getCsvFormat
public org.apache.commons.csv.CSVFormat getCsvFormat()Get the CSVFormat. ReturnsCSVFormat.EXCELif none was set.- Returns:
- CSVFormat
-
executeImpl
protected Map<String,Object> executeImpl(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.Status status) - Overrides:
executeImplin classorg.springframework.extensions.webscripts.DeclarativeWebScript- See Also:
-
DeclarativeWebScript.executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status)
-
generateSpreadsheet
public void generateSpreadsheet(Object resource, String format, org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.Status status, Map<String, Object> model) throws IOExceptionGenerates the spreadsheet, based on the properties in the header and a callback for the body.- Throws:
IOException
-
createTemplateParameters
protected Map<String,Object> createTemplateParameters(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, Map<String, Object> customParams) - Overrides:
createTemplateParametersin classorg.springframework.extensions.webscripts.AbstractWebScript
-