Updated Certifications support

This commit is contained in:
Giancarlo Panichi 2021-12-03 19:07:42 +01:00
parent 97b7a3a4ae
commit 7313c1f8fc
29 changed files with 657 additions and 70 deletions

View File

@ -47,7 +47,7 @@ public class EPASAffiliationsCient {
HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASAffiliations>>() {
}, groupId,includeInactive);
List<EPASAffiliations> listEPASAffiliations = responseEntity.getBody();
log.info("Retrieved Affiliations byGroup: {}", listEPASAffiliations);
log.info("Retrieved Affiliations by group id: {}", listEPASAffiliations);
return listEPASAffiliations;
}
@ -58,7 +58,7 @@ public class EPASAffiliationsCient {
HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASAffiliations>>() {
}, personId);
List<EPASAffiliations> listEPASAffiliations = responseEntity.getBody();
log.info("Retrieved Affiliations by Person id: {}", listEPASAffiliations);
log.info("Retrieved Affiliations by person id: {}", listEPASAffiliations);
return listEPASAffiliations;
}
@ -69,7 +69,7 @@ public class EPASAffiliationsCient {
HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASAffiliations>>() {
}, fc);
List<EPASAffiliations> listEPASAffiliations = responseEntity.getBody();
log.info("Retrieved Affiliations by Person fiscalcode: {}", listEPASAffiliations);
log.info("Retrieved Affiliations by person fiscalcode: {}", listEPASAffiliations);
return listEPASAffiliations;
}

View File

@ -29,36 +29,52 @@ public class EPASCertificationsClient {
@Autowired
ApplicationProperties appProps;
public EPASCertifications getCertificationsByPersonId(String id, String year, String month) {
log.info("Retrieving EPASCertifications for person id: {}", id);
public EPASCertifications getByPersonId(String id, String year, String month) {
log.info("Retrieving EPASCertifications by person id: {}", id);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("id", id);
uriVariables.put("year", year);
uriVariables.put("month", month);
EPASCertifications epasCertifications = rt.getForObject(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/certifications/getMonthValidationStatusByPerson?id={id}&year={year}&month={month}",
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/certifications/getMonthSituation?id={id}&year={year}&month={month}",
EPASCertifications.class,uriVariables);
log.info("Retrieved EPASCertifications: {}", epasCertifications);
return epasCertifications;
}
public EPASCertifications getCertificationsByPersonFiscalCode(String fc, String year, String month) {
log.info("Retrieving EPASCertifications for person fiscalCode: {}", fc);
public EPASCertifications getByPersonFiscalCode(String fc, String year, String month) {
log.info("Retrieving EPASCertifications by person fiscalcode: {}", fc);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("fc", fc);
uriVariables.put("year", year);
uriVariables.put("month", month);
EPASCertifications epasCertifications = rt.getForObject(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/certifications/getMonthValidationStatusByPerson?fiscalCode={fc}&year={year}&month={month}",
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/certifications/getMonthSituation?fiscalCode={fc}&year={year}&month={month}",
EPASCertifications.class,uriVariables);
log.info("Retrieved EPASCertifications: {}", epasCertifications);
return epasCertifications;
}
public List<EPASCertifications> getCertificationsByOfficeCodeId(String id, String year, String month) {
log.info("Retrieving EPASCertifications for office codeId: {}", id);
public EPASCertifications getByPersonEmail(String email, String year, String month) {
log.info("Retrieving EPASCertifications by person email={}, year={}, month={}", email,year,month);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("email", email);
uriVariables.put("year", year);
uriVariables.put("month", month);
EPASCertifications epasCertifications = rt.getForObject(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/certifications/getMonthSituation?email={email}&year={year}&month={month}",
EPASCertifications.class,uriVariables);
log.info("Retrieved EPASCertifications: {}", epasCertifications);
return epasCertifications;
}
public List<EPASCertifications> getByOfficeCodeId(String id, String year, String month) {
log.info("Retrieving EPASCertifications by office codeId: {}", id);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("sedeId", id);

View File

@ -60,6 +60,17 @@ public class EPASContractsCient {
return listEPASContracts;
}
public List<EPASContracts> getByPersonEmail(String email) {
ResponseEntity<List<EPASContracts>> responseEntity = rt.exchange(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/contracts/byPerson?email={email}", HttpMethod.GET,
null, new ParameterizedTypeReference<List<EPASContracts>>() {
}, email);
List<EPASContracts> listEPASContracts = responseEntity.getBody();
log.info("Retrieved Contracts: {}", listEPASContracts);
return listEPASContracts;
}
public EPASContracts create(EPASContractsDTO epasContractsDTO) {
ResponseEntity<EPASContracts> response = rt.postForEntity(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/contracts/create", epasContractsDTO,

View File

@ -0,0 +1,94 @@
package it.cnr.isti.epasmed.epas.client;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import it.cnr.isti.epasmed.config.ApplicationProperties;
import it.cnr.isti.epasmed.epas.model.EPASLeaves;
@Component
public class EPASLeavesCient {
private final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
@Qualifier("RestTemplateForSecondUser")
RestTemplate rt;
@Autowired
ApplicationProperties appProps;
public List<EPASLeaves> getByPersonId(String id, String year) {
log.info("Retrieving EPASLeaves by person id: {}", id);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("id", id);
uriVariables.put("year", year);
ResponseEntity<List<EPASLeaves>> responseEntity = rt.exchange(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/leaves/byPersonAndYear?id={id}&year={year}",
HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASLeaves>>() {
}, uriVariables);
List<EPASLeaves> listEPASLeaves = responseEntity.getBody();
log.info("Retrieved Leaves: {}", listEPASLeaves);
return listEPASLeaves;
}
public List<EPASLeaves> getByFiscalcode(String fc, String year) {
log.info("Retrieving EPASLeaves by person fiscalcode: {}", fc);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("fc", fc);
uriVariables.put("year", year);
ResponseEntity<List<EPASLeaves>> responseEntity = rt.exchange(
appProps.getDatasourceEpasRest().getRestUrl()
+ "/v2/leaves/byPersonAndYear?fiscalCode={fc}&year={year}",
HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASLeaves>>() {
}, uriVariables);
List<EPASLeaves> listEPASLeaves = responseEntity.getBody();
log.info("Retrieved Leaves: {}", listEPASLeaves);
return listEPASLeaves;
}
public List<EPASLeaves> getByPersonEmail(String email, String year) {
log.info("Retrieving EPASLeaves by person email: {}", email);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("email", email);
uriVariables.put("year", year);
ResponseEntity<List<EPASLeaves>> responseEntity = rt.exchange(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/leaves/byPersonAndYear?email={email}&year={year}",
HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASLeaves>>() {
}, uriVariables);
List<EPASLeaves> listEPASLeaves = responseEntity.getBody();
log.info("Retrieved Leaves: {}", listEPASLeaves);
return listEPASLeaves;
}
public List<EPASLeaves> getByOfficeCodeId(String officeCodeId, String year) {
log.info("Retrieving EPASLeaves by office codeId: {}", officeCodeId);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("id", officeCodeId);
uriVariables.put("year", year);
ResponseEntity<List<EPASLeaves>> responseEntity = rt.exchange(
appProps.getDatasourceEpasRest().getRestUrl() + "/v2/leaves/byOfficeAndYear?sedeId={id}&year={year}",
HttpMethod.GET, null, new ParameterizedTypeReference<List<EPASLeaves>>() {
}, uriVariables);
List<EPASLeaves> listEPASLeaves = responseEntity.getBody();
log.info("Retrieved Leaves: {}", listEPASLeaves);
return listEPASLeaves;
}
}

View File

@ -95,7 +95,7 @@ public class EPASPersonsCient {
public void deleteByFiscalCode(String fc) {
rt.delete(appProps.getDatasourceEpasRest().getRestUrl() + "/v2/persons/delete?fiscalCode={fc}", fc);
log.info("Delete Persons with fiscalcode: {}", fc);
log.info("Delete Persons by fiscalcode: {}", fc);
return;
}

View File

@ -15,7 +15,6 @@ import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import it.cnr.isti.epasmed.config.ApplicationProperties;
import it.cnr.isti.epasmed.epas.model.EPASPersons;
import it.cnr.isti.epasmed.epas.model.EPASTimeCards;
@Component
@ -30,7 +29,8 @@ public class EPASTimeCardsClient {
@Autowired
ApplicationProperties appProps;
public EPASTimeCards getTimeCardByPersonId(String id, String year, String month) {
public EPASTimeCards getByPersonId(String id, String year, String month) {
log.info("Retrieving EPASTimeCard by person id: {}", id);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("id", id);
uriVariables.put("year", year);
@ -44,7 +44,7 @@ public class EPASTimeCardsClient {
}
public List<EPASTimeCards> getTimeCardByOfficeCodeId(String id, String year, String month) {
public List<EPASTimeCards> getByOfficeCodeId(String id, String year, String month) {
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("sedeId", id);
uriVariables.put("year", year);

View File

@ -25,7 +25,7 @@ public class EPASValidatesClient {
@Autowired
ApplicationProperties appProps;
public String isValidatesByPersonEmail(String email, String year, String month) {
public String isByPersonEmail(String email, String year, String month) {
log.info("Retrieving EPASValidates status for person email: {}", email);
Map<String, String> uriVariables = new HashMap<>();
uriVariables.put("email", email);
@ -40,7 +40,7 @@ public class EPASValidatesClient {
}
public EPASValidates getValidatesByOfficeCodeId(String id, String year, String month) {
public EPASValidates getByOfficeCodeId(String id, String year, String month) {
log.info("Retrieving EPASValidates for office codeId: {}", id);
Map<String, String> uriVariables = new HashMap<>();

View File

@ -14,11 +14,11 @@ public class EPASAbsences implements Serializable {
private static final long serialVersionUID = 1L;
String code;
String date;
String id;
String justifiedTime;
String justifiedType;
String note;
private String code;
private String date;
private String id;
private String justifiedTime;
private String justifiedType;
private String note;
}

View File

@ -23,4 +23,4 @@ public class EPASCertifications implements Serializable {
private String[] trainingHours;
private String year;
}
}

View File

@ -0,0 +1,21 @@
package it.cnr.isti.epasmed.epas.model;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EPASLeaves implements Serializable {
private static final long serialVersionUID = 1L;
private EPASPersons person;
private String code;
private String start;
private String end;
}

View File

@ -14,14 +14,14 @@ public class EPASPersonDays implements Serializable {
private static final long serialVersionUID = 1L;
EPASAbsences[] absences;
String date;
Integer difference;
String id;
Boolean isHoliday;
Boolean isTicketAvailable;
Integer progressive;
String[] stampings;
Integer timeAtWork;
private EPASAbsences[] absences;
private String date;
private Integer difference;
private String id;
private Boolean isHoliday;
private Boolean isTicketAvailable;
private Integer progressive;
private EPASStampings[] stampings;
private Integer timeAtWork;
}

View File

@ -0,0 +1,25 @@
package it.cnr.isti.epasmed.epas.model;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EPASStampings implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String date;
private String way;
private String stampType;
private String place;
private String reason;
private String markedByAdmin;
private String markedByEmployee;
private String note;
}

View File

@ -13,7 +13,10 @@ public class EPASTickets implements Serializable {
private static final long serialVersionUID = 1L;
private String code;
private String electronicTickets;
private String paperyTickets;
private String quantity;
}

View File

@ -14,10 +14,10 @@ public class EPASTimeCards implements Serializable {
private static final long serialVersionUID = 1L;
String baseWorkingDays;
String month;
String year;
EPASPersons person;
EPASPersonDays[] personDays;
private String baseWorkingDays;
private String month;
private String year;
private EPASPersons person;
private EPASPersonDays[] personDays;
}

View File

@ -14,8 +14,8 @@ public class EPASValidates implements Serializable {
private static final long serialVersionUID = 1L;
Boolean allCertificationsValidated;
EPASPersons[] notValidatedPersons;
EPASPersons[] validatedPersons;
private Boolean allCertificationsValidated;
private EPASPersons[] notValidatedPersons;
private EPASPersons[] validatedPersons;
}

View File

@ -15,15 +15,19 @@ public class EPASCertificationsService {
EPASCertificationsClient epasCertificationsClient;
public EPASCertifications getCertificationsByPersonId(String id, String year, String month) {
return epasCertificationsClient.getCertificationsByPersonId(id, year, month);
return epasCertificationsClient.getByPersonId(id, year, month);
}
public EPASCertifications getCertificationsByPersonFiscalCode(String fc, String year, String month) {
return epasCertificationsClient.getCertificationsByPersonFiscalCode(fc, year, month);
return epasCertificationsClient.getByPersonFiscalCode(fc, year, month);
}
public EPASCertifications getCertificationsByPersonEmail(String email, String year, String month) {
return epasCertificationsClient.getByPersonEmail(email, year, month);
}
public List<EPASCertifications> getCertificationsByOfficeCodeId(String id, String year, String month) {
return epasCertificationsClient.getCertificationsByOfficeCodeId(id, year, month);
return epasCertificationsClient.getByOfficeCodeId(id, year, month);
}

View File

@ -28,6 +28,10 @@ public class EPASContractsService {
public List<EPASContracts> getByPersonFiscalcode(String fc) {
return epasContractsClient.getByPersonFiscalcode(fc);
}
public List<EPASContracts> getByPersonEmail(String email) {
return epasContractsClient.getByPersonEmail(email);
}
public EPASContracts create(EPASContractsDTO epasContractsDTO) {
return epasContractsClient.create(epasContractsDTO);

View File

@ -0,0 +1,33 @@
package it.cnr.isti.epasmed.epas.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import it.cnr.isti.epasmed.epas.client.EPASLeavesCient;
import it.cnr.isti.epasmed.epas.model.EPASLeaves;
@Service
public class EPASLeavesService {
@Autowired
EPASLeavesCient epasLeavesClient;
public List<EPASLeaves> getLeavesByPersonId(String id, String year) {
return epasLeavesClient.getByPersonId(id, year);
}
public List<EPASLeaves> getLeavesByPersonFiscalcode(String fc, String year) {
return epasLeavesClient.getByFiscalcode(fc, year);
}
public List<EPASLeaves> getLeavesByPersonEmail(String email, String year) {
return epasLeavesClient.getByPersonEmail(email, year);
}
public List<EPASLeaves> getLeavesByOfficeCodeId(String officeCodeId, String year) {
return epasLeavesClient.getByOfficeCodeId(officeCodeId, year);
}
}

View File

@ -15,11 +15,11 @@ public class EPASTimeCardsService {
EPASTimeCardsClient epasTimeCardsClient;
public EPASTimeCards getTimeCardByPersonId(String id, String year, String month) {
return epasTimeCardsClient.getTimeCardByPersonId(id, year, month);
return epasTimeCardsClient.getByPersonId(id, year, month);
}
public List<EPASTimeCards> getTimeCardByOfficeCodeId(String id, String year, String month) {
return epasTimeCardsClient.getTimeCardByOfficeCodeId(id, year, month);
return epasTimeCardsClient.getByOfficeCodeId(id, year, month);
}
}

View File

@ -13,11 +13,11 @@ public class EPASValidatesService {
EPASValidatesClient epasValidatesClient;
public String isValidatesByPersonEmail(String email, String year, String month) {
return epasValidatesClient.isValidatesByPersonEmail(email, year, month);
return epasValidatesClient.isByPersonEmail(email, year, month);
}
public EPASValidates getValidatesByOfficeCodeId(String id, String year, String month) {
return epasValidatesClient.getValidatesByOfficeCodeId(id, year, month);
return epasValidatesClient.getByOfficeCodeId(id, year, month);
}

View File

@ -28,6 +28,7 @@ public class SyncService {
private static final String ISTI_OFFICE_ID = "1";
private static final String SI_FLAG_DEL_TRUE = "1";
private static final String SI_RECAPITO_TELEFONICO_UFFICIO = "Ufficio";
@SuppressWarnings("unused")
private static final String SI_TIPO_EMAIL_ISTITUZIONALE = "Istituzionale";
private static final String SI_TIPO_EMAIL_CNR = "C.N.R.";
@ -59,8 +60,8 @@ public class SyncService {
private boolean btelefoni;
private boolean bgruppi;
private boolean bgruppo_pers;
private boolean bposizioni;
private boolean bproroghe;
//private boolean bposizioni;
//private boolean bproroghe;
private boolean borario;
private boolean bcartellini;
private boolean bcartellini_rendicontazioni;
@ -74,8 +75,8 @@ public class SyncService {
btelefoni = false;
bgruppi = false;
bgruppo_pers = false;
bposizioni = false;
bproroghe = false;
//bposizioni = false;
//bproroghe = false;
List<TabsSI> tabsSI = tabsSIService.getAllTabsSI();
siMasterLogService.startFluxReads();
@ -211,14 +212,15 @@ public class SyncService {
EPASPersonsDTO epasPersonsDTO = epasPersonsMapper
.epasPersonsToEPASPersonsDTO(epasPerson);
switch (emailTipo) {
case SI_TIPO_EMAIL_ISTITUZIONALE:
epasPersonsDTO.setEmail(se.getEmail());
epasPersonsService.updateByFiscalCode(epasPersonsDTO.getFiscalCode(),
epasPersonsDTO);
log.info("EPAS Updated Person: {}", epasPersonsDTO);
break;
//case SI_TIPO_EMAIL_ISTITUZIONALE:
// epasPersonsDTO.setEmail(se.getEmail());
// epasPersonsService.updateByFiscalCode(epasPersonsDTO.getFiscalCode(),
// epasPersonsDTO);
// log.info("EPAS Updated Person: {}", epasPersonsDTO);
//
// break;
case SI_TIPO_EMAIL_CNR:
epasPersonsDTO.setEmail(se.getEmail());
epasPersonsDTO.setEppn(se.getEmail());
epasPersonsService.updateByFiscalCode(epasPersonsDTO.getFiscalCode(),
epasPersonsDTO);

View File

@ -0,0 +1,98 @@
package it.cnr.isti.epasmed.web.rest.epas;
import java.util.List;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.github.jhipster.web.util.HeaderUtil;
import io.github.jhipster.web.util.ResponseUtil;
import it.cnr.isti.epasmed.epas.model.EPASCertifications;
import it.cnr.isti.epasmed.epas.service.EPASCertificationsService;
@RestController
@RequestMapping("/api/epas")
public class EPASCertificationsResource {
private final Logger log = LoggerFactory.getLogger(getClass());
@Value("${jhipster.clientApp.name}")
private String applicationName;
private final EPASCertificationsService epasCertificationsService;
public EPASCertificationsResource(EPASCertificationsService epasCertificationsService) {
this.epasCertificationsService = epasCertificationsService;
}
/**
* {@code GET /certifications/getMonthSituation} : get certifications by person, year and month
*
* @param id the id of the person.
* @param fiscalCode the fiscal code of the person.
* @param email the email of the person.
* @param year the year.
* @param month the month.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
* the EPAS Leaves, or with status {@code 404 (Not Found)}.
*/
@GetMapping("/certifications/getMonthSituation")
public ResponseEntity<EPASCertifications> getEPASCertificationByPerson(@RequestParam("id") Optional<String> id,
@RequestParam("fiscalCode") Optional<String> fiscalCode,
@RequestParam("email") Optional<String> email,
@RequestParam("year") String year,@RequestParam("month") String month) {
EPASCertifications epasCertifications = null;
if (id.isPresent()) {
log.info("REST request to get ePAS Certification by Person: {}", id.get());
epasCertifications = epasCertificationsService.getCertificationsByPersonId(id.get(), year, month);
} else {
if (fiscalCode.isPresent()) {
log.info("REST request to get ePAS Certification by Person fiscal code: {}", fiscalCode.get());
epasCertifications = epasCertificationsService.getCertificationsByPersonFiscalCode(fiscalCode.get(), year, month);
} else {
if (email.isPresent()) {
log.info("REST request to get ePAS Certification by Person email: {}", email.get());
epasCertifications = epasCertificationsService.getCertificationsByPersonEmail(email.get(), year, month);
} else {
return ResponseUtil.wrapOrNotFound(Optional.of(epasCertifications), HeaderUtil.createFailureAlert(applicationName,false,
"","","Invalid parameter in call"));
}
}
}
log.info("Retrieved Certification: {}", epasCertifications);
return ResponseUtil.wrapOrNotFound(Optional.of(epasCertifications));
}
/**
* {@code GET /certifications/getMonthSituationByOffice} : get certifications by office, year and month.
*
* @param officeCodeId the office codeId.
* @param year the year.
* @param month the month.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
* the list of EPAS Leaves, or with status {@code 404 (Not Found)}.
*/
@GetMapping("/certifications/getMonthSituationByOffice")
public ResponseEntity<List<EPASCertifications>> getEPASCertificationByOfficeCodeId(@RequestParam("officeCodeId") String officeCodeId,
@RequestParam("year") String year, @RequestParam("month") String month) {
log.info("REST request to get ePAS Certification by office: codeId={}, year={}, month={}", officeCodeId, year, month);
List<EPASCertifications> epasCertificationsList = epasCertificationsService.getCertificationsByOfficeCodeId(officeCodeId, year, month);
log.info("Retrieved Certification: {}", epasCertificationsList);
return ResponseUtil.wrapOrNotFound(Optional.of(epasCertificationsList));
}
}

View File

@ -63,16 +63,18 @@ public class EPASContractsResource {
}
/**
* {@code GET /contracts/byPerson} : get contracts by Person id
* {@code GET /contracts/byPerson} : get contracts by Person
*
* @param id the id of the person.
* @param fiscalCode the fiscal code of the person.
* @param email the email of the person.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
* the EPAS Contracts, or with status {@code 404 (Not Found)}.
*/
@GetMapping("/contracts/byPerson")
public ResponseEntity<List<EPASContracts>> getEPASContractsByPerson(@RequestParam("id") Optional<String> id,
@RequestParam("fiscalCode") Optional<String> fiscalCode) {
@RequestParam("fiscalCode") Optional<String> fiscalCode,
@RequestParam("email") Optional<String> email) {
List<EPASContracts> epasContractsList = null;
if (id.isPresent()) {
log.info("REST request to get ePAS Contracts by Person: {}", id.get());
@ -81,6 +83,11 @@ public class EPASContractsResource {
if (fiscalCode.isPresent()) {
log.info("REST request to get ePAS Contracts by Person fiscal code: {}", fiscalCode.get());
epasContractsList = epasContractsService.getByPersonFiscalcode(fiscalCode.get());
} else {
if (email.isPresent()) {
log.info("REST request to get ePAS Contracts by Person email: {}", email.get());
epasContractsList = epasContractsService.getByPersonEmail(email.get());
}
}
}
log.info("Retrieved List of Contracts: {}", epasContractsList);

View File

@ -0,0 +1,87 @@
package it.cnr.isti.epasmed.web.rest.epas;
import java.util.List;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.github.jhipster.web.util.ResponseUtil;
import it.cnr.isti.epasmed.epas.model.EPASLeaves;
import it.cnr.isti.epasmed.epas.service.EPASLeavesService;
@RestController
@RequestMapping("/api/epas")
public class EPASLeavesResource {
private final Logger log = LoggerFactory.getLogger(getClass());
@Value("${jhipster.clientApp.name}")
private String applicationName;
private final EPASLeavesService epasLeavesService;
public EPASLeavesResource(EPASLeavesService epasLeavesService) {
this.epasLeavesService = epasLeavesService;
}
/**
* {@code GET /leaves/byPersonAndYear} : get contracts by person and year
*
* @param id the id of the person.
* @param fiscalCode the fiscal code of the person.
* @param email the email of the person.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
* the EPAS Leaves, or with status {@code 404 (Not Found)}.
*/
@GetMapping("/leaves/byPersonAndYear")
public ResponseEntity<List<EPASLeaves>> getEPASContractsByPerson(@RequestParam("id") Optional<String> id,
@RequestParam("fiscalCode") Optional<String> fiscalCode,
@RequestParam("email") Optional<String> email,
@RequestParam("year") String year) {
List<EPASLeaves> epasLeavesList = null;
if (id.isPresent()) {
log.info("REST request to get ePAS Leaves by Person: {}", id.get());
epasLeavesList = epasLeavesService.getLeavesByPersonId(id.get(),year);
} else {
if (fiscalCode.isPresent()) {
log.info("REST request to get ePAS Leaves by Person fiscal code: {}", fiscalCode.get());
epasLeavesList = epasLeavesService.getLeavesByPersonFiscalcode(fiscalCode.get(), year);
} else {
if (email.isPresent()) {
log.info("REST request to get ePAS Leaves by Person email: {}", email.get());
epasLeavesList = epasLeavesService.getLeavesByPersonEmail(email.get(), year);
}
}
}
log.info("Retrieved List of Leaves: {}", epasLeavesList);
return ResponseUtil.wrapOrNotFound(Optional.of(epasLeavesList));
}
/**
* {@code GET /leaves/byOfficeAndYear} : get leaves by office and year.
*
* @param officeCodeId the office codeId.
* @param year the year.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body
* the list of EPAS Leaves, or with status {@code 404 (Not Found)}.
*/
@GetMapping("/leaves/byOfficeAndYear")
public ResponseEntity<List<EPASLeaves>> getEPASLeavesByOfficeCodeId(@RequestParam("officeCodeId") String officeCodeId,
@RequestParam("year") String year) {
log.info("REST request to get ePAS Leaves by office: codeId={}, year={}", officeCodeId, year);
List<EPASLeaves> epasLeavesList = epasLeavesService.getLeavesByOfficeCodeId(officeCodeId, year);
return ResponseUtil.wrapOrNotFound(Optional.of(epasLeavesList));
}
}

View File

@ -53,9 +53,9 @@ public class EPASAffiliationsResourceIT {
private final Logger log = LoggerFactory.getLogger(getClass());
private static final String OFFICE_DEFAULT_ID = "1";
private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa";
private static final String OFFICE_DEFAULT_CODE = "074000";
private static final String OFFICE_DEFAULT_CODEID = "225200";
//private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa";
//private static final String OFFICE_DEFAULT_CODE = "074000";
//private static final String OFFICE_DEFAULT_CODEID = "225200";
private static final String AFFILIATION_DEFAULT_ID = "1";
private static final String AFFILIATION_DEFAULT_BEGINDATE = "2021-01-01";
@ -65,7 +65,7 @@ public class EPASAffiliationsResourceIT {
private static final String AFFILIATION_DEFAULT_PERSONID = "1";
private static final String AFFILIATION_DEFAULT_EXTERNALID = "1";
private ArrayList<EPASAffiliationsDTO> epasAffiliationsDTOList;
//private ArrayList<EPASAffiliationsDTO> epasAffiliationsDTOList;
@Autowired
private MockMvc restEPASAffiliationsMockMvc;
@ -76,7 +76,7 @@ public class EPASAffiliationsResourceIT {
@Autowired
private Environment environment;
private EPASAffiliations epasAffiliations;
//private EPASAffiliations epasAffiliations;
private EPASAffiliationsDTO epasAffiliationsDTO;

View File

@ -0,0 +1,88 @@
package it.cnr.isti.epasmed.web.rest.epas;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment;
import org.springframework.security.test.context.support.WithMockUser;
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.security.AuthoritiesConstants;
/**
* Integration tests for the {@link EPASCertificationsResource} REST controller.
*/
@AutoConfigureMockMvc
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
@SpringBootTest(classes = EpasmedApp.class)
@EnabledIf("false")
public class EPASCertificationsResourceIT {
private final Logger log = LoggerFactory.getLogger(getClass());
// private static final String OFFICE_DEFAULT_ID = "1";
// private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa";
// private static final String OFFICE_DEFAULT_CODE = "074000";
private static final String OFFICE_DEFAULT_CODEID = "225200";
private static final String PERSON_DEFAULT_ID = "113";
//private static final String PERSON_DEFAULT_NAME = "Giuseppe";
//private static final String PERSON_DEFAULT_SURNAME = "Amato";
private static final String PERSON_DEFAULT_FISCAL_CODE = "MTAGPP68D15D976W";
private static final String PERSON_DEFAULT_EMAIL = "giuseppe.amato@cnr.it";
//private static final String PERSON_DEFAULT_QUALIFICATION = "2";
@Autowired
private MockMvc restEPASCertificationsMockMvc;
@Autowired
private Environment environment;
//private EPASLeaves epasLeaves;
@BeforeEach
public void initTest() {
for (String profileName : environment.getActiveProfiles()) {
log.info("Currently active profile - " + profileName);
}
}
@Test
public void getEPASCertificationsByPersonId() throws Exception {
restEPASCertificationsMockMvc.perform(get("/api/epas/certifications/getMonthSituation?id=" + PERSON_DEFAULT_ID + "&year=2021&month=10"))
.andExpect(status().isOk());
}
@Test
public void getEPASCertificationsByPersonFiscalcode() throws Exception {
restEPASCertificationsMockMvc
.perform(
get("/api/epas/certifications/getMonthSituation?fiscalCode=" + PERSON_DEFAULT_FISCAL_CODE + "&year=2021&month=10"))
.andExpect(status().isOk());
}
@Test
public void getEPASCertificationsByPersonEmail() throws Exception {
restEPASCertificationsMockMvc
.perform(get("/api/epas/certifications/getMonthSituation?email=" + PERSON_DEFAULT_EMAIL + "&year=2021&month=10"))
.andExpect(status().isOk());
}
@Test
public void getEPASCertificationsByOfficeCodeId() throws Exception {
restEPASCertificationsMockMvc
.perform(get("/api/epas/certifications/getMonthSituationByOffice?officeCodeId=" + OFFICE_DEFAULT_CODEID + "&year=2021&month=10"))
.andExpect(status().isOk());
}
}

View File

@ -61,7 +61,7 @@ public class EPASContractsResourceIT {
private static final String PERSON_DEFAULT_EMAIL = "giancarlo.panichi@cnr.it";
private static final String PERSON_DEFAULT_QUALIFICATION = "6";
private static final String CONTRACT_DEFAULT_ID = "1";
private static final String CONTRACT_DEFAULT_ID = "175";
private static final String CONTRACT_DEFAULT_BEGINDATE = "2018-12-27";
private static final String CONTRACT_DEFAUL_ENDDATE = null;
private static final String CONTRACT_DEFAULT_ENDCONTRACT = null;
@ -127,7 +127,7 @@ public class EPASContractsResourceIT {
}
@Test
public void getContract() throws Exception {
public void getContractById() throws Exception {
restEPASContractsMockMvc.perform(get("/api/epas/contracts/" + CONTRACT_DEFAULT_ID)).andExpect(status().isOk());
}
@ -142,6 +142,12 @@ public class EPASContractsResourceIT {
restEPASContractsMockMvc.perform(get("/api/epas/contracts/byPerson?fiscalCode=" + PERSON_DEFAULT_FISCAL_CODE))
.andExpect(status().isOk());
}
@Test
public void getContractByPersonEmail() throws Exception {
restEPASContractsMockMvc.perform(get("/api/epas/contracts/byPerson?email=" + PERSON_DEFAULT_EMAIL))
.andExpect(status().isOk());
}
@Test
public void createContract() throws Exception {

View File

@ -0,0 +1,88 @@
package it.cnr.isti.epasmed.web.rest.epas;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment;
import org.springframework.security.test.context.support.WithMockUser;
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.security.AuthoritiesConstants;
/**
* Integration tests for the {@link EPASLeavesResource} REST controller.
*/
@AutoConfigureMockMvc
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
@SpringBootTest(classes = EpasmedApp.class)
@EnabledIf("false")
public class EPASLeavesResourceIT {
private final Logger log = LoggerFactory.getLogger(getClass());
// private static final String OFFICE_DEFAULT_ID = "1";
// private static final String OFFICE_DEFAULT_NAME = "ISTI - Pisa";
// private static final String OFFICE_DEFAULT_CODE = "074000";
private static final String OFFICE_DEFAULT_CODEID = "225200";
private static final String PERSON_DEFAULT_ID = "113";
//private static final String PERSON_DEFAULT_NAME = "Giuseppe";
//private static final String PERSON_DEFAULT_SURNAME = "Amato";
private static final String PERSON_DEFAULT_FISCAL_CODE = "MTAGPP68D15D976W";
private static final String PERSON_DEFAULT_EMAIL = "giuseppe.amato@cnr.it";
//private static final String PERSON_DEFAULT_QUALIFICATION = "2";
@Autowired
private MockMvc restEPASLeavesMockMvc;
@Autowired
private Environment environment;
//private EPASLeaves epasLeaves;
@BeforeEach
public void initTest() {
for (String profileName : environment.getActiveProfiles()) {
log.info("Currently active profile - " + profileName);
}
}
@Test
public void getEPASLeavesByPersonId() throws Exception {
restEPASLeavesMockMvc.perform(get("/api/epas/leaves/byPersonAndYear?id=" + PERSON_DEFAULT_ID + "&year=2021"))
.andExpect(status().isOk());
}
@Test
public void getEPASLeaveByPersonFiscalcode() throws Exception {
restEPASLeavesMockMvc
.perform(
get("/api/epas/leaves/byPersonAndYear?fiscalCode=" + PERSON_DEFAULT_FISCAL_CODE + "&year=2021"))
.andExpect(status().isOk());
}
@Test
public void getEPASLeavesByPersonEmail() throws Exception {
restEPASLeavesMockMvc
.perform(get("/api/epas/leaves/byPersonAndYear?email=" + PERSON_DEFAULT_EMAIL + "&year=2021"))
.andExpect(status().isOk());
}
@Test
public void getEPASLeavesByOfficeCodeId() throws Exception {
restEPASLeavesMockMvc
.perform(get("/api/epas/leaves/byOfficeAndYear?officeCodeId=" + OFFICE_DEFAULT_CODEID + "&year=2021"))
.andExpect(status().isOk());
}
}

View File

@ -121,7 +121,7 @@ public class EPASPersonsResourceIT {
@Test
public void getPersonByFiscalCode() throws Exception {
restEPASPersonsMockMvc.perform(get("/api/epas/persons/show?fiscalCode=PRIGRL74E31G491R")).andExpect(status().isOk());
restEPASPersonsMockMvc.perform(get("/api/epas/persons/show?fiscalCode=MTAGPP68D15D976W")).andExpect(status().isOk());
}
@Test