Class AbstractPilotageReport
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.odfpilotage.report.AbstractPilotageReport
-
- All Implemented Interfaces:
PilotageReport
,LogEnabled
,PluginAware
,Initializable
,Configurable
,Serviceable
- Direct Known Subclasses:
AbstractExtract
,AbstractReport
public abstract class AbstractPilotageReport extends AbstractLogEnabled implements PilotageReport, Serviceable, Initializable, PluginAware, Configurable
The abstract class for pilotage reports.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractPilotageReport.PilotageFile
Object representing a pilotage file Containing the zip file and the report statusstatic class
AbstractPilotageReport.PilotageReportStatus
The enumerator for different pilotage report status-
Nested classes/interfaces inherited from interface org.ametys.plugins.odfpilotage.report.PilotageReport
PilotageReport.PilotageReportTarget
-
-
Field Summary
Fields Modifier and Type Field Description private static com.google.gson.Gson
__GSON
protected String
_currentFormattedDate
The current date formatted to yyyy-MM-ddprotected I18nUtils
_i18nUtils
The I18N utilsprivate String
_id
private I18nizableText
_label
private String
_mailFrom
protected ODFHelper
_odfHelper
The ODF helperprivate String
_outputFormat
protected PilotageHelper
_pilotageHelper
The pilotage helperprivate String
_pluginName
protected OdfReferenceTableHelper
_refTableHelper
The ODF enumeration helperprotected ReportHelper
_reportHelper
The report helperprotected AmetysObjectResolver
_resolver
The ametys object resolverprotected SourceResolver
_sourceResolver
The source resolverprotected File
_tmpFolder
The tmp folderprotected UserManager
_userManager
The user managerstatic String
MANIFEST_FILENAME
Filename of the manifest to describe the ZIP content-
Fields inherited from interface org.ametys.plugins.odfpilotage.report.PilotageReport
OUTPUT_FORMAT_DOC, OUTPUT_FORMAT_XLS, PARAMETER_CATALOG, PARAMETER_LANG, PARAMETER_ORGUNIT, PARAMETER_OUTPUT_FORMAT, PARAMETER_PROGRAM
-
-
Constructor Summary
Constructors Constructor Description AbstractPilotageReport()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
_buildZipName(String contextName)
Build the ZIP name.protected void
addManifest(ZipOutputStream zos, PilotageReport.PilotageReportTarget target, Map<String,String> reportParameters)
Add the manifest to JSON format to the ZIP.void
configure(Configuration configuration)
protected void
convertReport(File outputFolder, String fileName, File xmlFile)
Convert the report from XML to the required formatprotected AbstractPilotageReport.PilotageFile
createZipFile(File folderToZip, PilotageReport.PilotageReportTarget target, Map<String,String> reportParameters, String contextName)
Compress a folder to zip format.String
getId()
Retrieves the id of the report.I18nizableText
getLabel()
Retrieves the label of the report.protected String
getMailBody(AbstractPilotageReport.PilotageReportStatus status)
The mail body.protected String
getMailSubject()
The mail subject.protected String
getOutputFormat()
Get the output format of the report.protected String
getPipeline(String outputFolderName)
Build the pipeline to launch the transformation.protected String
getPluginName()
Get the plugin name to build the pipeline.protected String
getReportName()
The report name to add in the mail.protected Set<String>
getSupportedOutputFormats()
Get the list of supported output formatsprotected abstract String
getType()
Get the name of the reportvoid
initialize()
protected boolean
isCompatibleSchedulable(AbstractReportSchedulable schedulable)
Check if the given schedulable is compatible with the currentboolean
isGeneric()
Most of reports are generic.protected boolean
isSupportedFormat()
Get the output format of the report.protected abstract boolean
isSupportedTarget(PilotageReport.PilotageReportTarget target)
Returnstrue
if the target is supported by the report.void
launch(PilotageReport.PilotageReportTarget target, Map<String,String> reportParameters, UserIdentity user)
Launch a report on the given target with the given parameters.protected abstract String
launchByOrgUnit(Map<String,String> reportParameters)
Launch a report generation on an orgunit.protected abstract String
launchByProgram(Map<String,String> reportParameters)
Launch a report generation on a program.protected void
sendMail(AbstractPilotageReport.PilotageFile file, UserIdentity user)
Send a mail with the ZIP file as attachment at the end of the report generation.void
service(ServiceManager manager)
void
setPluginInfo(String pluginName, String featureName, String id)
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.boolean
supports(AbstractReportSchedulable schedulable)
Check if the report supports the given schedulable.-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
MANIFEST_FILENAME
public static final String MANIFEST_FILENAME
Filename of the manifest to describe the ZIP content- See Also:
- Constant Field Values
-
__GSON
private static final com.google.gson.Gson __GSON
-
_sourceResolver
protected SourceResolver _sourceResolver
The source resolver
-
_pilotageHelper
protected PilotageHelper _pilotageHelper
The pilotage helper
-
_resolver
protected AmetysObjectResolver _resolver
The ametys object resolver
-
_reportHelper
protected ReportHelper _reportHelper
The report helper
-
_refTableHelper
protected OdfReferenceTableHelper _refTableHelper
The ODF enumeration helper
-
_odfHelper
protected ODFHelper _odfHelper
The ODF helper
-
_userManager
protected UserManager _userManager
The user manager
-
_i18nUtils
protected I18nUtils _i18nUtils
The I18N utils
-
_tmpFolder
protected File _tmpFolder
The tmp folder
-
_currentFormattedDate
protected String _currentFormattedDate
The current date formatted to yyyy-MM-dd
-
_label
private I18nizableText _label
-
_pluginName
private String _pluginName
-
_outputFormat
private String _outputFormat
-
-
Constructor Detail
-
AbstractPilotageReport
public AbstractPilotageReport()
-
-
Method Detail
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getId
public String getId()
Description copied from interface:PilotageReport
Retrieves the id of the report.- Specified by:
getId
in interfacePilotageReport
- Returns:
- the id.
-
getLabel
public I18nizableText getLabel()
Description copied from interface:PilotageReport
Retrieves the label of the report.- Specified by:
getLabel
in interfacePilotageReport
- Returns:
- the label.
-
supports
public boolean supports(AbstractReportSchedulable schedulable)
Description copied from interface:PilotageReport
Check if the report supports the given schedulable.- Specified by:
supports
in interfacePilotageReport
- Parameters:
schedulable
- The schedulable to check- Returns:
true
if the schedulable is supported,false
otherwise
-
isGeneric
public boolean isGeneric()
Most of reports are generic. This method can be overridden.- Returns:
true
if the current report is generic,false
otherwise
-
isSupportedTarget
protected abstract boolean isSupportedTarget(PilotageReport.PilotageReportTarget target)
Returnstrue
if the target is supported by the report.- Parameters:
target
- The target to test- Returns:
true
if the target is supported,false
otherwise
-
isCompatibleSchedulable
protected boolean isCompatibleSchedulable(AbstractReportSchedulable schedulable)
Check if the given schedulable is compatible with the current- Parameters:
schedulable
- The schedulable to test- Returns:
true
if the schedulable is compatible with the report
-
launchByOrgUnit
protected abstract String launchByOrgUnit(Map<String,String> reportParameters) throws Exception
Launch a report generation on an orgunit.- Parameters:
reportParameters
- The report parameters- Returns:
- the name of the generated file
- Throws:
Exception
- if an exception occurs
-
launchByProgram
protected abstract String launchByProgram(Map<String,String> reportParameters) throws Exception
Launch a report generation on a program.- Parameters:
reportParameters
- The report parameters- Returns:
- the name of the generated file
- Throws:
Exception
- if an exception occurs
-
getPluginName
protected String getPluginName()
Get the plugin name to build the pipeline.- Returns:
- The plugin name
-
getOutputFormat
protected String getOutputFormat()
Get the output format of the report.- Returns:
- The output format
-
getSupportedOutputFormats
protected Set<String> getSupportedOutputFormats()
Get the list of supported output formats- Returns:
- A
Set
of supported output formats
-
isSupportedFormat
protected boolean isSupportedFormat()
Get the output format of the report.- Returns:
- The output format
-
getPipeline
protected String getPipeline(String outputFolderName)
Build the pipeline to launch the transformation.- Parameters:
outputFolderName
- The name of the output folder name- Returns:
- The pipeline for transformation
-
launch
public void launch(PilotageReport.PilotageReportTarget target, Map<String,String> reportParameters, UserIdentity user)
Description copied from interface:PilotageReport
Launch a report on the given target with the given parameters.- Specified by:
launch
in interfacePilotageReport
- Parameters:
target
- The target of the reportreportParameters
- The report parametersuser
- The current user
-
convertReport
protected void convertReport(File outputFolder, String fileName, File xmlFile) throws IOException
Convert the report from XML to the required format- Parameters:
outputFolder
- folder where the file will stay temporarilyfileName
- the filename without the extensionxmlFile
- the file to be converted- Throws:
IOException
- if an error occurs
-
createZipFile
protected AbstractPilotageReport.PilotageFile createZipFile(File folderToZip, PilotageReport.PilotageReportTarget target, Map<String,String> reportParameters, String contextName) throws IOException
Compress a folder to zip format.- Parameters:
folderToZip
- the folder to be compressedtarget
- The target of the reportreportParameters
- The report parameterscontextName
- the name of the report context- Returns:
- The pilotage file
- Throws:
IOException
- if an exception occurs
-
addManifest
protected void addManifest(ZipOutputStream zos, PilotageReport.PilotageReportTarget target, Map<String,String> reportParameters) throws IOException
Add the manifest to JSON format to the ZIP.- Parameters:
zos
- The ZIP output streamtarget
- The target of the reportreportParameters
- The report parameters- Throws:
IOException
- if an exception occurs
-
sendMail
protected void sendMail(AbstractPilotageReport.PilotageFile file, UserIdentity user)
Send a mail with the ZIP file as attachment at the end of the report generation.- Parameters:
file
- the pilotage fileuser
- the recipient if he has an email
-
getMailSubject
protected String getMailSubject()
The mail subject.- Returns:
- The subject of the mail
-
getMailBody
protected String getMailBody(AbstractPilotageReport.PilotageReportStatus status)
The mail body.- Parameters:
status
- the status of the pilotage report- Returns:
- The body of the mail
-
getReportName
protected String getReportName()
The report name to add in the mail.- Returns:
- The report name
-
_buildZipName
protected String _buildZipName(String contextName)
Build the ZIP name.- Parameters:
contextName
- The report context name- Returns:
- The full ZIP name
-
-