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-core-impl/src/main/java/com/megatim/fdxconsultation/core/impl/supervision/StandaloneServerStateEntityManagerImpl.java | 71 +++++++++++++++++++++++++++++++++++
1 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/fdx-consultation/fdxconsultation-core-impl/src/main/java/com/megatim/fdxconsultation/core/impl/supervision/StandaloneServerStateEntityManagerImpl.java b/fdx-consultation/fdxconsultation-core-impl/src/main/java/com/megatim/fdxconsultation/core/impl/supervision/StandaloneServerStateEntityManagerImpl.java
new file mode 100644
index 0000000..60d0c62
--- /dev/null
+++ b/fdx-consultation/fdxconsultation-core-impl/src/main/java/com/megatim/fdxconsultation/core/impl/supervision/StandaloneServerStateEntityManagerImpl.java
@@ -0,0 +1,71 @@
+package com.megatim.fdxconsultation.core.impl.supervision;
+
+import com.fdx.messaging.common.StandaloneServerState;
+import com.megatim.fdxconsultation.core.ifaces.supervision.AgentConfigurationEntityManager;
+import com.megatim.fdxconsultation.core.ifaces.supervision.StandaloneServerStateEntityManager;
+import com.megatim.fdxconsultation.dao.ifaces.supervision.StandaloneServerStateEntityDAO;
+import com.megatim.fdxconsultation.model.mappers.MapStructMapper;
+import com.megatim.fdxconsultation.model.supervision.StandaloneServerStateEntity;
+import com.megatim.fdxconsultation.model.supervision.StatutConfiguration;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+/**
+ *
+ * @author ASUS
+ */
+@ApplicationScoped
+public class StandaloneServerStateEntityManagerImpl implements StandaloneServerStateEntityManager {
+
+ @Inject
+ private StandaloneServerStateEntityDAO dao;
+
+ @Inject
+ private MapStructMapper mapper;
+
+ @Inject
+ private AgentConfigurationEntityManager agentConfigurationManager;
+
+ private StandaloneServerStateEntity standaloneServerStateEntity;
+
+ @PostConstruct
+ public void init() {
+ standaloneServerStateEntity = dao.getCurrentStandaloneServerStateEntity();
+ }
+
+ @Override
+ public StandaloneServerStateEntityDAO getDao() {
+ return dao;
+ }
+
+ @Override
+ public StandaloneServerStateEntity persistStandaloneConfigurationStateEntity(StandaloneServerState standaloneServerState) {
+
+ StandaloneServerStateEntity serverStateEntity = mapper.standaloneServerStateToStandaloneServerStateEntity(standaloneServerState);
+
+ if (serverStateEntity != null) {
+
+ dao.archiveServerState();
+
+ if (serverStateEntity.getAgentConfigurations() != null && !serverStateEntity.getAgentConfigurations().isEmpty()) {
+ serverStateEntity.getAgentConfigurations().stream().forEach(a -> {
+ agentConfigurationManager.archiveAgentConfiguration(a.getAgentCode());
+ a.setStandaloneServerState(serverStateEntity);
+ a.setStatutConfiguration(StatutConfiguration.EN_COURS);
+ });
+ }
+
+ serverStateEntity.setStatutConfiguration(StatutConfiguration.EN_COURS);
+ standaloneServerStateEntity = save(serverStateEntity);
+ return standaloneServerStateEntity;
+ }
+
+ return null;
+ }
+
+ @Override
+ public StandaloneServerStateEntity getCurrentStandaloneServerStateEntity() {
+ return standaloneServerStateEntity;
+ }
+}
--
Gitblit v1.10.0