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
Modifier and TypeClassDescriptionstatic class
Object representing a pilotage file Containing the zip file and the report statusstatic enum
The enumerator for different pilotage report statusNested classes/interfaces inherited from interface org.ametys.plugins.odfpilotage.report.PilotageReport
PilotageReport.PilotageReportTarget
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
The current date formatted to yyyy-MM-ddprotected I18nUtils
The I18N utilsprotected ODFHelper
The ODF helperprotected PilotageHelper
The pilotage helperprotected OdfReferenceTableHelper
The ODF enumeration helperprotected ReportHelper
The report helperprotected AmetysObjectResolver
The ametys object resolverprotected SourceResolver
The source resolverprotected File
The tmp folderprotected UserManager
The user managerstatic final String
Filename of the manifest to describe the ZIP contentFields 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
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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.getId()
Retrieves the id of the report.getLabel()
Retrieves the label of the report.protected String
The mail body.protected String
The mail subject.protected String
Get the output format of the report.protected String
getPipeline
(String outputFolderName) Build the pipeline to launch the transformation.protected String
Get the plugin name to build the pipeline.protected String
The report name to add in the mail.Get the list of supported output formatsprotected abstract String
getType()
Get the name of the reportvoid
protected boolean
isCompatibleSchedulable
(AbstractReportSchedulable schedulable) Check if the given schedulable is compatible with the currentboolean
Most of reports are generic.protected boolean
Get the output format of the report.protected abstract boolean
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 Details
-
MANIFEST_FILENAME
Filename of the manifest to describe the ZIP content- See Also:
-
_sourceResolver
The source resolver -
_pilotageHelper
The pilotage helper -
_resolver
The ametys object resolver -
_reportHelper
The report helper -
_refTableHelper
The ODF enumeration helper -
_odfHelper
The ODF helper -
_userManager
The user manager -
_i18nUtils
The I18N utils -
_tmpFolder
The tmp folder -
_currentFormattedDate
The current date formatted to yyyy-MM-dd
-
-
Constructor Details
-
AbstractPilotageReport
public AbstractPilotageReport()
-
-
Method Details
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
setPluginInfo
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
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getId
Description copied from interface:PilotageReport
Retrieves the id of the report.- Specified by:
getId
in interfacePilotageReport
- Returns:
- the id.
-
getLabel
Description copied from interface:PilotageReport
Retrieves the label of the report.- Specified by:
getLabel
in interfacePilotageReport
- Returns:
- the label.
-
supports
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
Most of reports are generic. This method can be overridden.- Returns:
true
if the current report is generic,false
otherwise
-
isSupportedTarget
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
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
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
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
-
getType
Get the name of the report- Returns:
- The report name
-
getPluginName
Get the plugin name to build the pipeline.- Returns:
- The plugin name
-
getOutputFormat
Get the output format of the report.- Returns:
- The output format
-
getSupportedOutputFormats
Get the list of supported output formats- Returns:
- A
Set
of supported output formats
-
isSupportedFormat
Get the output format of the report.- Returns:
- The output format
-
getPipeline
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
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 IOExceptionCompress 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 IOExceptionAdd 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
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
The mail subject.- Returns:
- The subject of the mail
-
getMailBody
The mail body.- Parameters:
status
- the status of the pilotage report- Returns:
- The body of the mail
-
getReportName
The report name to add in the mail.- Returns:
- The report name
-
_buildZipName
Build the ZIP name.- Parameters:
contextName
- The report context name- Returns:
- The full ZIP name
-