Updated sync PersOrario
This commit is contained in:
parent
37778f42e4
commit
8293e18d96
2
pom.xml
2
pom.xml
|
@ -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.0</version>
|
<version>1.0.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>epasmed</name>
|
<name>epasmed</name>
|
||||||
|
|
||||||
|
|
|
@ -225,10 +225,10 @@ public class PersOrario implements Serializable {
|
||||||
if (idPersona != null && idPersona.compareTo(l.getIdPersona()) == 0) {
|
if (idPersona != null && idPersona.compareTo(l.getIdPersona()) == 0) {
|
||||||
if (dal != null && dal.compareTo(l.getDal()) == 0) {
|
if (dal != null && dal.compareTo(l.getDal()) == 0) {
|
||||||
if (al == null && l.getAl() == null) {
|
if (al == null && l.getAl() == null) {
|
||||||
sameOthersFields(l);
|
return sameOthersFields(l);
|
||||||
} else {
|
} else {
|
||||||
if (al != null && al.compareTo(l.getAl()) == 0) {
|
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) {
|
private boolean sameOthersFields(PersOrario l) {
|
||||||
|
|
||||||
boolean someOthers = false;
|
boolean someOthers = false;
|
||||||
if (lun == l.getLun() && mar == l.getMar() && mer == l.getMer() && gio == l.getGio() && ven == l.getVen()
|
if (lun.compareTo(l.getLun()) == 0 && mar.compareTo(l.getMar()) == 0 && mer.compareTo(l.getMer()) == 0
|
||||||
&& sab == l.getSab() && percentuale == l.getPercentuale()) {
|
&& 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 (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 (festivo != null && festivo.compareTo(l.getFestivo()) == 0) {
|
||||||
if (notturno != null && notturno.compareTo(l.getNotturno()) == 0) {
|
if (notturno != null && notturno.compareTo(l.getNotturno()) == 0) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -267,7 +269,7 @@ public class PersOrario implements Serializable {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (turno == null && l.getTurno() == null) {
|
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 (festivo != null && festivo.compareTo(l.getFestivo()) == 0) {
|
||||||
if (notturno != null && notturno.compareTo(l.getNotturno()) == 0) {
|
if (notturno != null && notturno.compareTo(l.getNotturno()) == 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1570,12 +1570,15 @@ public class SyncService {
|
||||||
Optional<PersOrario> persOrario = persOrarioService.getPersOrarioById(siPersOrario.getId());
|
Optional<PersOrario> persOrario = persOrarioService.getPersOrarioById(siPersOrario.getId());
|
||||||
if (persOrario.isPresent()) {
|
if (persOrario.isPresent()) {
|
||||||
PersOrario found = persOrario.get();
|
PersOrario found = persOrario.get();
|
||||||
|
logger.debug("Found: {}",found);
|
||||||
PersOrario persOrarioDTO = persOrarioMapper.siPersOrarioToPersOrario(siPersOrario);
|
PersOrario persOrarioDTO = persOrarioMapper.siPersOrarioToPersOrario(siPersOrario);
|
||||||
|
logger.debug("PersOrarioDTO: {}",persOrarioDTO);
|
||||||
if (!found.same(persOrarioDTO)) {
|
if (!found.same(persOrarioDTO)) {
|
||||||
upgradeable = true;
|
upgradeable = true;
|
||||||
persOrarioService.updatePersOrario(persOrarioDTO);
|
persOrarioService.updatePersOrario(persOrarioDTO);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
logger.debug("Not found PersOrario by id: {}",siPersOrario.getId());
|
||||||
upgradeable = true;
|
upgradeable = true;
|
||||||
PersOrario persOrarioDTO = persOrarioMapper.siPersOrarioToPersOrario(siPersOrario);
|
PersOrario persOrarioDTO = persOrarioMapper.siPersOrarioToPersOrario(siPersOrario);
|
||||||
persOrarioService.createPersOrario(persOrarioDTO);
|
persOrarioService.createPersOrario(persOrarioDTO);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.DateTimeFormatterBuilder;
|
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 org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
import it.cnr.isti.epasmed.EpasmedApp;
|
import it.cnr.isti.epasmed.EpasmedApp;
|
||||||
|
import it.cnr.isti.epasmed.domain.PersOrario;
|
||||||
import it.cnr.isti.epasmed.security.AuthoritiesConstants;
|
import it.cnr.isti.epasmed.security.AuthoritiesConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,4 +145,56 @@ 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue