Fissato il problema di sync quando un gruppo non ha un id esterno

This commit is contained in:
Giancarlo Panichi 2023-06-08 14:12:33 +02:00
parent 52619ae831
commit 3c9fc8fa6a
4 changed files with 43 additions and 17 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "epasmed", "name": "epasmed",
"version": "0.0.1-SNAPSHOT", "version": "1.0.6",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -6,7 +6,7 @@
<groupId>it.cnr.isti.epasmed</groupId> <groupId>it.cnr.isti.epasmed</groupId>
<artifactId>epasmed</artifactId> <artifactId>epasmed</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>epasmed</name> <name>epasmed</name>

View File

@ -197,7 +197,7 @@ public class SyncService {
borario = false; borario = false;
bpers_orario = false; bpers_orario = false;
blavoro_fuori_sede = false; blavoro_fuori_sede = false;
baspettative=false; baspettative = false;
} }
public void executeReads() throws Exception { public void executeReads() throws Exception {
@ -359,7 +359,7 @@ public class SyncService {
logger.info("EPAS Created Person: {}", epasPerson); logger.info("EPAS Created Person: {}", epasPerson);
} catch (Exception e) { } catch (Exception e) {
logger.error("Error creating person: {}", epasPersonsDTO); logger.error("Error creating person: {}", epasPersonsDTO);
logger.error(e.getLocalizedMessage(),e); logger.error(e.getLocalizedMessage(), e);
} }
} else { } else {
EPASPersonsDTO epasPersonsDTO = epasPersonsMapper.epasPersonsToEPASPersonsDTO(epasPerson); EPASPersonsDTO epasPersonsDTO = epasPersonsMapper.epasPersonsToEPASPersonsDTO(epasPerson);
@ -386,24 +386,24 @@ public class SyncService {
private String createCNREmail(SIAnagrafico sia) { private String createCNREmail(SIAnagrafico sia) {
StringBuilder cnrEmail = new StringBuilder(); StringBuilder cnrEmail = new StringBuilder();
if (sia.getNome() != null && !sia.getNome().isEmpty()) { if (sia.getNome() != null && !sia.getNome().isEmpty()) {
String nome=sia.getNome(); String nome = sia.getNome();
if(!Normalizer.isNormalized(sia.getNome(), Normalizer.Form.NFKD)){ if (!Normalizer.isNormalized(sia.getNome(), Normalizer.Form.NFKD)) {
nome=Normalizer.normalize(sia.getNome(), Normalizer.Form.NFKD).replaceAll("\\p{M}", ""); nome = Normalizer.normalize(sia.getNome(), Normalizer.Form.NFKD).replaceAll("\\p{M}", "");
} }
cnrEmail.append(nome.toLowerCase()); cnrEmail.append(nome.toLowerCase());
if (sia.getCognome() != null && !sia.getCognome().isEmpty()) { if (sia.getCognome() != null && !sia.getCognome().isEmpty()) {
String cognome=sia.getCognome(); String cognome = sia.getCognome();
if(!Normalizer.isNormalized(sia.getCognome(), Normalizer.Form.NFKD)){ if (!Normalizer.isNormalized(sia.getCognome(), Normalizer.Form.NFKD)) {
cognome=Normalizer.normalize(sia.getCognome(), Normalizer.Form.NFKD).replaceAll("\\p{M}", ""); cognome = Normalizer.normalize(sia.getCognome(), Normalizer.Form.NFKD).replaceAll("\\p{M}", "");
} }
cnrEmail.append("."); cnrEmail.append(".");
cnrEmail.append(cognome.toLowerCase().trim()); cnrEmail.append(cognome.toLowerCase().trim());
} }
} else { } else {
if (sia.getCognome() != null && !sia.getCognome().isEmpty()) { if (sia.getCognome() != null && !sia.getCognome().isEmpty()) {
String cognome=sia.getCognome(); String cognome = sia.getCognome();
if(!Normalizer.isNormalized(sia.getCognome(), Normalizer.Form.NFKD)){ if (!Normalizer.isNormalized(sia.getCognome(), Normalizer.Form.NFKD)) {
cognome=Normalizer.normalize(sia.getCognome(), Normalizer.Form.NFKD).replaceAll("\\p{M}", ""); cognome = Normalizer.normalize(sia.getCognome(), Normalizer.Form.NFKD).replaceAll("\\p{M}", "");
} }
cnrEmail.append(cognome.toLowerCase().trim()); cnrEmail.append(cognome.toLowerCase().trim());
} else { } else {
@ -558,11 +558,19 @@ public class SyncService {
if (epasGroups != null) { if (epasGroups != null) {
EPASGroups groupPresent = null; EPASGroups groupPresent = null;
for (EPASGroups g : epasGroups) { for (EPASGroups g : epasGroups) {
if (Integer.valueOf(g.getExternalId()).compareTo(sig.getId()) == 0) { if (g.getExternalId() != null && !g.getExternalId().isEmpty()) {
Integer gExternalId=null;
try {
gExternalId=Integer.valueOf(g.getExternalId());
} catch (NumberFormatException e) {
logger.error("EPAS Group has invalid External Id: {}", g);
}
if (gExternalId!=null&&gExternalId.compareTo(sig.getId()) == 0) {
groupPresent = g; groupPresent = g;
break; break;
} }
} }
}
if (groupPresent == null) { if (groupPresent == null) {
EPASGroupsDTO epasGroupsDTO = new EPASGroupsDTO(sig.getDescrizione(), null, EPASGroupsDTO epasGroupsDTO = new EPASGroupsDTO(sig.getDescrizione(), null,

View File

@ -1,5 +1,8 @@
package it.cnr.isti.epasmed.web.rest.sync; package it.cnr.isti.epasmed.web.rest.sync;
//import java.security.SecureRandom;
//import java.util.concurrent.TimeUnit;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -131,7 +134,7 @@ public class SyncResource {
public ResponseEntity<Void> syncTest(@RequestParam("year") String year, @RequestParam("month") String month) public ResponseEntity<Void> syncTest(@RequestParam("year") String year, @RequestParam("month") String month)
throws Exception { throws Exception {
logger.info("REST request syncTest"); logger.info("REST request syncTest");
//delayTest();
ResponseEntity<Void> res; ResponseEntity<Void> res;
logger.info("Selezionato {} - {} ", year, month); logger.info("Selezionato {} - {} ", year, month);
String msg = "Test eseguito correttamente."; String msg = "Test eseguito correttamente.";
@ -148,6 +151,21 @@ public class SyncResource {
return res; return res;
} }
/* private void delayTest() {
SecureRandom rand = new SecureRandom();
int upperbound = 1000;
// Generating random values from 0 - 999
// using nextInt()
int random1 = rand.nextInt(upperbound);
logger.debug("Test: "+random1);
try {
TimeUnit.SECONDS.sleep(5);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
*/
/** /**
* {@code GET /sync/writesOrario} : Report Orario from ePAS and update * {@code GET /sync/writesOrario} : Report Orario from ePAS and update
* SistemaInformativo. * SistemaInformativo.