org.alfresco.repo.web.scripts
Class DeclarativeSpreadsheetWebScript

java.lang.Object
  extended by org.springframework.extensions.webscripts.AbstractWebScript
      extended by org.springframework.extensions.webscripts.DeclarativeWebScript
          extended by org.alfresco.repo.web.scripts.DeclarativeSpreadsheetWebScript
All Implemented Interfaces:
org.springframework.extensions.webscripts.WebScript
Direct Known Subclasses:
DataListDownloadWebScript, 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.


Nested Class Summary
static class DeclarativeSpreadsheetWebScript.WriteExcel
           
 
Nested classes/interfaces inherited from class org.springframework.extensions.webscripts.AbstractWebScript
org.springframework.extensions.webscripts.AbstractWebScript.ScriptDetails
 
Field Summary
protected  org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService
           
protected  java.lang.String filenameBase
           
static java.lang.String MODEL_CSV
           
static java.lang.String MODEL_EXCEL
           
 
Constructor Summary
DeclarativeSpreadsheetWebScript()
           
 
Method Summary
protected abstract  boolean allowHtmlFallback()
          If the format is requested as HTML, should an exception be raised, or should an HTML version be called?
protected abstract  java.util.List buildPropertiesForHeader(java.lang.Object resource, java.lang.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
protected  java.util.Map createTemplateParameters(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.WebScriptResponse res, java.util.Map customParams)
           
protected  java.util.Map executeImpl(org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.Status status)
           
 void generateSpreadsheet(java.lang.Object resource, java.lang.String format, org.springframework.extensions.webscripts.WebScriptRequest req, org.springframework.extensions.webscripts.Status status, java.util.Map model)
          Generates the spreadsheet, based on the properties in the header and a callback for the body.
protected abstract  java.lang.Object identifyResource(java.lang.String format, org.springframework.extensions.webscripts.WebScriptRequest req)
          Identifies the resource for the webscript.
protected abstract  void populateBody(java.lang.Object resource, org.apache.commons.csv.CSVPrinter csv, java.util.List properties)
          Populates the body of the CSV file, once the header has been output.
protected abstract  void populateBody(java.lang.Object resource, org.apache.poi.ss.usermodel.Workbook workbook, org.apache.poi.ss.usermodel.Sheet sheet, java.util.List properties)
          Populates the body of the Excel Workbook, once the header has been output.
 void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
           
 
Methods inherited from class org.springframework.extensions.webscripts.DeclarativeWebScript
execute, executeFinallyImpl, executeImpl, executeImpl, getTemplateModel, renderFormatTemplate
 
Methods inherited from class org.springframework.extensions.webscripts.AbstractWebScript
createArgs, createArgsM, createHeaders, createHeadersM, createScriptParameters, createStatusException, executeScript, getContainer, getDescription, getExecuteScript, getResources, getStatusTemplate, init, renderString, renderString, renderTemplate, sendStatus, setURLModelFactory, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MODEL_CSV

public static final java.lang.String MODEL_CSV
See Also:
Constant Field Values

MODEL_EXCEL

public static final java.lang.String MODEL_EXCEL
See Also:
Constant Field Values

dictionaryService

protected org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService

filenameBase

protected java.lang.String filenameBase
Constructor Detail

DeclarativeSpreadsheetWebScript

public DeclarativeSpreadsheetWebScript()
Method Detail

setDictionaryService

public void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
Parameters:
dictionaryService - the DictionaryService to set

identifyResource

protected abstract java.lang.Object identifyResource(java.lang.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 java.util.List buildPropertiesForHeader(java.lang.Object resource,
                                                           java.lang.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(java.lang.Object resource,
                                     org.apache.poi.ss.usermodel.Workbook workbook,
                                     org.apache.poi.ss.usermodel.Sheet sheet,
                                     java.util.List properties)
                              throws java.io.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:
java.io.IOException

populateBody

protected abstract void populateBody(java.lang.Object resource,
                                     org.apache.commons.csv.CSVPrinter csv,
                                     java.util.List properties)
                              throws java.io.IOException
Populates the body of the CSV file, once the header has been output. This is called if the format is .csv

Throws:
java.io.IOException

executeImpl

protected java.util.Map executeImpl(org.springframework.extensions.webscripts.WebScriptRequest req,
                                    org.springframework.extensions.webscripts.Status status)
Overrides:
executeImpl in class org.springframework.extensions.webscripts.DeclarativeWebScript
See Also:
org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status)

generateSpreadsheet

public void generateSpreadsheet(java.lang.Object resource,
                                java.lang.String format,
                                org.springframework.extensions.webscripts.WebScriptRequest req,
                                org.springframework.extensions.webscripts.Status status,
                                java.util.Map model)
                         throws java.io.IOException
Generates the spreadsheet, based on the properties in the header and a callback for the body.

Throws:
java.io.IOException

createTemplateParameters

protected java.util.Map createTemplateParameters(org.springframework.extensions.webscripts.WebScriptRequest req,
                                                 org.springframework.extensions.webscripts.WebScriptResponse res,
                                                 java.util.Map customParams)
Overrides:
createTemplateParameters in class org.springframework.extensions.webscripts.AbstractWebScript


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.