From 7b81ef8be381b9b0b6526881e38a76c0f6a3d453 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Mon, 10 Oct 2022 17:09:52 +0200 Subject: [PATCH] Aggiunto un flag per l'export delle descrizioni dei codici assenza --- .../it/cnr/isti/epasmed/sync/SyncService.java | 29 ++++++++++++------- .../epasmed/web/rest/sync/SyncResourceIT.java | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/it/cnr/isti/epasmed/sync/SyncService.java b/src/main/java/it/cnr/isti/epasmed/sync/SyncService.java index 2e0c7cf..7f1f8d8 100755 --- a/src/main/java/it/cnr/isti/epasmed/sync/SyncService.java +++ b/src/main/java/it/cnr/isti/epasmed/sync/SyncService.java @@ -84,6 +84,8 @@ public class SyncService { private static final String SI_TIPO_EMAIL_CNR = "C.N.R."; private static final String PERSON_DEFAULT_QUALIFICATION = "3"; + private static final boolean EXPORT_ABSENCE_CODE_DESCRIPTION = false; + private static final Logger logger = LoggerFactory.getLogger(SyncService.class); private final SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd"); @@ -1196,8 +1198,10 @@ public class SyncService { EPASTimeCards epasTimeCards = epasTimeCardsService.getTimeCardByPersonFiscalCode(person.getFiscalCode(), year, month); - LinkedHashMap epasAbsenceTypeMap = epasAbsenceTypeService.getAbsenceTypesMap(); - + LinkedHashMap epasAbsenceTypeMap = null; + if (EXPORT_ABSENCE_CODE_DESCRIPTION) { + epasAbsenceTypeMap = epasAbsenceTypeService.getAbsenceTypesMap(); + } EPASPersons epasPerson = epasTimeCards.getPerson(); Integer personId = Integer.valueOf(epasPerson.getId()); @@ -1271,7 +1275,11 @@ public class SyncService { EPASTimeCards epasTimeCards = epasTimeCardsService.getTimeCardByPersonFiscalCode(person.getFiscalCode(), year, month); - LinkedHashMap epasAbsenceTypeMap = epasAbsenceTypeService.getAbsenceTypesMap(); + LinkedHashMap epasAbsenceTypeMap = null; + if (EXPORT_ABSENCE_CODE_DESCRIPTION) { + epasAbsenceTypeMap = epasAbsenceTypeService.getAbsenceTypesMap(); + } + EPASPersons epasPerson = epasTimeCards.getPerson(); Integer personId = Integer.valueOf(epasPerson.getId()); @@ -1373,8 +1381,7 @@ public class SyncService { } - private void extractMotivoInfo(EPASPersonDays epasPersonDay, - LinkedHashMap epasAbsenceTypeMap, + private void extractMotivoInfo(EPASPersonDays epasPersonDay, LinkedHashMap epasAbsenceTypeMap, StringBuilder motivo) { if (epasPersonDay.getIsHoliday()) { motivo.append("[Festivo]"); @@ -1412,11 +1419,13 @@ public class SyncService { // motivo.append(epasAbsences.getJustifiedType()); // motivo.append("-"); motivo.append(epasAbsences.getCode()); - - String description=epasAbsenceTypeMap.get(epasAbsences.getCode()); - if(description!=null && !description.isEmpty()) { - motivo.append("-"); - motivo.append(description); + + if (epasAbsenceTypeMap != null && !epasAbsenceTypeMap.isEmpty()) { + String description = epasAbsenceTypeMap.get(epasAbsences.getCode()); + if (description != null && !description.isEmpty()) { + motivo.append("-"); + motivo.append(description); + } } if (epasAbsences.getNote() != null && !epasAbsences.getNote().isEmpty()) { motivo.append("-"); diff --git a/src/test/java/it/cnr/isti/epasmed/web/rest/sync/SyncResourceIT.java b/src/test/java/it/cnr/isti/epasmed/web/rest/sync/SyncResourceIT.java index 1436557..eec31ea 100755 --- a/src/test/java/it/cnr/isti/epasmed/web/rest/sync/SyncResourceIT.java +++ b/src/test/java/it/cnr/isti/epasmed/web/rest/sync/SyncResourceIT.java @@ -29,7 +29,7 @@ public class SyncResourceIT { private final Logger log = LoggerFactory.getLogger(getClass()); private static final String YEAR = "2022"; - private static final String MONTH = "7"; + private static final String MONTH = "9"; private static final String PERSON_DEFAULT_FISCAL_CODE = "CSTDTL57L65A864M"; @Autowired