Class DefaultReportViewConverterStrategy
- java.lang.Object
-
- de.hybris.platform.auditreport.service.impl.AbstractTemplateViewConverterStrategy
-
- de.hybris.platform.auditreport.service.impl.DefaultReportViewConverterStrategy
-
- All Implemented Interfaces:
ReportViewConverterStrategy
public class DefaultReportViewConverterStrategy extends AbstractTemplateViewConverterStrategy
The strategy generates reports by using Apache Velocity templates. Velocity templates can operate on java object (collection with reports, keyVELOCITY_CTX_REPORTS) or text representation of that java object (generated by an implementation of theReportViewConverterStrategy, keyVELOCITY_CTX_REPORTS_TEXT).
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_FILE_NAMEstatic java.lang.StringTEMP_FILE_EXTENSIONstatic java.lang.StringTEMP_FILE_PREFIXstatic java.lang.StringVELOCITY_CTX_CONFIG_NAMEstatic java.lang.StringVELOCITY_CTX_GENERATED_BYstatic java.lang.StringVELOCITY_CTX_GENERATED_FORstatic java.lang.StringVELOCITY_CTX_GENERATED_TIMESTAMPstatic java.lang.StringVELOCITY_CTX_REPORT_NAMEstatic java.lang.StringVELOCITY_CTX_REPORTSKey under which a Velocity context stores a collection withReportViewobjects.static java.lang.StringVELOCITY_CTX_REPORTS_TEXTKey under which a Velocity context stores text representation of the collection withReportViewobjects.-
Fields inherited from class de.hybris.platform.auditreport.service.impl.AbstractTemplateViewConverterStrategy
CTX_CONFIG_NAME, CTX_CURRENT_USER, CTX_REPORT_ID, CTX_ROOT_ITEM, CTX_TEMPLATE
-
-
Constructor Summary
Constructors Constructor Description DefaultReportViewConverterStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected java.util.List<ReportConversionData>convert(java.util.List<ReportView> reports, RendererTemplateModel template, java.util.Map<java.lang.String,java.lang.Object> context)Deprecated.since 1811java.util.List<ReportConversionData>convert(java.util.stream.Stream<ReportView> reports, RendererTemplateModel template, java.util.Map<java.lang.String,java.lang.Object> context)protected ReportConversionDataconvertUsingTemplate(RendererTemplateModel template, java.util.Map<java.lang.String,java.lang.Object> conversionContext)Converts the given reports to html format.protected java.util.Map<java.lang.String,java.lang.Object>createConversionContext(java.util.List<ReportView> reports, java.util.Map<java.lang.String,java.lang.Object> context)Deprecated.since 1811protected java.util.Map<java.lang.String,java.lang.Object>createConversionContext(java.util.Map<java.lang.String,java.lang.Object> context)Create context for conversion.java.util.Collection<org.apache.velocity.runtime.directive.Directive>getCustomDirectives()I18NServicegetI18NService()protected RendererServicegetRendererService()java.lang.StringgetReportName()SessionServicegetSessionService()protected ReportViewConverterStrategygetTextConverterStrategy()protected java.util.Map<java.lang.String,java.lang.Object>prepareAdditionalContext(java.util.Map<java.lang.String,java.lang.Object> context)Prepares a Velocity context.protected voidregisterRequiredCustomDirectives()voidsetCustomDirectives(java.util.Collection<org.apache.velocity.runtime.directive.Directive> customDirectives)voidsetI18NService(I18NService i18NService)voidsetRendererService(RendererService rendererService)voidsetReportName(java.lang.String reportName)Sets a name of the report.voidsetSessionService(SessionService sessionService)voidsetTextConverterStrategy(ReportViewConverterStrategy textConverterStrategy)Sets an implementation of theReportViewConverterStrategywhich generates text representation of the report.-
Methods inherited from class de.hybris.platform.auditreport.service.impl.AbstractTemplateViewConverterStrategy
convert, convert
-
-
-
-
Field Detail
-
VELOCITY_CTX_REPORTS
public static final java.lang.String VELOCITY_CTX_REPORTS
Key under which a Velocity context stores a collection withReportViewobjects.- See Also:
- Constant Field Values
-
VELOCITY_CTX_REPORTS_TEXT
public static final java.lang.String VELOCITY_CTX_REPORTS_TEXT
Key under which a Velocity context stores text representation of the collection withReportViewobjects.- See Also:
VELOCITY_CTX_REPORTS, Constant Field Values
-
VELOCITY_CTX_GENERATED_TIMESTAMP
public static final java.lang.String VELOCITY_CTX_GENERATED_TIMESTAMP
- See Also:
- Constant Field Values
-
VELOCITY_CTX_GENERATED_BY
public static final java.lang.String VELOCITY_CTX_GENERATED_BY
- See Also:
- Constant Field Values
-
VELOCITY_CTX_GENERATED_FOR
public static final java.lang.String VELOCITY_CTX_GENERATED_FOR
- See Also:
- Constant Field Values
-
VELOCITY_CTX_REPORT_NAME
public static final java.lang.String VELOCITY_CTX_REPORT_NAME
- See Also:
- Constant Field Values
-
VELOCITY_CTX_CONFIG_NAME
public static final java.lang.String VELOCITY_CTX_CONFIG_NAME
- See Also:
- Constant Field Values
-
DEFAULT_FILE_NAME
public static final java.lang.String DEFAULT_FILE_NAME
- See Also:
- Constant Field Values
-
TEMP_FILE_EXTENSION
public static final java.lang.String TEMP_FILE_EXTENSION
- See Also:
- Constant Field Values
-
TEMP_FILE_PREFIX
public static final java.lang.String TEMP_FILE_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
convert
@Deprecated protected java.util.List<ReportConversionData> convert(java.util.List<ReportView> reports, RendererTemplateModel template, java.util.Map<java.lang.String,java.lang.Object> context)
Deprecated.since 1811Description copied from class:AbstractTemplateViewConverterStrategyCaution: as this method will be removedAbstractTemplateViewConverterStrategy.convert(java.util.stream.Stream, de.hybris.platform.commons.model.renderer.RendererTemplateModel, java.util.Map)will become abstract.- Specified by:
convertin classAbstractTemplateViewConverterStrategy
-
convert
public java.util.List<ReportConversionData> convert(java.util.stream.Stream<ReportView> reports, RendererTemplateModel template, java.util.Map<java.lang.String,java.lang.Object> context)
- Overrides:
convertin classAbstractTemplateViewConverterStrategy
-
createConversionContext
protected java.util.Map<java.lang.String,java.lang.Object> createConversionContext(java.util.Map<java.lang.String,java.lang.Object> context)
Create context for conversion.- Parameters:
context- a map used to pass in additional jsonData needed by the strategy.- Returns:
- context prepared to perform conversion
-
createConversionContext
@Deprecated protected java.util.Map<java.lang.String,java.lang.Object> createConversionContext(java.util.List<ReportView> reports, java.util.Map<java.lang.String,java.lang.Object> context)
Deprecated.since 1811Create context for conversion.- Parameters:
reports- generated report viewcontext- a map used to pass in additional jsonData needed by the strategy.- Returns:
- context prepared to perform conversion
-
convertUsingTemplate
protected ReportConversionData convertUsingTemplate(RendererTemplateModel template, java.util.Map<java.lang.String,java.lang.Object> conversionContext)
Converts the given reports to html format.- Parameters:
template- template used to convert the raw data into desired format.conversionContext- conversion context.- Returns:
- an object representing a generated report file.
-
registerRequiredCustomDirectives
protected void registerRequiredCustomDirectives()
-
prepareAdditionalContext
protected java.util.Map<java.lang.String,java.lang.Object> prepareAdditionalContext(java.util.Map<java.lang.String,java.lang.Object> context)
Prepares a Velocity context.- Parameters:
context- original context passed to theAbstractTemplateViewConverterStrategy.convert(List, Map)method.- Returns:
VelocityContextcontaining the generation timestamp, report id, configuration name and user names (generated by and for).
-
getReportName
public java.lang.String getReportName()
-
setReportName
public void setReportName(java.lang.String reportName)
Sets a name of the report. By default the strategy usesDEFAULT_FILE_NAME.- Parameters:
reportName- the report name.
-
getTextConverterStrategy
protected ReportViewConverterStrategy getTextConverterStrategy()
-
setTextConverterStrategy
public void setTextConverterStrategy(ReportViewConverterStrategy textConverterStrategy)
Sets an implementation of theReportViewConverterStrategywhich generates text representation of the report.- Parameters:
textConverterStrategy- the strategy which produces text representation of the report.
-
getRendererService
protected RendererService getRendererService()
-
setRendererService
public void setRendererService(RendererService rendererService)
-
getSessionService
public SessionService getSessionService()
-
setSessionService
public void setSessionService(SessionService sessionService)
-
getI18NService
public I18NService getI18NService()
-
setI18NService
public void setI18NService(I18NService i18NService)
-
getCustomDirectives
public java.util.Collection<org.apache.velocity.runtime.directive.Directive> getCustomDirectives()
-
setCustomDirectives
public void setCustomDirectives(java.util.Collection<org.apache.velocity.runtime.directive.Directive> customDirectives)
-
-