public class DefaultExcelTemplateService extends java.lang.Object implements ExcelTemplateService
| Constructor and Description |
|---|
DefaultExcelTemplateService() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
activateFirstNonUtilitySheet(Workbook workbook) |
protected void |
addAttributeToExcelTypeSystemSheet(AttributeDescriptorModel attributeDescriptor,
Sheet sheet) |
protected void |
addAttributeToExcelTypeSystemSheet(AttributeDescriptorModel attributeDescriptor,
Sheet sheet,
java.lang.String langIsoCode) |
void |
addTypeSheet(java.lang.String typeName,
Workbook workbook)
Adds a new sheet to given workbook.
|
Row |
createEmptyRow(Sheet sheet)
Creates an empty row in given sheet.
|
protected java.lang.String |
createSheetName(java.lang.String typeCode,
Workbook workbook) |
Sheet |
createTypeSheet(java.lang.String typeCode,
Workbook workbook)
Creates a new type sheet in given workbook.
|
Workbook |
createWorkbook(java.io.InputStream is)
Creates workbook object based on inputStream of excel file.
|
protected java.lang.String |
findAttributeDisplayNameInTypeSystemSheet(Sheet typeSystemSheet,
SelectedAttribute selectedAttribute) |
int |
findColumnIndex(Sheet typeSystemSheet,
Sheet sheet,
SelectedAttribute selectedAttribute)
Finds column index based on selected attribute.
|
java.lang.String |
findSheetNameForTypeCode(java.lang.String typeCode,
Workbook workbook)
Finds sheet name for given type code.
|
java.lang.String |
findTypeCodeForSheetName(java.lang.String sheetName,
Workbook workbook)
Finds type code for given sheet name.
|
protected java.util.Optional<Row> |
findTypeSystemRowForGivenHeader(Sheet typeSystemSheet,
java.lang.String typeCode,
java.lang.String header) |
protected java.lang.String |
getAttributeDescriptorName(AttributeDescriptorModel attributeDescriptor) |
java.lang.String |
getAttributeDisplayName(AttributeDescriptorModel attributeDescriptor,
java.lang.String langIsoCode)
Returns displayed header name based on attribute descriptor
|
java.lang.String |
getCellValue(Cell cell)
Returns cell value as a string value.
|
CommonI18NService |
getCommonI18NService() |
ExcelDateUtils |
getExcelDateUtils() |
ExcelSheetNamingStrategy |
getExcelSheetNamingStrategy() |
ExcelTranslatorRegistry |
getExcelTranslatorRegistry() |
java.util.List<SelectedAttribute> |
getHeaders(Sheet typeSystemSheet,
Sheet typeSheet)
Returns list of selected attributes for given sheet, based on metainformation from type system sheet.
|
protected java.lang.String |
getHeaderValueWithoutMetadata(java.lang.String headerValue) |
protected java.lang.String |
getNumericCellValue(Cell cell) |
PermissionCRUDService |
getPermissionCRUDService() |
java.util.List<SelectedAttributeQualifier> |
getSelectedAttributesQualifiers(Sheet typeSystemSheet,
Sheet typeSheet)
Returns qualifiers of attributes which at selected in the typSheet
|
java.util.List<Sheet> |
getSheets(Workbook workbook)
Returns all sheets except sheets contains metadata (TypeSystem and TypeTemplate).
|
java.util.List<java.lang.String> |
getSheetsNames(Workbook workbook)
Returns all sheets names except sheets contains metadata (TypeSystem and TypeTemplate).
|
protected java.util.TimeZone |
getTimeZone() |
TypeService |
getTypeService() |
Sheet |
getTypeSystemSheet(Workbook workbook)
Returns sheet which contains metadata about type system
|
protected int |
getUtilitySheetHiddenLevel() |
protected void |
hideUtilitySheet(Workbook workbook,
java.lang.String sheetName) |
void |
insertAttributeHeader(Sheet sheet,
SelectedAttribute selectedAttribute,
int columnIndex)
Inserts value to the sheet's header (first row)
|
void |
insertAttributesHeader(Sheet sheet,
java.util.Collection<SelectedAttribute> selectedAttributes)
A shortcut for It is possible to inserts all values to the header at once instead of
invoking for every attribute separately
|
void |
insertAttributeValue(Cell cell,
java.lang.Object value)
Inserts given value to a given cell
|
protected boolean |
isMandatory(AttributeDescriptorModel attributeDescriptor,
java.lang.String langIsoCode) |
protected AttributeDescriptorModel |
loadAttributeDescriptor(Row row) |
protected java.lang.String |
loadIsoCode(Row row) |
protected void |
persistSheetNameInProperties(java.lang.String typeCode,
java.lang.String sheetName,
Workbook workbook) |
protected void |
populateTypeSystemSheet(ComposedTypeModel composedType,
Workbook workbook) |
void |
setCommonI18NService(CommonI18NService commonI18NService) |
void |
setExcelDateUtils(ExcelDateUtils excelDateUtils) |
void |
setExcelSheetNamingStrategy(ExcelSheetNamingStrategy excelSheetNamingStrategy) |
void |
setExcelTranslatorRegistry(ExcelTranslatorRegistry excelTranslatorRegistry) |
void |
setPermissionCRUDService(PermissionCRUDService permissionCRUDService) |
void |
setTypeService(TypeService typeService) |
public Workbook createWorkbook(java.io.InputStream is)
createWorkbook in interface ExcelTemplateServiceis - Input stream of excel fileWorkbook object which represents excel filepublic Sheet getTypeSystemSheet(Workbook workbook)
getTypeSystemSheet in interface ExcelTemplateServiceworkbook - Workbook object which represents excel fileSheet which contains information about type systempublic java.util.List<java.lang.String> getSheetsNames(Workbook workbook)
getSheetsNames in interface ExcelTemplateServiceworkbook - Workbook object which represents excel filepublic java.util.List<Sheet> getSheets(Workbook workbook)
getSheets in interface ExcelTemplateServiceworkbook - Workbook object which represents excel filepublic java.lang.String getCellValue(Cell cell)
getCellValue in interface ExcelTemplateServicecell - Cellprotected java.lang.String getNumericCellValue(Cell cell)
protected java.util.TimeZone getTimeZone()
public java.util.List<SelectedAttribute> getHeaders(Sheet typeSystemSheet, Sheet typeSheet)
getHeaders in interface ExcelTemplateServicetypeSystemSheet - Sheet contains metainformation about attributes for each type sheetstypeSheet - Sheet contains data for given sheetpublic java.util.List<SelectedAttributeQualifier> getSelectedAttributesQualifiers(Sheet typeSystemSheet, Sheet typeSheet)
ExcelTemplateServicegetSelectedAttributesQualifiers in interface ExcelTemplateServicetypeSystemSheet - Sheet contains metainformation about attributes for each type sheetstypeSheet - Sheet contains data for given sheetprotected java.lang.String getHeaderValueWithoutMetadata(java.lang.String headerValue)
protected java.util.Optional<Row> findTypeSystemRowForGivenHeader(Sheet typeSystemSheet,
java.lang.String typeCode,
java.lang.String header)
protected AttributeDescriptorModel loadAttributeDescriptor(Row row)
protected java.lang.String loadIsoCode(Row row)
public int findColumnIndex(Sheet typeSystemSheet,
Sheet sheet,
SelectedAttribute selectedAttribute)
ExcelTemplateServicefindColumnIndex in interface ExcelTemplateServicetypeSystemSheet - - sheet which contains information about type systemsheet - sheet for current typeselectedAttribute - attribute for which column index should be found.protected java.lang.String findAttributeDisplayNameInTypeSystemSheet(Sheet typeSystemSheet,
SelectedAttribute selectedAttribute)
public Sheet createTypeSheet(java.lang.String typeCode,
Workbook workbook)
ExcelTemplateServicecreateTypeSheet in interface ExcelTemplateServicetypeCode - a new sheet name. Moreover, an additional sheet called "TypeSystem" is populated by data of this
typeCode.workbook - workbook which will be extended by a new sheetprotected java.lang.String createSheetName(java.lang.String typeCode,
Workbook workbook)
protected void persistSheetNameInProperties(java.lang.String typeCode,
java.lang.String sheetName,
Workbook workbook)
public java.lang.String findTypeCodeForSheetName(java.lang.String sheetName,
Workbook workbook)
ExcelTemplateServicefindTypeCodeForSheetName in interface ExcelTemplateServicesheetName - sheet name.workbook - workbook.public java.lang.String findSheetNameForTypeCode(java.lang.String typeCode,
Workbook workbook)
ExcelTemplateServicefindSheetNameForTypeCode in interface ExcelTemplateServicetypeCode - type codeworkbook - workbookpublic void addTypeSheet(java.lang.String typeName,
Workbook workbook)
ExcelTemplateServiceaddTypeSheet in interface ExcelTemplateServicetypeName - a new sheet name.workbook - workbook which will be extended by a new sheetpublic void insertAttributeHeader(Sheet sheet,
SelectedAttribute selectedAttribute,
int columnIndex)
ExcelTemplateServiceinsertAttributeHeader in interface ExcelTemplateServicesheet - where the value will be insertedselectedAttribute - a pojo which allows to retrieve value to insertcolumnIndex - index of a column for inserted valuepublic void insertAttributesHeader(Sheet sheet,
java.util.Collection<SelectedAttribute> selectedAttributes)
ExcelTemplateServiceinsertAttributesHeader in interface ExcelTemplateServicesheet - where the value will be insertedselectedAttributes - a pojo which allows to retrieve value to insertpublic void insertAttributeValue(Cell cell,
java.lang.Object value)
ExcelTemplateServiceinsertAttributeValue in interface ExcelTemplateServicecell - where the value will be insertedvalue - a value to insertpublic Row createEmptyRow(Sheet sheet)
ExcelTemplateServicecreateEmptyRow in interface ExcelTemplateServicesheet - where the row will be createdprotected void hideUtilitySheet(Workbook workbook,
java.lang.String sheetName)
protected int getUtilitySheetHiddenLevel()
protected void activateFirstNonUtilitySheet(Workbook workbook)
protected void populateTypeSystemSheet(ComposedTypeModel composedType, Workbook workbook)
protected void addAttributeToExcelTypeSystemSheet(AttributeDescriptorModel attributeDescriptor, Sheet sheet)
protected void addAttributeToExcelTypeSystemSheet(AttributeDescriptorModel attributeDescriptor, Sheet sheet, java.lang.String langIsoCode)
public java.lang.String getAttributeDisplayName(AttributeDescriptorModel attributeDescriptor, java.lang.String langIsoCode)
ExcelTemplateServicegetAttributeDisplayName in interface ExcelTemplateServiceattributeDescriptor - attribute descriptor of selected attributelangIsoCode - - isoCode of languageprotected boolean isMandatory(AttributeDescriptorModel attributeDescriptor, java.lang.String langIsoCode)
protected java.lang.String getAttributeDescriptorName(AttributeDescriptorModel attributeDescriptor)
public void setTypeService(TypeService typeService)
public TypeService getTypeService()
public CommonI18NService getCommonI18NService()
public void setCommonI18NService(CommonI18NService commonI18NService)
public ExcelTranslatorRegistry getExcelTranslatorRegistry()
public void setExcelTranslatorRegistry(ExcelTranslatorRegistry excelTranslatorRegistry)
public PermissionCRUDService getPermissionCRUDService()
public void setPermissionCRUDService(PermissionCRUDService permissionCRUDService)
public ExcelDateUtils getExcelDateUtils()
public void setExcelDateUtils(ExcelDateUtils excelDateUtils)
public ExcelSheetNamingStrategy getExcelSheetNamingStrategy()
public void setExcelSheetNamingStrategy(ExcelSheetNamingStrategy excelSheetNamingStrategy)
Copyright © 2018 SAP SE. All Rights Reserved.