Class DefaultAuditReportDataService
- java.lang.Object
-
- de.hybris.platform.auditreport.service.impl.DefaultAuditReportDataService
-
- All Implemented Interfaces:
AuditReportDataService
public class DefaultAuditReportDataService extends java.lang.Object implements AuditReportDataService
This service uses instances ofReportViewConverterStrategyto generate a zip file containing files generated by all of the strategies. The generated files contain representations of theReportView's obtained for a given configuration.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_FILE_NAMEprotected static java.lang.StringZIP_EXTENSIONprotected static java.lang.StringZIP_MIME_TYPE
-
Constructor Summary
Constructors Constructor Description DefaultAuditReportDataService()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected byte[]compressContent(java.util.Map<java.lang.String,byte[]> filesByName)Deprecated, for removal: This API element is subject to removal in a future version.1811protected java.io.InputStreamcompressContentStream(java.util.Map<java.lang.String,java.io.InputStream> filesByName)Creates a byte array representation of ZIP archive.AuditReportDataModelcreateReport(CreateAuditReportParams params)Creates a new report for given parameters.protected java.lang.StringcreateReportFileName()Creates report file name which always ends with ".zip".protected java.util.List<ReportView>createReportsViews(ItemModel item, java.lang.String configName, boolean audit, java.util.Collection<LanguageModel> includedLanguages)Deprecated, for removal: This API element is subject to removal in a future version.since 1811protected java.util.stream.Stream<ReportView>createReportsViewsStream(ItemModel item, java.lang.String configName, boolean audit, java.util.Collection<LanguageModel> includedLanguages)voiddeleteReportsForItem(ItemModel item)Deletes all reports generated for givenItemModelprotected java.util.Map<java.lang.String,byte[]>evaluateStrategies(java.util.List<ReportView> reports, java.util.Map<java.lang.String,java.lang.Object> context)Deprecated, for removal: This API element is subject to removal in a future version.since 1811protected java.util.Map<java.lang.String,byte[]>evaluateStrategies(java.util.stream.Stream<ReportView> reports, java.util.Map<java.lang.String,java.lang.Object> context)Deprecated, for removal: This API element is subject to removal in a future version.since 1811protected java.util.Map<java.lang.String,java.io.InputStream>evaluateStrategiesToStreams(java.util.stream.Stream<ReportView> reports, java.util.Map<java.lang.String,java.lang.Object> context)Creates a map which stores binary representation of the reports (keys = files names).AuditViewServicegetAuditViewService()protected FlexibleSearchServicegetFlexibleSearchService()MediaServicegetMediaService()ModelServicegetModelService()java.lang.StringgetReportFileName()java.lang.StringgetReportFolderName()java.util.List<ReportViewConverterStrategy>getReportViewConverterStrategies()UserServicegetUserService()protected java.util.Map<java.lang.String,java.lang.Object>populateReportGenerationContext(ItemModel rootItem, java.lang.String configName, java.lang.String reportId, AuditReportTemplateModel template)Populates context map that will be passed to the report generation procedure.protected AuditReportDataModelsaveReport(ItemModel rootItem, java.lang.String reportId, java.lang.String configName, byte[] content)Deprecated, for removal: This API element is subject to removal in a future version.since 1811protected AuditReportDataModelsaveReport(ItemModel rootItem, java.lang.String reportId, java.lang.String configName, java.io.InputStream content)Saves an audit report with given identifier and content.voidsetAuditViewService(AuditViewService auditViewService)voidsetFlexibleSearchService(FlexibleSearchService flexibleSearchService)voidsetMediaService(MediaService mediaService)voidsetModelService(ModelService modelService)voidsetReportFileName(java.lang.String reportFileName)Sets a name of the ZIP archive saved in the report media.voidsetReportFolderName(java.lang.String reportFolderName)voidsetReportViewConverterStrategies(java.util.List<ReportViewConverterStrategy> reportViewConverterStrategies)voidsetUserService(UserService userService)
-
-
-
Field Detail
-
DEFAULT_FILE_NAME
public static final java.lang.String DEFAULT_FILE_NAME
- See Also:
- Constant Field Values
-
ZIP_MIME_TYPE
protected static final java.lang.String ZIP_MIME_TYPE
- See Also:
- Constant Field Values
-
ZIP_EXTENSION
protected static final java.lang.String ZIP_EXTENSION
- See Also:
- Constant Field Values
-
-
Method Detail
-
createReport
public AuditReportDataModel createReport(CreateAuditReportParams params)
Description copied from interface:AuditReportDataServiceCreates a new report for given parameters. The created report is saved in database before return.- Specified by:
createReportin interfaceAuditReportDataService- Parameters:
params- parameters needed to generate the report.- Returns:
- the new report with audit data.
-
deleteReportsForItem
public void deleteReportsForItem(ItemModel item)
Description copied from interface:AuditReportDataServiceDeletes all reports generated for givenItemModel- Specified by:
deleteReportsForItemin interfaceAuditReportDataService- Parameters:
item- item to be used to lookup reports
-
populateReportGenerationContext
protected java.util.Map<java.lang.String,java.lang.Object> populateReportGenerationContext(ItemModel rootItem, java.lang.String configName, java.lang.String reportId, AuditReportTemplateModel template)
Populates context map that will be passed to the report generation procedure.- Parameters:
rootItem- for which item / user the report is generated.configName- name of the configuration that was used to generate the report.reportId- name of the report.template- template used to generate the report view.- Returns:
- a map of values available in the report generation.
-
evaluateStrategies
@Deprecated(since="1811", forRemoval=true) protected java.util.Map<java.lang.String,byte[]> evaluateStrategies(java.util.List<ReportView> reports, java.util.Map<java.lang.String,java.lang.Object> context)Deprecated, for removal: This API element is subject to removal in a future version.since 1811Creates a map which stores binary representation of the reports (keys = files names). It usesconverter strategiesto convert reports to binary format.- Parameters:
reports- the list with reports to convert.context- context object to pass in data to the used generation strategies.- Returns:
- the map with files.
- See Also:
getReportViewConverterStrategies()
-
evaluateStrategies
@Deprecated(since="1811", forRemoval=true) protected java.util.Map<java.lang.String,byte[]> evaluateStrategies(java.util.stream.Stream<ReportView> reports, java.util.Map<java.lang.String,java.lang.Object> context)Deprecated, for removal: This API element is subject to removal in a future version.since 1811Creates a map which stores binary representation of the reports (keys = files names). It usesconverter strategiesto convert reports to binary format.- Parameters:
reports- the list with reports to convert.context- context object to pass in data to the used generation strategies.- Returns:
- the map with files.
- See Also:
getReportViewConverterStrategies()
-
evaluateStrategiesToStreams
protected java.util.Map<java.lang.String,java.io.InputStream> evaluateStrategiesToStreams(java.util.stream.Stream<ReportView> reports, java.util.Map<java.lang.String,java.lang.Object> context)
Creates a map which stores binary representation of the reports (keys = files names). It usesconverter strategiesto convert reports to binary format.- Parameters:
reports- the list with reports to convert.context- context object to pass in data to the used generation strategies.- Returns:
- the map with files.
- See Also:
getReportViewConverterStrategies()
-
createReportsViews
@Deprecated(since="1811", forRemoval=true) protected java.util.List<ReportView> createReportsViews(ItemModel item, java.lang.String configName, boolean audit, java.util.Collection<LanguageModel> includedLanguages)Deprecated, for removal: This API element is subject to removal in a future version.since 1811Creates reports views for given item specified and configuration name.- Parameters:
item- the item for which report will be generated.configName- the configuration name used to create a new report.audit- if set to true the generated report will contain audit data. Otherwise data snapshot will be taken.includedLanguages- all mentioned languages will be included in the report. Other languages will be omitted. In case no language is set all available languages will be exported.- Returns:
- reports views.
-
createReportsViewsStream
protected java.util.stream.Stream<ReportView> createReportsViewsStream(ItemModel item, java.lang.String configName, boolean audit, java.util.Collection<LanguageModel> includedLanguages)
-
compressContent
@Deprecated(since="1811", forRemoval=true) protected byte[] compressContent(java.util.Map<java.lang.String,byte[]> filesByName) throws java.io.IOExceptionDeprecated, for removal: This API element is subject to removal in a future version.1811Creates a byte array representation of ZIP archive.- Parameters:
filesByName- the map where keys store files names and values store files content.- Returns:
- the input stream which represents ZIP archive.
- Throws:
java.io.IOException- if any I/O error occurred.
-
compressContentStream
protected java.io.InputStream compressContentStream(java.util.Map<java.lang.String,java.io.InputStream> filesByName) throws java.io.IOExceptionCreates a byte array representation of ZIP archive.- Parameters:
filesByName- the map where keys store files names and values store files content.- Returns:
- the input stream which represents ZIP archive.
- Throws:
java.io.IOException- if any I/O error occurred.
-
saveReport
@Deprecated(since="1811", forRemoval=true) protected AuditReportDataModel saveReport(ItemModel rootItem, java.lang.String reportId, java.lang.String configName, byte[] content)Deprecated, for removal: This API element is subject to removal in a future version.since 1811Saves an audit report with given identifier and content. Reports are stored in folder returned bygetReportFileName().- Parameters:
rootItem- item for which the report is generatedreportId- the report identifier.configName- name of theAuditReportConfigModelused to generate reportcontent- the content saved in report media. @return the saved audit report.
-
saveReport
protected AuditReportDataModel saveReport(ItemModel rootItem, java.lang.String reportId, java.lang.String configName, java.io.InputStream content)
Saves an audit report with given identifier and content. Reports are stored in folder returned bygetReportFileName().- Parameters:
rootItem- item for which the report is generatedreportId- the report identifier.configName- name of theAuditReportConfigModelused to generate reportcontent- the content saved in report media. @return the saved audit report.
-
createReportFileName
protected java.lang.String createReportFileName()
Creates report file name which always ends with ".zip".- Returns:
- the report file name.
-
getReportFileName
public java.lang.String getReportFileName()
-
setReportFileName
public void setReportFileName(java.lang.String reportFileName)
Sets a name of the ZIP archive saved in the report media. By default the service usesDEFAULT_FILE_NAME. If file name does not end with ".zip" extension, then it will be appended.- Parameters:
reportFileName- the ZIP archive name.
-
getAuditViewService
public AuditViewService getAuditViewService()
-
setAuditViewService
public void setAuditViewService(AuditViewService auditViewService)
-
getMediaService
public MediaService getMediaService()
-
setMediaService
public void setMediaService(MediaService mediaService)
-
getModelService
public ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getUserService
public UserService getUserService()
-
setUserService
public void setUserService(UserService userService)
-
getReportViewConverterStrategies
public java.util.List<ReportViewConverterStrategy> getReportViewConverterStrategies()
-
setReportViewConverterStrategies
public void setReportViewConverterStrategies(java.util.List<ReportViewConverterStrategy> reportViewConverterStrategies)
-
getReportFolderName
public java.lang.String getReportFolderName()
-
setReportFolderName
public void setReportFolderName(java.lang.String reportFolderName)
-
getFlexibleSearchService
protected FlexibleSearchService getFlexibleSearchService()
-
setFlexibleSearchService
public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
-
-