From 23a46b4be35277e06ec89f48730eeb694e686be8 Mon Sep 17 00:00:00 2001
From: Kenmegne <stephanie.kenmegne@gmail.com>
Date: Thu, 18 Jun 2026 15:40:06 +0000
Subject: [PATCH] add fdx-commons and fdx-consultation
---
fdx-consultation/fdxconsultation-dao-impl/src/main/java/com/megatim/fdxconsultation/daoimpl/documents/DocumentDAOImpl.java | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/fdx-consultation/fdxconsultation-dao-impl/src/main/java/com/megatim/fdxconsultation/daoimpl/documents/DocumentDAOImpl.java b/fdx-consultation/fdxconsultation-dao-impl/src/main/java/com/megatim/fdxconsultation/daoimpl/documents/DocumentDAOImpl.java
new file mode 100644
index 0000000..1442872
--- /dev/null
+++ b/fdx-consultation/fdxconsultation-dao-impl/src/main/java/com/megatim/fdxconsultation/daoimpl/documents/DocumentDAOImpl.java
@@ -0,0 +1,48 @@
+package com.megatim.fdxconsultation.daoimpl.documents;
+
+import com.bekosoftware.genericdaolayer.dao.impl.AbstractGenericDAO;
+import com.megatim.fdxcommons.model.enumeration.TypeOperation;
+import com.megatim.fdxconsultation.dao.ifaces.documents.DocumentDAO;
+import com.megatim.fdxconsultation.model.documents.Document;
+import java.util.List;
+import javax.enterprise.context.Dependent;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+
+/**
+ *
+ * @author Gabuntu
+ */
+@Dependent
+public class DocumentDAOImpl extends AbstractGenericDAO<Document, Long> implements DocumentDAO {
+
+ @PersistenceContext(unitName = "fdxConsultationPersistenceUnit")
+ protected EntityManager em;
+
+ @Override
+ public EntityManager getEntityManager() {
+ return em;
+ }
+
+ @Override
+ public Class<Document> getManagedEntityClass() {
+ return Document.class;
+ }
+
+ @Override
+ public Document getById(Long id) {
+ Query query = getEntityManager().createQuery("SELECT d FROM Document d WHERE d.id = :id AND d.typeOperation = :typeOperation");
+ query.setParameter("id", id).setParameter("typeOperation", TypeOperation.AJOUTER);
+ List<Document> liste = query.getResultList();
+ return liste != null ? liste.stream().findFirst().get() : null;
+ }
+
+ @Override
+ public List<Document> getByCategory(Long categoryId) {
+ Query query = getEntityManager().createQuery("SELECT d FROM Document d WHERE d.category.id = :id AND d.typeOperation = :typeOperation");
+ query.setParameter("id", categoryId).setParameter("typeOperation", TypeOperation.AJOUTER);
+ return query.getResultList();
+ }
+
+}
--
Gitblit v1.10.0