Package backend.logic
Klasse ExportService
java.lang.Object
backend.logic.ExportService
The ExportService class provides functionality to export reimbursement data in the formats
JSON, XML, PDF, and CSV. It supports different types of reports for both administrators
and regular users, with options to customize the output based on report type and time range.
The service integrates with StatisticsService to generate statistical reports and charts, and can export data for individual users or aggregated data for accounting purposes.
Supported export formats include:
- JSON - For reimbursement data and accounting reports
- XML - For reimbursement data and accounting reports
- PDF - For visual reports with charts and tables
- CSV - For tabular data exports (admin only)
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic class
static class
static class
Data transfer object for exporting user reimbursement information. -
Feldübersicht
Felder -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungConstructs a new ExportService with default settings.ExportService
(StatisticsService statisticsService, User currentUser) Constructs a new ExportService with the specified statistics service and current user. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
exportAdminToCsv
(File file, String reportType, List<Reimbursement> adminData) Exports admin data to a CSV file based on the specified report type.void
exportAdminToPdf
(File file, javafx.scene.chart.Chart chart, String reportTitle, List<Reimbursement> adminData) Generates an admin PDF report with charts and data tables.void
exportToJson
(List<Reimbursement> data, File file) Exports a list of reimbursements to a JSON file.void
exportToJsonAccounting
(Map<User, Double> userPayrollData, File file) Exports accounting data (payroll information) to a JSON file.void
exportToXml
(List<Reimbursement> data, File file) Exports a list of reimbursements to an XML file.void
exportToXmlAccounting
(Map<User, Double> userPayrollData, File file) Exports accounting data (payroll information) to an XML file.void
exportUserToPdf
(File file, javafx.scene.chart.PieChart pieChart, javafx.scene.chart.BarChart<?, ?> barChart, List<Reimbursement> filteredData) Generates a user PDF report with pie and bar charts.void
setReportParameters
(String reportType, String timeRange) Sets the report parameters for the export operation.
-
Felddetails
-
connectionProvider
secures DatabaseConnection
-
-
Konstruktordetails
-
ExportService
public ExportService()Constructs a new ExportService with default settings. -
ExportService
Constructs a new ExportService with the specified statistics service and current user.- Parameter:
statisticsService
- the statistics service to use for report generationcurrentUser
- the user initiating the export operation
-
-
Methodendetails
-
setReportParameters
Sets the report parameters for the export operation.- Parameter:
reportType
- the type of report to generate (e.g., "Anzahl pro Monat", "Erstattungsbetrag")timeRange
- the time range for the report (e.g., "2024, "May 2025")
-
exportToJson
Exports a list of reimbursements to a JSON file.- Parameter:
data
- the list of reimbursements to exportfile
- the target file to write the JSON data to- Löst aus:
Exception
- if an error occurs during JSON serialization or file writing
-
exportToXml
Exports a list of reimbursements to an XML file.- Parameter:
data
- the list of reimbursements to exportfile
- the target file to write the XML data to- Löst aus:
Exception
- if an error occurs during XML marshalling or file writing
-
exportToJsonAccounting
Exports accounting data (payroll information) to a JSON file.- Parameter:
userPayrollData
- a map of users to their total approved amountsfile
- the target file to write the JSON data to- Löst aus:
Exception
- if an error occurs during JSON serialization or file writing
-
exportToXmlAccounting
Exports accounting data (payroll information) to an XML file.- Parameter:
userPayrollData
- a map of users to their total approved amountsfile
- the target file to write the XML data to- Löst aus:
Exception
- if an error occurs during XML marshalling or file writing
-
exportAdminToPdf
public void exportAdminToPdf(File file, javafx.scene.chart.Chart chart, String reportTitle, List<Reimbursement> adminData) throws IOException Generates an admin PDF report with charts and data tables.- Parameter:
file
- the target PDF filechart
- the chart to include in the reportreportTitle
- the title of the reportadminData
- the reimbursement data to include in the report- Löst aus:
IOException
- if an error occurs during PDF generation
-
exportUserToPdf
public void exportUserToPdf(File file, javafx.scene.chart.PieChart pieChart, javafx.scene.chart.BarChart<?, ?> barChart, List<Reimbursement> filteredData) throws IOExceptionGenerates a user PDF report with pie and bar charts.- Parameter:
file
- the target PDF filepieChart
- the pie chart to includebarChart
- the bar chart to includefilteredData
- the filtered reimbursement data for the current user- Löst aus:
IOException
- if an error occurs during PDF generation
-
exportAdminToCsv
public void exportAdminToCsv(File file, String reportType, List<Reimbursement> adminData) throws IOException Exports admin data to a CSV file based on the specified report type.- Parameter:
file
- the target CSV filereportType
- the type of report to generateadminData
- the reimbursement data to export- Löst aus:
IOException
- if an error occurs during CSV file writing
-