Updated sync PersOrario

This commit is contained in:
Giancarlo Panichi 2022-10-25 12:11:07 +02:00
parent 37778f42e4
commit 8293e18d96
4 changed files with 69 additions and 10 deletions

View File

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

View File

@ -18,7 +18,7 @@ import javax.validation.constraints.NotNull;
public class PersOrario implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Integer id;
@ -225,10 +225,10 @@ public class PersOrario implements Serializable {
if (idPersona != null && idPersona.compareTo(l.getIdPersona()) == 0) {
if (dal != null && dal.compareTo(l.getDal()) == 0) {
if (al == null && l.getAl() == null) {
sameOthersFields(l);
return sameOthersFields(l);
} else {
if (al != null && al.compareTo(l.getAl()) == 0) {
sameOthersFields(l);
return sameOthersFields(l);
}
}
}
@ -240,11 +240,13 @@ public class PersOrario implements Serializable {
}
private boolean sameOthersFields(PersOrario l) {
boolean someOthers = false;
if (lun == l.getLun() && mar == l.getMar() && mer == l.getMer() && gio == l.getGio() && ven == l.getVen()
&& sab == l.getSab() && percentuale == l.getPercentuale()) {
if (lun.compareTo(l.getLun()) == 0 && mar.compareTo(l.getMar()) == 0 && mer.compareTo(l.getMer()) == 0
&& gio.compareTo(l.getGio()) == 0 && ven.compareTo(l.getVen()) == 0 && sab.compareTo(l.getSab()) == 0
&& percentuale.compareTo(l.getPercentuale()) == 0) {
if (turno != null && turno.compareTo(l.getTurno()) == 0) {
if (oreTurno == l.getOreTurno()) {
if (oreTurno.compareTo(l.getOreTurno())==0) {
if (festivo != null && festivo.compareTo(l.getFestivo()) == 0) {
if (notturno != null && notturno.compareTo(l.getNotturno()) == 0) {
return true;
@ -267,7 +269,7 @@ public class PersOrario implements Serializable {
}
} else {
if (turno == null && l.getTurno() == null) {
if (oreTurno == l.getOreTurno()) {
if (oreTurno.compareTo(l.getOreTurno())==0) {
if (festivo != null && festivo.compareTo(l.getFestivo()) == 0) {
if (notturno != null && notturno.compareTo(l.getNotturno()) == 0) {
return true;
@ -281,11 +283,11 @@ public class PersOrario implements Serializable {
if (notturno != null && notturno.compareTo(l.getNotturno()) == 0) {
return true;
} else {
if (notturno == null && l.getNotturno() == null) {
if (notturno == null && l.getNotturno() == null) {
return true;
}
}
}
}
}
}
}

View File

@ -1570,12 +1570,15 @@ public class SyncService {
Optional<PersOrario> persOrario = persOrarioService.getPersOrarioById(siPersOrario.getId());
if (persOrario.isPresent()) {
PersOrario found = persOrario.get();
logger.debug("Found: {}",found);
PersOrario persOrarioDTO = persOrarioMapper.siPersOrarioToPersOrario(siPersOrario);
logger.debug("PersOrarioDTO: {}",persOrarioDTO);
if (!found.same(persOrarioDTO)) {
upgradeable = true;
persOrarioService.updatePersOrario(persOrarioDTO);
}
} else {
logger.debug("Not found PersOrario by id: {}",siPersOrario.getId());
upgradeable = true;
PersOrario persOrarioDTO = persOrarioMapper.siPersOrarioToPersOrario(siPersOrario);
persOrarioService.createPersOrario(persOrarioDTO);

View File

@ -4,6 +4,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
@ -23,6 +24,7 @@ import org.springframework.test.context.junit.jupiter.EnabledIf;
import org.springframework.test.web.servlet.MockMvc;
import it.cnr.isti.epasmed.EpasmedApp;
import it.cnr.isti.epasmed.domain.PersOrario;
import it.cnr.isti.epasmed.security.AuthoritiesConstants;
/**
@ -142,5 +144,57 @@ public class SyncResourceIT {
}
@Test
public void testSamePersOrario() throws Exception {
PersOrario persOrario=new PersOrario();
persOrario.setId(72);
persOrario.setIdPersona(72);
persOrario.setCf("VDCLCU87A64D086T");
persOrario.setDal(LocalDate.of(2019,07,1));
persOrario.setAl(null);
persOrario.setDescrizione("Normale");
persOrario.setLun(432);
persOrario.setMar(432);
persOrario.setMer(432);
persOrario.setGio(432);
persOrario.setVen(432);
persOrario.setSab(0);
persOrario.setPercentuale(100);
persOrario.setTurno("NO");
persOrario.setOreTurno(0);
persOrario.setFestivo("SI");
persOrario.setNotturno("NO");
persOrario.setDataMod(LocalDateTime.parse("2022-10-25T03:00:01"));
logger.info("PersOrario: {}", persOrario);
PersOrario persOrarioDTO=new PersOrario();
persOrarioDTO.setId(72);
persOrarioDTO.setIdPersona(72);
persOrarioDTO.setCf("VDCLCU87A64D086T");
persOrarioDTO.setDal(LocalDate.of(2019,07,1));
persOrarioDTO.setAl(null);
persOrarioDTO.setDescrizione("Normale");
persOrarioDTO.setLun(432);
persOrarioDTO.setMar(432);
persOrarioDTO.setMer(432);
persOrarioDTO.setGio(432);
persOrarioDTO.setVen(432);
persOrarioDTO.setSab(0);
persOrarioDTO.setPercentuale(100);
persOrarioDTO.setTurno("NO");
persOrarioDTO.setOreTurno(0);
persOrarioDTO.setFestivo("SI");
persOrarioDTO.setNotturno("NO");
persOrarioDTO.setDataMod(LocalDateTime.parse("2022-10-25T11:23:30"));
logger.info("PersOrarioDTO: {}", persOrarioDTO);
logger.info("Is same: {}",persOrario.same(persOrarioDTO));
}
}