From b3d0580439b9a00c7eb918085de1694151066004 Mon Sep 17 00:00:00 2001
From: Kenmegne <stephanie.kenmegne@gmail.com>
Date: Thu, 18 Jun 2026 16:02:49 +0000
Subject: [PATCH] rename packages

---
 fdx_convert/src/main/java/com/megatim/fdxconvert/service/ImportFileService.java |   88 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 88 insertions(+), 0 deletions(-)

diff --git a/fdx_convert/src/main/java/com/megatim/fdxconvert/service/ImportFileService.java b/fdx_convert/src/main/java/com/megatim/fdxconvert/service/ImportFileService.java
new file mode 100644
index 0000000..6b2fa3b
--- /dev/null
+++ b/fdx_convert/src/main/java/com/megatim/fdxconvert/service/ImportFileService.java
@@ -0,0 +1,88 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.megatim.fdxconvert.service;
+
+import com.megatimfx.common.service.GenericCrudService;
+import com.megatim.fdxconvert.dao.AbstractDAO;
+import com.megatim.fdxconvert.dao.TypeFichierDAO;
+import com.megatim.fdxconvert.pojo.ImportFile;
+import com.megatim.fdxconvert.model.TypeFichier;
+import com.megatim.fdxconvert.pojo.DataToImport;
+import com.megatim.fdxconvert.util.ImportData;
+import com.megatim.fdxconvert.service.pojo.PaginationElts;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * structLigne : id, code,format_date, position, taille, type_donnee,
+ * validateur_fichier_id ValidateurFichier : id, nombre_position,
+ * type_fichier_code
+ *
+ * @author STEPHANIE
+ */
+public class ImportFileService implements GenericCrudService<ImportFile> {
+
+    private static ImportFileService importFileService;
+    private PaginationElts<TypeFichier> pagination;
+
+    private ImportFileService() {
+        
+    }
+    
+    public static synchronized ImportFileService getInstance() {
+        if (importFileService == null) {
+            importFileService = new ImportFileService();
+        }
+        return importFileService;
+    }
+
+    @Override
+    public ImportFile add(ImportFile t) throws Exception {
+        importDataFromFile(t);
+        return t;
+    }
+
+    @Override
+    public ImportFile edit(ImportFile t) throws Exception {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public List<ImportFile> getAll() throws Exception {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void delete(ImportFile t) throws Exception {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    private void importDataFromFile(ImportFile im) throws Exception{
+        List<String> fields = new ArrayList<>();
+
+        if (im != null && im.getType() != null) {
+            if (im.getType().equals(TypeFichier.class)) {
+                fields.add("code");
+                fields.add("libelle");
+                fields.add("codeParticipant");
+            }
+        }
+        DataToImport datIm = new DataToImport(new File(im.getFilePath()), im.getDelimiteurLigne().getCode(), im.getDelimiteurColonne().getCode(), im.getType(), fields);
+        List<Object> datas = ImportData.importDataFromCsvFile(datIm);
+        if (im.getType().equals(TypeFichier.class)) {
+            AbstractDAO<TypeFichier> dao = new AbstractDAO<>(TypeFichier.class);
+            
+            datas.forEach(d -> {
+                TypeFichier t = (TypeFichier) d;
+                Optional<TypeFichier> opt = TypeFichierDAO.findByCode(t);
+                if(!opt.isPresent())
+                     dao.add(t);
+            });
+        }
+    }
+}
+//{}

--
Gitblit v1.10.0