public abstract class G9ExcelExporter extends Object implements SpreadsheetExporter, Comparator<Object>, Serializable
It serves as a super class for exporters which are tailored for specific dialog models.
| Modifier and Type | Field and Description |
|---|---|
protected Map<DialogObjectConstant,ExportElement> |
elements
Holds all the elements that is part of a dialog.
|
| Constructor and Description |
|---|
G9ExcelExporter() |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
autoResizeAll(org.apache.poi.ss.usermodel.Sheet sheet)
Resize all columns according to the data, in all sheets from the workbook that contains the given sheet.
|
int |
compare(Object o1,
Object o2)
Used to compare two list objects.
|
org.apache.poi.ss.usermodel.Workbook |
createBook(ObjectSelection os,
File workbook,
WorkbookProvider.WORKBOOK_FORMAT bookFormat)
Creates the workbook in the input file.
|
org.apache.poi.ss.usermodel.Workbook |
createBook(ObjectSelection os,
OutputStream workbook,
WorkbookProvider.WORKBOOK_FORMAT bookFormat)
Creates the workbook in the input file.
|
protected org.apache.poi.ss.usermodel.Cell |
createCell(DialogObjectConstant dialogElement,
org.apache.poi.ss.usermodel.Sheet sheet,
G9ExcelCell offset,
boolean isLabel,
int colIndex,
short alignment)
Creates the cell for the element.
|
protected org.apache.poi.ss.usermodel.Cell |
createCell(DialogObjectConstant dialogElement,
org.apache.poi.ss.usermodel.Sheet sheet,
G9ExcelCell offset,
boolean isLabel,
int colIndex,
String columnTitle,
short alignment)
Creates the cell for the element.
|
protected org.apache.poi.ss.usermodel.Cell |
createCell(DialogObjectConstant dialogElement,
org.apache.poi.ss.usermodel.Sheet sheet,
G9ExcelCell offset,
boolean isLabel,
short alignment)
Creates a cell for the given element.
|
protected G9ExcelCell |
createTable(ObjectSelection os,
RoleConstant targetRole,
List<TableColumnData> columnDataList,
org.apache.poi.ss.usermodel.Sheet sheet,
G9ExcelCell initialCell,
boolean showHeader,
DialogObjectConstant doc)
Creates cells for a table.
|
protected abstract void |
exportDialog(ObjectSelection os,
org.apache.poi.ss.usermodel.Sheet defaultSheet)
Initialization of the export.
|
protected abstract ResourceBundle |
getBundle()
Gets the resource bundle.
|
protected static Object |
getChildObject(Object parent,
OSRole<?> parentRole,
RoleConstant childRole)
Gets the child object(s) from parent.
|
protected Object |
getColumnObject(Object targetObject,
RoleConstant attributeRole)
Gets the column object.
|
protected static short |
getColumns(org.apache.poi.ss.usermodel.Sheet sheet)
Get the (maximum) number of columns in use for a sheet.
|
protected abstract String |
getDialogName()
Retrieves the dialog name.
|
protected Object |
getDomainObjectFromParent(Object parentObject,
RoleConstant targetRole)
Gets the domain object(s) from the parent domain object
|
protected static ResourceBundle |
getGeneralBundle()
Gets the application resource bundle.
|
protected static G9ExcelCell |
getMax(G9ExcelCell[] cells)
Creates a
G9ExcelCell with max column and row. |
protected static G9ExcelCell |
getMax(G9ExcelCell offset,
G9ExcelCell cell)
Creates a
G9ExcelCell with max column and row. |
protected G9ExcelCell |
getMaxCell(DialogObjectConstant[] dialogElements,
G9ExcelCell offset)
Gets the maximum cell obtained when combining the provided offset with one of the dialog elements
|
protected G9ExcelCell |
getNextAvailableCell(DialogObjectConstant[] dialogElements,
G9ExcelCell offset)
Gets the next available cell.
|
protected abstract boolean |
getParameterHidden()
Gets the generator parameter that tells whether the user want to show hidden elements or not.
|
protected static List<OSRole<?>> |
getRoleHierarchy(OSRole<?> targetRole)
Gets the role hierarchy from target to root.
|
protected abstract Map<RoleConstant,OSRole<?>> |
getRoleMap()
Gives a map of role constants and object selection roles.
|
protected Object |
getRootObject(ObjectSelection os,
RoleConstant targetRole)
Gets the root object(s) for the target role from an object selection
|
Object |
getRootOrTargetObject(ObjectSelection os,
RoleConstant targetRole,
String compare)
Make sure that the use of getRootObject is not used, when the Root Object is not wanted.
|
protected static org.apache.poi.ss.usermodel.Row |
getRow(org.apache.poi.ss.usermodel.Sheet sheet,
int localRow,
int offset)
Retrieves the row with the given data.
|
protected abstract String |
getSheetName()
Gets the sheet name.
|
protected List<Object> |
getSortedTargetObjects(ObjectSelection os,
RoleConstant targetRole)
Retrieves a sorted list of the data.
|
protected Object |
getTargetObject(ObjectSelection os,
RoleConstant targetRole)
Gets the target object from the object selection.
|
org.apache.poi.ss.usermodel.Workbook |
getWorkbook()
Gets the result workbook.
|
WorkbookProvider |
getWorkbookProvider()
Get the workbook provider.
|
protected static boolean |
hookFilterElement(DialogObjectConstant dialogElement,
Object domainObject)
Lets user code filter the data for this dialog element.
|
protected abstract void |
setAllMapElements()
Sets all the
DialogObjectConstant elements in the map. |
protected void |
setCellData(DialogObjectConstant dialogElement,
Object domainObject,
org.apache.poi.ss.usermodel.Cell cell,
String dateFormat)
Adds data to a specific cell.
|
protected void |
setLabelAsBold(boolean val)
Sets the
labelAsBold variable. |
void |
setWorkbookProvider(WorkbookProvider workbookProvider)
Set a new workbook provider.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongprotected Map<DialogObjectConstant,ExportElement> elements
public WorkbookProvider getWorkbookProvider()
If it is not set, a new workbook provider is created.
public void setWorkbookProvider(WorkbookProvider workbookProvider)
workbookProvider - the new workbook providerpublic org.apache.poi.ss.usermodel.Workbook getWorkbook()
getWorkbook in interface SpreadsheetExporterprotected void setLabelAsBold(boolean val)
labelAsBold variable.val - a boolean value telling whether labels should be created as bold in the excel document or notpublic org.apache.poi.ss.usermodel.Workbook createBook(ObjectSelection os, File workbook, WorkbookProvider.WORKBOOK_FORMAT bookFormat)
os - the data to exportworkbook - the target workbookbookFormat - the format, i.e. xls vs. xlsxDefaultExcelExporter, which is a generated class for a specific dialog modelpublic org.apache.poi.ss.usermodel.Workbook createBook(ObjectSelection os, OutputStream workbook, WorkbookProvider.WORKBOOK_FORMAT bookFormat)
os - the data to exportworkbook - the target workbookbookFormat - the format, i.e. xls vs. xlsxDefaultExcelExporter, which is a generated class for a specific dialog modelprotected abstract void exportDialog(ObjectSelection os, org.apache.poi.ss.usermodel.Sheet defaultSheet)
os - the datadefaultSheet - the default sheetprotected abstract void setAllMapElements()
DialogObjectConstant elements in the map.protected abstract String getSheetName()
Sheetprotected abstract boolean getParameterHidden()
protected abstract String getDialogName()
protected org.apache.poi.ss.usermodel.Cell createCell(DialogObjectConstant dialogElement, org.apache.poi.ss.usermodel.Sheet sheet, G9ExcelCell offset, boolean isLabel, short alignment)
dialogElement - the element to createsheet - the sheet to create the element inoffset - the global offset for the cellisLabel - indicates if the cell should hold a labelalignment - the specified alignmentprotected org.apache.poi.ss.usermodel.Cell createCell(DialogObjectConstant dialogElement, org.apache.poi.ss.usermodel.Sheet sheet, G9ExcelCell offset, boolean isLabel, int colIndex, short alignment)
dialogElement - the element to createsheet - the sheet to create the element inoffset - the global offset for the cellisLabel - indicates if the cell should hold a labelcolIndex - used in some special cases to indicate start columnalignment - the specified alignmentprotected org.apache.poi.ss.usermodel.Cell createCell(DialogObjectConstant dialogElement, org.apache.poi.ss.usermodel.Sheet sheet, G9ExcelCell offset, boolean isLabel, int colIndex, String columnTitle, short alignment)
dialogElement - the element to createsheet - the sheet to create the element inoffset - the global offset for the cellisLabel - indicates if the cell should hold a labelcolIndex - used in some special cases to indicate start column. The value -1 signals it is not to be usedcolumnTitle - used to name a cell in case the DialogObjectConstant is not able to provide a stringalignment - the specified alignmentprotected G9ExcelCell createTable(ObjectSelection os, RoleConstant targetRole, List<TableColumnData> columnDataList, org.apache.poi.ss.usermodel.Sheet sheet, G9ExcelCell initialCell, boolean showHeader, DialogObjectConstant doc)
os - the datatargetRole - the primary role for the tablecolumnDataList - a list containing data about each columnsheet - the Sheet in which the table should be added toinitialCell - the offset before creating the tableshowHeader - tells whether the columns headers should be showndoc - the DialogObjectConstantprotected Object getColumnObject(Object targetObject, RoleConstant attributeRole)
targetObject - contains data about role attributesattributeRole - some role constant belonging to the current columnprotected List<Object> getSortedTargetObjects(ObjectSelection os, RoleConstant targetRole)
Typically to be used in lists (list blocks and table blocks).
os - the datatargetRole - the target roleList of target objects. An empty list if no target objectsprotected void setCellData(DialogObjectConstant dialogElement, Object domainObject, org.apache.poi.ss.usermodel.Cell cell, String dateFormat)
dialogElement - the dialog elementdomainObject - the domain objectcell - the cell to put the data indateFormat - the format for datesprotected Object getTargetObject(ObjectSelection os, RoleConstant targetRole)
The operation will only navigate over single relations from parent to child.
os - the datatargetRole - the target rolepublic Object getRootOrTargetObject(ObjectSelection os, RoleConstant targetRole, String compare)
os - the ObjectSelectiontargetRole - the target rolecompare - the compare stringprotected static Object getChildObject(Object parent, OSRole<?> parentRole, RoleConstant childRole)
parent - the parent objectparentRole - the parent rolechildRole - the role constant to get the object forprotected static List<OSRole<?>> getRoleHierarchy(OSRole<?> targetRole)
targetRole - the target roleList of roles from target (first) to root (last). Empty list if targetRole is nullprotected static boolean hookFilterElement(DialogObjectConstant dialogElement, Object domainObject)
dialogElement - the dialog elementdomainObject - the domain objectprotected static org.apache.poi.ss.usermodel.Row getRow(org.apache.poi.ss.usermodel.Sheet sheet,
int localRow,
int offset)
Creates a new if it doesn't exist already.
sheet - the addressed sheetlocalRow - the row numberoffset - the offsetprotected static G9ExcelCell getMax(G9ExcelCell[] cells)
G9ExcelCell with max column and row.cells - some array containing G9ExcelCellsG9ExcelCellsprotected static G9ExcelCell getMax(G9ExcelCell offset, G9ExcelCell cell)
G9ExcelCell with max column and row.offset - the initial cellcell - the new cellG9ExcelCellsprotected G9ExcelCell getMaxCell(DialogObjectConstant[] dialogElements, G9ExcelCell offset)
dialogElements - the dialog elements to consideroffset - the maximum cell before dialog elements are addedprotected Object getRootObject(ObjectSelection os, RoleConstant targetRole)
os - the object selection (data)targetRole - the target roleprotected Object getDomainObjectFromParent(Object parentObject, RoleConstant targetRole)
parentObject - the parent domain objecttargetRole - the target roleprotected abstract Map<RoleConstant,OSRole<?>> getRoleMap()
Map from role constant to object selection roleprotected abstract ResourceBundle getBundle()
protected static ResourceBundle getGeneralBundle()
protected G9ExcelCell getNextAvailableCell(DialogObjectConstant[] dialogElements, G9ExcelCell offset)
Almost like getMaxCell, but the returned cell does not necessary contain the highest column index possible.
Instead, the maximum column index on the row having the highest row index, is used.
dialogElements - the dialog elements to consideroffset - the maximum cell before dialog elements are addedpublic int compare(Object o1, Object o2)
Uses the OS Role Map to get the target objects value.
The target objects values are then compared using their compareTo-method.
compare in interface Comparator<Object>o1 - a target objecto2 - also a target objectprotected static short getColumns(org.apache.poi.ss.usermodel.Sheet sheet)
sheet - the sheet with dataprotected static void autoResizeAll(org.apache.poi.ss.usermodel.Sheet sheet)
sheet - a Sheet contained within the workbook where all cells are going to be resizedCopyright © 2006–2017 Esito AS. All rights reserved.