Package backend.logic

Klasse ExportService

java.lang.Object
backend.logic.ExportService

public class ExportService extends Object
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)

  • Felddetails

    • connectionProvider

      public static ConnectionProvider connectionProvider
      secures DatabaseConnection
  • Konstruktordetails

    • ExportService

      public ExportService()
      Constructs a new ExportService with default settings.
    • ExportService

      public ExportService(StatisticsService statisticsService, User currentUser)
      Constructs a new ExportService with the specified statistics service and current user.
      Parameter:
      statisticsService - the statistics service to use for report generation
      currentUser - the user initiating the export operation
  • Methodendetails

    • setReportParameters

      public void setReportParameters(String reportType, String timeRange)
      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

      public void exportToJson(List<Reimbursement> data, File file) throws Exception
      Exports a list of reimbursements to a JSON file.
      Parameter:
      data - the list of reimbursements to export
      file - the target file to write the JSON data to
      Löst aus:
      Exception - if an error occurs during JSON serialization or file writing
    • exportToXml

      public void exportToXml(List<Reimbursement> data, File file) throws Exception
      Exports a list of reimbursements to an XML file.
      Parameter:
      data - the list of reimbursements to export
      file - the target file to write the XML data to
      Löst aus:
      Exception - if an error occurs during XML marshalling or file writing
    • exportToJsonAccounting

      public void exportToJsonAccounting(Map<User,Double> userPayrollData, File file) throws Exception
      Exports accounting data (payroll information) to a JSON file.
      Parameter:
      userPayrollData - a map of users to their total approved amounts
      file - the target file to write the JSON data to
      Löst aus:
      Exception - if an error occurs during JSON serialization or file writing
    • exportToXmlAccounting

      public void exportToXmlAccounting(Map<User,Double> userPayrollData, File file) throws Exception
      Exports accounting data (payroll information) to an XML file.
      Parameter:
      userPayrollData - a map of users to their total approved amounts
      file - 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 file
      chart - the chart to include in the report
      reportTitle - the title of the report
      adminData - 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 IOException
      Generates a user PDF report with pie and bar charts.
      Parameter:
      file - the target PDF file
      pieChart - the pie chart to include
      barChart - the bar chart to include
      filteredData - 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 file
      reportType - the type of report to generate
      adminData - the reimbursement data to export
      Löst aus:
      IOException - if an error occurs during CSV file writing