From 6494941037ae2670876de9940853d50538eb5129 Mon Sep 17 00:00:00 2001
From: Kenmegne <stephanie.kenmegne@gmail.com>
Date: Fri, 19 Jun 2026 11:25:51 +0000
Subject: [PATCH] move to new repo

---
 reporting-adhoc/src/main/java/com/megatim/reporting/adhoc/App.java |   96 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 96 insertions(+), 0 deletions(-)

diff --git a/reporting-adhoc/src/main/java/com/megatim/reporting/adhoc/App.java b/reporting-adhoc/src/main/java/com/megatim/reporting/adhoc/App.java
new file mode 100644
index 0000000..2ec570b
--- /dev/null
+++ b/reporting-adhoc/src/main/java/com/megatim/reporting/adhoc/App.java
@@ -0,0 +1,96 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
+ */
+package com.megatim.reporting.adhoc;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.Map;
+import net.sf.jasperreports.engine.JasperExportManager;
+import net.sf.jasperreports.engine.JasperFillManager;
+import net.sf.jasperreports.engine.JasperPrint;
+import net.sf.jasperreports.engine.JasperReport;
+import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
+import net.sf.jasperreports.engine.util.JRLoader;
+
+/**
+ *
+ * @author ASUS
+ */
+public class App {
+
+    public final static File templateListe = new File("C:\\Users\\ASUS\\Documents\\templateEtats.xml");
+    public final static File templateDetail = new File("C:\\Users\\ASUS\\Documents\\templateEtatsDetail.xml");
+
+    public static void main(String[] args) {
+        String str = "\t\tmoi     hghruhrih         \niroriotor\naem\t\tp\t\t";
+
+        String result = str.trim()
+                .replaceAll("(?U)\\s+", " ");
+//                .replaceAll("(?U)\\G\\s", "");
+        System.out.println("----------------- before ----------------------------");
+        System.out.println(str);
+        System.out.println("--------------------after-------------------------");
+        System.out.println("begin" + result + "end");
+
+//        String jrxmlPath = "C:\\Users\\ASUS\\Documents\\etats\\etats_horizon";
+//        String pdfPath = "C:\\Users\\ASUS\\Documents\\etats\\etats_horizon\\pdfs";
+//        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+//
+//        try {
+//            String jasperFile = new Processor().process(new CategorieDetailConstruct().construct(jrxmlPath));
+////            String jasperFile = new Processor().process(templateDetail, new ComiteDetailConstruct().construct(jrxmlPath));
+//
+//            List<ComiteRapport> liste = ComiteDataSource.createBeanCollection();
+//
+//            HashMap<String, Object> map = new HashMap<>();
+//            map.put("MONTANT_TOTAL", new BigDecimal("642555.36915"));
+//            map.put("TITRE", "LISTE DES ENTREPRISES");
+//            map.put("LOGIN_UTILISATEUR", "Mela");
+//            map.put("VERSION", "HORIZON");
+//            map.put("LOGO_CENTRE", jrxmlPath + "\\images\\logo.jpg");
+//            map.put("NOMBRE_TOTAL", liste.size() + "");
+//            map.put("SUBREPORT_DIR", jrxmlPath + File.separator);
+//
+//            genererFichierPdf(liste, Paths.get(pdfPath, "ComiteDetail" + dtf.format(LocalDateTime.now()) + ".pdf").toString(),
+//                    jasperFile, map);
+//        } catch (Exception ex) {
+//            Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
+//        }
+    }
+
+    public static File genererFichierPdf(List<?> datas, String pdfFile, String reportFilePath, Map params) throws Exception {
+
+        // Creation d'un File sur le fichier
+        File reportFile = new File(reportFilePath);
+        File fichierGenerer = new File(pdfFile);
+
+        //On cree le fichier s'ile n'existe pas
+        if (!fichierGenerer.exists()) {
+
+            //On cree le fichier
+            fichierGenerer.createNewFile();
+
+        }
+
+        // Chargement du Rapport
+        JasperReport report = null;
+
+        // Etat rempli
+        JasperPrint jasperPrint = null;
+
+        // Chargement du report
+        report = (JasperReport) JRLoader.loadObject(reportFile);
+        jasperPrint = JasperFillManager.fillReport(report, params, new JRBeanCollectionDataSource(datas, false));
+
+        OutputStream output = new FileOutputStream(fichierGenerer);
+        JasperExportManager.exportReportToPdfStream(jasperPrint, output);
+        output.close();
+
+        return fichierGenerer;
+    }
+
+}

--
Gitblit v1.10.0