ReportTimerController Integration Guide
📋 Overview
The ReportTimerController utility class has been introduced to track and monitor the time taken for report generation in the system. This allows automatic logging of report execution metrics for audit, performance optimization, and debugging purposes.
What Gets Logged
- ⏰ Start time - When report generation begins
- ⏰ End time - When report generation completes
- 👤 Executing user - Who initiated the report
- 📊 Report type and name - What report was generated
All captured data is saved in the ReportLog entity for future analysis.
📁 File Location
com.divudi.bean.common.ReportTimerController
🎯 Purpose
The ReportTimerController encapsulates the logic required to:
- Log the start time of a report
- Execute the report generation logic
- Log the end time and calculate report duration
- Save execution metrics to the database
🔧 Integration Steps
Follow this step-by-step guide to integrate report time tracking into your existing report methods:
Step 1: Locate Your Report Files
Find the XHTML file where your report exists (e.g., /pharmacy/bin_card.xhtml)
Step 2: Find the Processing Method
Navigate to the processing button and identify the method in the action attribute:
action="#{pharmacyErrorChecking.processBinCard()}"
Step 3: Wrap Your Report Logic
Wrap your existing report processing logic inside the trackReportExecution method:
reportTimerController.trackReportExecution(() -> {
// Your existing report processing code goes here
}, YourReportEnum.REPORT_NAME, sessionController.getLoggedUser());
📝 Example Implementation
Before Integration
public void processBinCard() {
binCardEntries = stockHistoryController.findBinCardDTOs(fromDate, toDate, null, department, item);
if (configOptionApplicationController.getBooleanValueByKey("Pharmacy Bin Card - Hide Adjustment Bills in Bin Card", true)) {
List<BillType> bts = new ArrayList<>();
bts.add(BillType.PharmacyAdjustmentSaleRate);
Iterator<PharmacyBinCardDTO> iterator = binCardEntries.iterator();
while (iterator.hasNext()) {
PharmacyBinCardDTO dto = iterator.next();
if (dto.getBillType() != null && bts.contains(dto.getBillType())) {
iterator.remove();
}
}
}
}
After Integration
public void processBinCard() {
reportTimerController.trackReportExecution(() -> {
binCardEntries = stockHistoryController.findBinCardDTOs(fromDate, toDate, null, department, item);
if (configOptionApplicationController.getBooleanValueByKey("Pharmacy Bin Card - Hide Adjustment Bills in Bin Card", true)) {
List<BillType> bts = new ArrayList<>();
bts.add(BillType.PharmacyAdjustmentSaleRate);
Iterator<PharmacyBinCardDTO> iterator = binCardEntries.iterator();
while (iterator.hasNext()) {
PharmacyBinCardDTO dto = iterator.next();
if (dto.getBillType() != null && bts.contains(dto.getBillType())) {
iterator.remove();
}
}
}
}, PharmacyReports.PHARMACY_BIN_CARD, sessionController.getLoggedUser());
}
🏷️ Report Enum Configuration
Creating Report Type Enums
To enable proper identification of report types, ensure your report type is declared in the appropriate module enum. Use the module-specific enum file based on your report's domain.
Example: PharmacyReports.java
package com.divudi.core.data.reports;
public enum PharmacyReports implements IReportType {
PHARMACY_BIN_CARD("Pharmacy Bin Card"),
PHARMACY_STOCK_SUMMARY("Pharmacy Stock Summary"),
PHARMACY_SALES_REPORT("Pharmacy Sales Report");
private final String displayName;
PharmacyReports(String displayName) {
this.displayName = displayName;
}
@Override
public String getDisplayName() {
return displayName;
}
@Override
public String getReportType() {
return this.getClass().getSimpleName();
}
@Override
public String getReportName() {
return this.name();
}
}