Class BaseExportTemplate<ID extends Serializable,T extends AbstractEntity<ID>>
- java.lang.Object
-
- com.ocs.dynamo.ui.composite.export.impl.BaseExportTemplate<ID,T>
-
- Type Parameters:
ID- the type of the primary key of the entityT- the type of the entity
- Direct Known Subclasses:
BaseCsvExportTemplate,BaseExcelExportTemplate
public abstract class BaseExportTemplate<ID extends Serializable,T extends AbstractEntity<ID>> extends Object
Base class for entity model based exports to Excel or CSV- Author:
- bas.rutten
-
-
Field Summary
Fields Modifier and Type Field Description protected static intFIXED_COLUMN_WIDTHThe width for a fixed with columnprotected static intMAX_SIZE_BEFORE_STREAMINGThe maximum number of rows that will be created normally.protected static intPAGE_SIZEThe page sizeprotected static intTITLE_ROW_HEIGHTThe height of the title row in pixels
-
Constructor Summary
Constructors Constructor Description BaseExportTemplate(BaseService<ID,T> service, EntityModel<T> entityModel, ExportMode exportMode, SortOrder[] sortOrders, Filter filter, String title, FetchJoinInformation... joins)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract byte[]generate(com.ocs.dynamo.domain.query.DataSetIterator<ID,T> iterator)Generates the fileEntityModel<T>getEntityModel()EntityModelFactorygetEntityModelFactory()FiltergetFilter()FetchJoinInformation[]getJoins()BaseService<ID,T>getService()SortOrder[]getSortOrders()StringgetTitle()byte[]process()Processes the input and creates a filebyte[]processFixed(List<T> items)Processes a fixed set of dataprotected booleanshow(AttributeModel am)Check whether a certain attribute model must be included in the export
-
-
-
Field Detail
-
FIXED_COLUMN_WIDTH
protected static final int FIXED_COLUMN_WIDTH
The width for a fixed with column- See Also:
- Constant Field Values
-
TITLE_ROW_HEIGHT
protected static final int TITLE_ROW_HEIGHT
The height of the title row in pixels- See Also:
- Constant Field Values
-
MAX_SIZE_BEFORE_STREAMING
protected static final int MAX_SIZE_BEFORE_STREAMING
The maximum number of rows that will be created normally. If the number is larger, then a streaming writer will be used. This is faster but it will mean we cannot auto size the columns- See Also:
- Constant Field Values
-
PAGE_SIZE
protected static final int PAGE_SIZE
The page size- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BaseExportTemplate
public BaseExportTemplate(BaseService<ID,T> service, EntityModel<T> entityModel, ExportMode exportMode, SortOrder[] sortOrders, Filter filter, String title, FetchJoinInformation... joins)
Constructor- Parameters:
service- the service used to retrieve the datasortOrders- the sort orderfilter- the filter used to limit the datatitle- the title of the sheetcustomGenerator- custom generator used to apply extra stylingjoins-
-
-
Method Detail
-
generate
protected abstract byte[] generate(com.ocs.dynamo.domain.query.DataSetIterator<ID,T> iterator) throws IOException
Generates the file- Parameters:
iterator- data set iterator that contains the rows to include- Returns:
- Throws:
IOException
-
getEntityModel
public EntityModel<T> getEntityModel()
-
getEntityModelFactory
public EntityModelFactory getEntityModelFactory()
-
show
protected boolean show(AttributeModel am)
Check whether a certain attribute model must be included in the export- Parameters:
am- the attribute model- Returns:
trueif the attribute must be included,falseotherwise
-
getFilter
public Filter getFilter()
-
getJoins
public FetchJoinInformation[] getJoins()
-
getService
public BaseService<ID,T> getService()
-
getSortOrders
public SortOrder[] getSortOrders()
-
getTitle
public String getTitle()
-
process
public final byte[] process()
Processes the input and creates a file- Parameters:
xls- whether to export to Excel (xlsx)- Returns:
- Throws:
IOException
-
-