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",
"version": "0.0.1-SNAPSHOT",
"version": "1.0.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

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

View File

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

View File

@ -1,5 +1,8 @@
package it.cnr.isti.epasmed.web.rest.sync;
//import java.security.SecureRandom;
//import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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)
throws Exception {
logger.info("REST request syncTest");
//delayTest();
ResponseEntity<Void> res;
logger.info("Selezionato {} - {} ", year, month);
String msg = "Test eseguito correttamente.";
@ -148,6 +151,21 @@ public class SyncResource {
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
* SistemaInformativo.