From e91d8a3a77a2f6dad981f57cf547d4102a84ce3a Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 15 Dec 2021 18:41:27 +0100 Subject: [PATCH] Updated Stampings support --- .../config/EpasRestTemplateConfig.java | 9 + ...emaInformativoDataSourceConfiguration.java | 1 - .../epasmed/config/SyncConfiguration.java | 27 ++ .../it/cnr/isti/epasmed/domain/TabsSI.java | 6 +- .../epasmed/domain/TimeCardsReporting.java | 6 +- .../epas/client/EPASStampingsClient.java | 44 ++++ .../epasmed/epas/dto/EPASStampingsDTO.java | 24 ++ .../epas/service/EPASStampingsService.java | 24 ++ .../model/SICartellini.java | 28 +++ .../model/SICartelliniRendicontazioni.java | 23 ++ .../sistemainformativo/model/SIOrario.java | 23 ++ .../repository/SIAnagraficoRepository.java | 4 +- ...SICartelliniRendicontazioniRepository.java | 37 +++ .../repository/SICartelliniRepository.java | 38 +++ .../repository/SIEmailRepository.java | 4 +- .../repository/SIGruppiPersRepository.java | 4 +- .../repository/SIGruppiRepository.java | 4 +- .../repository/SIMasterLogRepository.java | 52 ++-- .../repository/SIOrarioRepository.java | 37 +++ .../repository/SIPosizioniRepository.java | 4 +- .../repository/SIProrogheRepository.java | 4 +- .../repository/SITelefoniRepository.java | 4 +- .../service/SIAnagraficoService.java | 8 +- .../SICartelliniRendicontazioniService.java | 33 +++ .../service/SICartelliniService.java | 35 +++ .../service/SIEmailService.java | 8 +- .../service/SIGruppiPersService.java | 8 +- .../service/SIGruppiService.java | 8 +- .../service/SIMasterLogService.java | 4 +- .../service/SIOrarioService.java | 35 +++ .../service/SIPosizioniService.java | 6 +- .../service/SIProrogheService.java | 6 +- .../service/SITelefoniService.java | 6 +- .../it/cnr/isti/epasmed/sync/SyncService.java | 192 ++++++++++---- .../isti/epasmed/web/rest/SyncResource.java | 56 +++-- .../web/rest/epas/EPASPersonsResource.java | 6 +- .../web/rest/epas/EPASStampingsResource.java | 89 +++++++ src/main/webapp/app/app-routing.module.ts | 4 + src/main/webapp/app/app.module.ts | 2 + .../app/layouts/navbar/navbar.component.html | 16 ++ .../app/operations/operations.module.ts | 18 ++ .../app/operations/sync/sync.component.html | 11 + .../app/operations/sync/sync.component.ts | 22 ++ .../webapp/app/operations/sync/sync.model.ts | 1 + .../webapp/app/operations/sync/sync.module.ts | 13 + .../webapp/app/operations/sync/sync.route.ts | 13 + .../app/operations/sync/sync.service.ts | 15 ++ .../java/it/cnr/isti/epasmed/SimpleTest.java | 18 ++ .../rest/epas/EPASStampingsResourceIT.java | 238 ++++++++++++++++++ .../epas/EPASWorkingTimeTypesResourceIT.java | 2 +- 50 files changed, 1135 insertions(+), 145 deletions(-) create mode 100644 src/main/java/it/cnr/isti/epasmed/config/SyncConfiguration.java create mode 100644 src/main/java/it/cnr/isti/epasmed/epas/client/EPASStampingsClient.java create mode 100644 src/main/java/it/cnr/isti/epasmed/epas/dto/EPASStampingsDTO.java create mode 100644 src/main/java/it/cnr/isti/epasmed/epas/service/EPASStampingsService.java create mode 100644 src/main/java/it/cnr/isti/epasmed/sistemainformativo/model/SICartellini.java create mode 100644 src/main/java/it/cnr/isti/epasmed/sistemainformativo/model/SICartelliniRendicontazioni.java create mode 100644 src/main/java/it/cnr/isti/epasmed/sistemainformativo/model/SIOrario.java create mode 100644 src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SICartelliniRendicontazioniRepository.java create mode 100644 src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SICartelliniRepository.java create mode 100644 src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIOrarioRepository.java create mode 100644 src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SICartelliniRendicontazioniService.java create mode 100644 src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SICartelliniService.java create mode 100644 src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIOrarioService.java create mode 100644 src/main/java/it/cnr/isti/epasmed/web/rest/epas/EPASStampingsResource.java create mode 100644 src/main/webapp/app/operations/operations.module.ts create mode 100644 src/main/webapp/app/operations/sync/sync.component.html create mode 100644 src/main/webapp/app/operations/sync/sync.component.ts create mode 100644 src/main/webapp/app/operations/sync/sync.model.ts create mode 100644 src/main/webapp/app/operations/sync/sync.module.ts create mode 100644 src/main/webapp/app/operations/sync/sync.route.ts create mode 100644 src/main/webapp/app/operations/sync/sync.service.ts create mode 100644 src/test/java/it/cnr/isti/epasmed/SimpleTest.java create mode 100644 src/test/java/it/cnr/isti/epasmed/web/rest/epas/EPASStampingsResourceIT.java diff --git a/src/main/java/it/cnr/isti/epasmed/config/EpasRestTemplateConfig.java b/src/main/java/it/cnr/isti/epasmed/config/EpasRestTemplateConfig.java index ab585cd..6f76d04 100644 --- a/src/main/java/it/cnr/isti/epasmed/config/EpasRestTemplateConfig.java +++ b/src/main/java/it/cnr/isti/epasmed/config/EpasRestTemplateConfig.java @@ -33,4 +33,13 @@ public class EpasRestTemplateConfig { applicationProperties.getDatasourceEpasRest().getRestPassword2()) .build(); } + + + @Bean(name = "RestTemplateForThirdUser") + public RestTemplate restTemplateThird(RestTemplateBuilder builder) { + return builder.defaultHeader("Accept", MediaType.APPLICATION_JSON.toString()) + .basicAuthentication(applicationProperties.getDatasourceEpasRest().getRestUsername3(), + applicationProperties.getDatasourceEpasRest().getRestPassword3()) + .build(); + } } diff --git a/src/main/java/it/cnr/isti/epasmed/config/SistemaInformativoDataSourceConfiguration.java b/src/main/java/it/cnr/isti/epasmed/config/SistemaInformativoDataSourceConfiguration.java index be109a6..684abd9 100644 --- a/src/main/java/it/cnr/isti/epasmed/config/SistemaInformativoDataSourceConfiguration.java +++ b/src/main/java/it/cnr/isti/epasmed/config/SistemaInformativoDataSourceConfiguration.java @@ -12,7 +12,6 @@ import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.transaction.TransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; diff --git a/src/main/java/it/cnr/isti/epasmed/config/SyncConfiguration.java b/src/main/java/it/cnr/isti/epasmed/config/SyncConfiguration.java new file mode 100644 index 0000000..5b3be24 --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/config/SyncConfiguration.java @@ -0,0 +1,27 @@ +package it.cnr.isti.epasmed.config; + +import java.time.LocalDateTime; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; + +@Configuration +@EnableScheduling +public class SyncConfiguration { + + private final Logger logger = LoggerFactory.getLogger(SyncConfiguration.class); + + @Scheduled(cron = "0 0 7 * * ?") + public void cronJobSch() { + + LocalDateTime start = LocalDateTime.now(); + logger.info("Scheduled Sync Start : {}", start); + + LocalDateTime end = LocalDateTime.now(); + logger.info("Scheduled Sync End : {}", end); + + } +} diff --git a/src/main/java/it/cnr/isti/epasmed/domain/TabsSI.java b/src/main/java/it/cnr/isti/epasmed/domain/TabsSI.java index b21cac0..dd035fb 100644 --- a/src/main/java/it/cnr/isti/epasmed/domain/TabsSI.java +++ b/src/main/java/it/cnr/isti/epasmed/domain/TabsSI.java @@ -30,13 +30,13 @@ public class TabsSI implements Serializable { @NotNull @Column(unique = true, nullable = false) - public String nome; + private String nome; @NotNull - public String operazioni; + private String operazioni; @NotNull - public Long idFlusso; + private Long idFlusso; @NotNull @Column(columnDefinition = "TIMESTAMP" ) diff --git a/src/main/java/it/cnr/isti/epasmed/domain/TimeCardsReporting.java b/src/main/java/it/cnr/isti/epasmed/domain/TimeCardsReporting.java index 793db7c..d5b068f 100644 --- a/src/main/java/it/cnr/isti/epasmed/domain/TimeCardsReporting.java +++ b/src/main/java/it/cnr/isti/epasmed/domain/TimeCardsReporting.java @@ -28,13 +28,13 @@ public class TimeCardsReporting implements Serializable { @NotNull @Column(nullable = false) - public Integer year; + private Integer year; @NotNull - public Integer month; + private Integer month; @NotNull - public Long idFlusso; + private Long idFlusso; @NotNull @Column(columnDefinition = "TIMESTAMP") diff --git a/src/main/java/it/cnr/isti/epasmed/epas/client/EPASStampingsClient.java b/src/main/java/it/cnr/isti/epasmed/epas/client/EPASStampingsClient.java new file mode 100644 index 0000000..11d2f8e --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/epas/client/EPASStampingsClient.java @@ -0,0 +1,44 @@ +package it.cnr.isti.epasmed.epas.client; + +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.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.dto.EPASStampingsDTO; +import it.cnr.isti.epasmed.epas.model.EPASStampings; + +@Component +public class EPASStampingsClient { + + private static final Logger logger = LoggerFactory.getLogger(EPASStampingsClient.class); + + @Autowired + @Qualifier("RestTemplateForThirdUser") + RestTemplate rt; + + @Autowired + ApplicationProperties appProps; + + public EPASStampings getById(String id) { + EPASStampings epasPersons = rt.getForObject( + appProps.getDatasourceEpasRest().getRestUrl() + "/v3/stampings/show/{id}", EPASStampings.class, id); + logger.info("Retrieved EPASStamping: {}", epasPersons); + return epasPersons; + } + + public EPASStampings create(EPASStampingsDTO epasStampingsDTO) { + ResponseEntity response = rt.postForEntity( + appProps.getDatasourceEpasRest().getRestUrl() + "/v3/stampings/create", epasStampingsDTO, EPASStampings.class); + EPASStampings createdEPASPersons = response.getBody(); + + logger.info("Created EPASStamping: {}", createdEPASPersons); + return createdEPASPersons; + } + + +} diff --git a/src/main/java/it/cnr/isti/epasmed/epas/dto/EPASStampingsDTO.java b/src/main/java/it/cnr/isti/epasmed/epas/dto/EPASStampingsDTO.java new file mode 100644 index 0000000..cd33ae0 --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/epas/dto/EPASStampingsDTO.java @@ -0,0 +1,24 @@ +package it.cnr.isti.epasmed.epas.dto; + +import java.io.Serializable; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class EPASStampingsDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + private String wayType; + private String reasonType; + private String dateTime; + private String badgeNumber; + private String zone; + private String note; + private String place; + private String reason; +} \ No newline at end of file diff --git a/src/main/java/it/cnr/isti/epasmed/epas/service/EPASStampingsService.java b/src/main/java/it/cnr/isti/epasmed/epas/service/EPASStampingsService.java new file mode 100644 index 0000000..79fd982 --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/epas/service/EPASStampingsService.java @@ -0,0 +1,24 @@ +package it.cnr.isti.epasmed.epas.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import it.cnr.isti.epasmed.epas.client.EPASStampingsClient; +import it.cnr.isti.epasmed.epas.dto.EPASStampingsDTO; +import it.cnr.isti.epasmed.epas.model.EPASStampings; + +@Service +public class EPASStampingsService { + + @Autowired + EPASStampingsClient epasStampingsClient; + + public EPASStampings getById(String id) { + return epasStampingsClient.getById(id); + } + + public EPASStampings create(EPASStampingsDTO epasStampingsDTO) { + return epasStampingsClient.create(epasStampingsDTO); + } + +} diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/model/SICartellini.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/model/SICartellini.java new file mode 100644 index 0000000..da57de6 --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/model/SICartellini.java @@ -0,0 +1,28 @@ +package it.cnr.isti.epasmed.sistemainformativo.model; + +import java.io.Serializable; +import java.sql.Timestamp; +import java.sql.Date; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SICartellini implements Serializable { + + private static final long serialVersionUID = 1L; + private Long id; + private Integer idpersona; + private String cf; + private Date data; + private String motivo; + private Integer ore_lavorate; + private Integer differenza; + private Timestamp data_mod; + private String flag_del; + private Long id_flusso; + +} diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/model/SICartelliniRendicontazioni.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/model/SICartelliniRendicontazioni.java new file mode 100644 index 0000000..70eb0ce --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/model/SICartelliniRendicontazioni.java @@ -0,0 +1,23 @@ +package it.cnr.isti.epasmed.sistemainformativo.model; + +import java.io.Serializable; +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SICartelliniRendicontazioni implements Serializable { + + private static final long serialVersionUID = 1L; + private Long id; + private Integer anno; + private Integer mese; + private Timestamp data_mod; + private String flag_del; + private Long id_flusso; + +} diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/model/SIOrario.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/model/SIOrario.java new file mode 100644 index 0000000..f9944a3 --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/model/SIOrario.java @@ -0,0 +1,23 @@ +package it.cnr.isti.epasmed.sistemainformativo.model; + +import java.io.Serializable; +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SIOrario implements Serializable { + + private static final long serialVersionUID = 1L; + private Long id; + private String descrizione; + private String flag; + private Timestamp data_mod; + private String flag_del; + private Long id_flusso; + +} diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIAnagraficoRepository.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIAnagraficoRepository.java index ebb2a3b..124b564 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIAnagraficoRepository.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIAnagraficoRepository.java @@ -18,7 +18,7 @@ import it.cnr.isti.epasmed.sistemainformativo.model.SIAnagrafico; @Repository public class SIAnagraficoRepository { - private final Logger logger = LoggerFactory.getLogger(SIAnagraficoRepository.class); + private static final Logger logger = LoggerFactory.getLogger(SIAnagraficoRepository.class); private JdbcTemplate jdbcTemplate; @@ -29,7 +29,6 @@ public class SIAnagraficoRepository { } public List readNewFlux(Long flusso) { - logger.info("Read Flux > {}",flusso); String query="select codicefiscale, cognome, nome, datanascita," + " numbadge, data_mod, flag_del, id_flusso, id " + " from anagrafico " @@ -62,6 +61,7 @@ public class SIAnagraficoRepository { a.setId(rs.getInt(9)); return a; }}); + logger.debug("Anagrafica: {}", anagrafica); return anagrafica; } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SICartelliniRendicontazioniRepository.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SICartelliniRendicontazioniRepository.java new file mode 100644 index 0000000..9914943 --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SICartelliniRendicontazioniRepository.java @@ -0,0 +1,37 @@ +package it.cnr.isti.epasmed.sistemainformativo.repository; + +import javax.sql.DataSource; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Repository; + +import it.cnr.isti.epasmed.sistemainformativo.model.SICartelliniRendicontazioni; + +@Repository +public class SICartelliniRendicontazioniRepository { + + private static final Logger logger = LoggerFactory.getLogger(SICartelliniRendicontazioniRepository.class); + + private JdbcTemplate jdbcTemplate; + + // + public SICartelliniRendicontazioniRepository( + final @Qualifier("sistemaInformativoDataSource") DataSource dataSource) { + super(); + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + public void writeNewFlux(Long fluxId, SICartelliniRendicontazioni siCartelliniRendicontazioni) { + jdbcTemplate.update( + "INSERT INTO epas_cartellini_rendicontazioni (id,anno,mese,data_mod,flag_del,id_flusso) " + + "VALUES (?,?,?,?,?,?)", + siCartelliniRendicontazioni.getId(), siCartelliniRendicontazioni.getAnno(), + siCartelliniRendicontazioni.getMese(), siCartelliniRendicontazioni.getData_mod(), + siCartelliniRendicontazioni.getFlag_del(), fluxId); + logger.debug("Writed SICartellinoRendicontazioni: {}", siCartelliniRendicontazioni); + } + +} diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SICartelliniRepository.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SICartelliniRepository.java new file mode 100644 index 0000000..cd7dcae --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SICartelliniRepository.java @@ -0,0 +1,38 @@ +package it.cnr.isti.epasmed.sistemainformativo.repository; + +import javax.sql.DataSource; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Repository; + +import it.cnr.isti.epasmed.sistemainformativo.model.SICartellini; + +@Repository +public class SICartelliniRepository { + + private static final Logger logger = LoggerFactory.getLogger(SICartelliniRepository.class); + + private JdbcTemplate jdbcTemplate; + + // + public SICartelliniRepository(final @Qualifier("sistemaInformativoDataSource") DataSource dataSource) { + super(); + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + public void writeNewFlux(Long fluxId, SICartellini siCartellini) { + jdbcTemplate.update("INSERT INTO epas_cartellini (id,idpersona,cf,data," + + " motivo,ore_lavorate,differenza,data_mod,flag_del,id_flusso) " + + "VALUES (?,?,?,?,?,?,?,?,?,?)", + siCartellini.getId(),siCartellini.getIdpersona(),siCartellini.getCf(),siCartellini.getData(), + siCartellini.getMotivo(),siCartellini.getOre_lavorate(),siCartellini.getDifferenza(), + siCartellini.getData_mod(),siCartellini.getFlag_del(),fluxId); + logger.debug("Writed SICartellino: {}",siCartellini); + } + + + +} diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIEmailRepository.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIEmailRepository.java index 6b1fe67..27dec6f 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIEmailRepository.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIEmailRepository.java @@ -18,7 +18,7 @@ import it.cnr.isti.epasmed.sistemainformativo.model.SIEmail; @Repository public class SIEmailRepository { - private final Logger logger = LoggerFactory.getLogger(SIEmailRepository.class); + private static final Logger logger = LoggerFactory.getLogger(SIEmailRepository.class); private JdbcTemplate jdbcTemplate; @@ -29,7 +29,6 @@ public class SIEmailRepository { } public List readNewFlux(Long flusso) { - logger.info("Read Flux > {}",flusso); String query="select cf, email, tipoemail, data_mod, flag_del, id_flusso, id, idpersona " + " from mail " + " WHERE id_flusso > " @@ -50,6 +49,7 @@ public class SIEmailRepository { return m; }}); + logger.debug("Emaills: {}",emails); return emails; } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIGruppiPersRepository.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIGruppiPersRepository.java index 88dc95d..f7d4f8e 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIGruppiPersRepository.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIGruppiPersRepository.java @@ -18,7 +18,7 @@ import it.cnr.isti.epasmed.sistemainformativo.model.SIGruppiPers; @Repository public class SIGruppiPersRepository { - private final Logger logger = LoggerFactory.getLogger(SIGruppiPersRepository.class); + private static final Logger logger = LoggerFactory.getLogger(SIGruppiPersRepository.class); private JdbcTemplate jdbcTemplate; @@ -29,7 +29,6 @@ public class SIGruppiPersRepository { } public List readNewFlux(Long flusso) { - logger.info("Read Flux > {}",flusso); String query="select cf, gruppo, dal, al, percentuale, data_mod, flag_del, id_flusso, id, idpersona, idgruppo " + " from gruppo_pers " + " WHERE id_flusso > " @@ -54,6 +53,7 @@ public class SIGruppiPersRepository { return gp; }}); + logger.debug("Gruppi: {}",gruppi); return gruppi; } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIGruppiRepository.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIGruppiRepository.java index fb7078c..b16ceb3 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIGruppiRepository.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIGruppiRepository.java @@ -18,7 +18,7 @@ import it.cnr.isti.epasmed.sistemainformativo.model.SIGruppi; @Repository public class SIGruppiRepository { - private final Logger logger = LoggerFactory.getLogger(SIGruppiRepository.class); + private static final Logger logger = LoggerFactory.getLogger(SIGruppiPersRepository.class); private JdbcTemplate jdbcTemplate; @@ -29,7 +29,6 @@ public class SIGruppiRepository { } public List readNewFlux(Long flusso) { - logger.info("Read Flux > {}",flusso); String query="select sigla, descrizione, data_mod, flag_del, id_flusso, id " + " from gruppi " + " WHERE id_flusso > " @@ -48,6 +47,7 @@ public class SIGruppiRepository { g.setId(rs.getInt(6)); return g; }}); + logger.debug("Gruppi: {}",gruppi); return gruppi; } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIMasterLogRepository.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIMasterLogRepository.java index ec23cfe..83a4bb3 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIMasterLogRepository.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIMasterLogRepository.java @@ -16,7 +16,7 @@ import org.springframework.stereotype.Repository; @Repository public class SIMasterLogRepository { - private final Logger log = LoggerFactory.getLogger(SIMasterLogRepository.class); + private static final Logger logger = LoggerFactory.getLogger(SIMasterLogRepository.class); private JdbcTemplate jdbcTemplate; @@ -27,21 +27,21 @@ public class SIMasterLogRepository { } public Long count() { - log.debug("Call MasterLogRepository Count()"); + logger.debug("Call MasterLogRepository Count()"); return jdbcTemplate.queryForObject("select count(*) from master_log", Long.class); } public void startFluxReads() { - log.info("Iniziato Flusso in lettura"); + logger.info("Iniziato Flusso in lettura"); jdbcTemplate.update("INSERT INTO master_log (codice_flusso, tabelle, operazione, data_inizio_oper) " + "VALUES ('epas','anagrafico,mail,telefoni,gruppi','L',current_timestamp)"); - log.info("Flusso in lettura aperto"); + logger.info("Flusso in lettura aperto"); } public void closeFluxReads(String tabelleLette) throws Exception { - log.info("Chiusura Flusso in lettura"); - log.info("Tabelle Lette: {}", tabelleLette); + logger.info("Chiusura Flusso in lettura"); + logger.info("Tabelle Lette: {}", tabelleLette); if (tabelleLette.isEmpty()) { tabelleLette = " "; } @@ -57,64 +57,64 @@ public class SIMasterLogRepository { return idFlusso; } }); - log.info("Flusso da chiudere: {}", idsFlux); + logger.info("Flusso da chiudere: {}", idsFlux); if (idsFlux != null && !idsFlux.isEmpty()) { jdbcTemplate.update("UPDATE master_log SET data_fine_oper=current_timestamp, tabelle='" + tabelleLette + "', esito_oper='OK' WHERE codice_flusso='epas' AND id_flusso=" + idsFlux.get(0) + " "); - log.info("Flusso in lettura chiuso"); + logger.info("Flusso in lettura chiuso"); } else { - log.error("Flusso da chiudere non trovato: {}", idsFlux); + logger.error("Flusso da chiudere non trovato: {}", idsFlux); throw new Exception("Errore chiudendo il flusso di lettura, id: "+idsFlux); } } public Long startFluxWrites() throws Exception { - log.info("Iniziato Flusso in scrittura"); + logger.info("Iniziato Flusso in scrittura"); jdbcTemplate.update("INSERT INTO master_log (codice_flusso, tabelle, operazione, data_inizio_oper) \"\n" + " + \"VALUES ('epas','cartellini, cartellini_rendicontazioni, festivita, pers_orario, lavoro_fuori_sede','S',current_timestamp)"); - log.info("Flusso in scrittura aperto"); + logger.info("Flusso in scrittura aperto"); String query = "SELECT id_flusso FROM master_log" + " WHERE codice_flusso='epas' AND operazione='S'" + " AND data_fine_oper IS NULL" + " ORDER BY id_flusso DESC"; - List idsFlux = jdbcTemplate.query(query, new RowMapper() { + List fluxIds = jdbcTemplate.query(query, new RowMapper() { @Override public Long mapRow(ResultSet rs, int rowNum) throws SQLException { Long idFlusso = rs.getLong("id_flusso"); return idFlusso; } }); - Long idFlux = 0l; - if (idsFlux != null && !idsFlux.isEmpty()) { - idFlux = idsFlux.get(0); - log.info("Flusso in scrittura id: {}", idFlux); + Long fluxId = 0l; + if (fluxIds != null && !fluxIds.isEmpty()) { + fluxId = fluxIds.get(0); + logger.info("Flusso in scrittura id: {}", fluxId); } else { - log.error("Errore inizializando il flusso di scrittura, id: {}",idsFlux); - throw new Exception("Errore inizializando il flusso di scrittura, id: "+idsFlux); + logger.error("Errore inizializando il flusso di scrittura, id: {}",fluxIds); + throw new Exception("Errore inizializando il flusso di scrittura, id: "+fluxIds); } - return idFlux; + return fluxId; } - public void closeFluxWrites(Long idFlux, String tabelleScritte) { - log.info("Chiusura Flusso in scrittura"); - log.info("Tabelle Scritte: {}", tabelleScritte); + public void closeFluxWrites(Long fluxId, String tabelleScritte) { + logger.info("Chiusura Flusso in scrittura"); + logger.info("Tabelle Scritte: {}", tabelleScritte); if (tabelleScritte.isEmpty()) { tabelleScritte = " "; } - if (idFlux != null && idFlux.longValue() != 0) { + if (fluxId != null && fluxId.longValue() != 0) { jdbcTemplate.update("UPDATE master_log SET data_fine_oper=current_timestamp, tabelle='" + tabelleScritte - + "', esito_oper='OK' WHERE codice_flusso='epas' AND id_flusso=" + idFlux + " "); + + "', esito_oper='OK' WHERE codice_flusso='epas' AND id_flusso=" + fluxId + " "); - log.info("Flusso in scrittura chiuso"); + logger.info("Flusso in scrittura chiuso"); } else { - log.info("Flusso in scrittura da chiudere non trovato: {}", idFlux); + logger.info("Flusso in scrittura da chiudere non trovato: {}", fluxId); } } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIOrarioRepository.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIOrarioRepository.java new file mode 100644 index 0000000..3c2b57d --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIOrarioRepository.java @@ -0,0 +1,37 @@ +package it.cnr.isti.epasmed.sistemainformativo.repository; + +import javax.sql.DataSource; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Repository; + +import it.cnr.isti.epasmed.sistemainformativo.model.SIOrario; + +@Repository +public class SIOrarioRepository { + + private static final Logger logger = LoggerFactory.getLogger(SIOrarioRepository.class); + + private JdbcTemplate jdbcTemplate; + + // + public SIOrarioRepository( + final @Qualifier("sistemaInformativoDataSource") DataSource dataSource) { + super(); + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + public void writeNewFlux(Long fluxId, SIOrario siOrario) { + jdbcTemplate.update( + "INSERT INTO epas_orario (id,descrizione,flag,data_mod,flag_del,id_flusso)" + + " VALUES (?,?,?,?,?,?)", + siOrario.getId(), siOrario.getDescrizione(), + siOrario.getFlag(), siOrario.getData_mod(), + siOrario.getFlag_del(), fluxId); + logger.debug("Writed SIOrario: {}", siOrario); + } + +} diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIPosizioniRepository.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIPosizioniRepository.java index c6bcbd7..50d25d6 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIPosizioniRepository.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIPosizioniRepository.java @@ -18,7 +18,7 @@ import it.cnr.isti.epasmed.sistemainformativo.model.SIPosizioni; @Repository public class SIPosizioniRepository { - private final Logger logger = LoggerFactory.getLogger(SIPosizioniRepository.class); + private static final Logger logger = LoggerFactory.getLogger(SIPosizioniRepository.class); private JdbcTemplate jdbcTemplate; @@ -29,7 +29,6 @@ public class SIPosizioniRepository { } public List readNewFlux(Long flusso) { - logger.info("Read Flux > {}",flusso); String query="select cf, dal, al, matricola, profilo, subprofilo, livello, tipocontratto, " + " motivofinerapportoti, fasciaimportoassegno, data_mod, flag_del,id_flusso, finerapportoti, idpersona, id " + " from posizioni " @@ -60,6 +59,7 @@ public class SIPosizioniRepository { return pos; }}); + logger.debug("Posizioni: {}",posizioni); return posizioni; } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIProrogheRepository.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIProrogheRepository.java index 7642345..8db0564 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIProrogheRepository.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SIProrogheRepository.java @@ -18,7 +18,7 @@ import it.cnr.isti.epasmed.sistemainformativo.model.SIProroghe; @Repository public class SIProrogheRepository { - private final Logger logger = LoggerFactory.getLogger(SIProrogheRepository.class); + private static final Logger logger = LoggerFactory.getLogger(SIProrogheRepository.class); private JdbcTemplate jdbcTemplate; @@ -29,7 +29,6 @@ public class SIProrogheRepository { } public List readNewFlux(Long flusso) { - logger.info("Read Flux > {}",flusso); String query="select cf,posizione_dal, proroga_al, data_mod,flag_del,id_flusso, " + " posizione_al, proroga_dal, id, idposizione" + " from proroghe " @@ -54,6 +53,7 @@ public class SIProrogheRepository { return pro; }}); + logger.debug("Proroghe: {}",proroghe); return proroghe; } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SITelefoniRepository.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SITelefoniRepository.java index 940b994..8a7637b 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SITelefoniRepository.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/repository/SITelefoniRepository.java @@ -18,7 +18,7 @@ import it.cnr.isti.epasmed.sistemainformativo.model.SITelefoni; @Repository public class SITelefoniRepository { - private final Logger logger = LoggerFactory.getLogger(SITelefoniRepository.class); + private static final Logger logger = LoggerFactory.getLogger(SITelefoniRepository.class); private JdbcTemplate jdbcTemplate; @@ -29,7 +29,6 @@ public class SITelefoniRepository { } public List readNewFlux(Long flusso) { - logger.info("Read Flux > {}",flusso); String query="select cf, tiporecapitotelefonico, recapitotelefonico, data_mod, flag_del, id_flusso, id, idpersona " + " from telefoni " + " WHERE id_flusso > " @@ -50,6 +49,7 @@ public class SITelefoniRepository { return t; }}); + logger.debug("Telefoni: {}",telefoni); return telefoni; } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIAnagraficoService.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIAnagraficoService.java index 498f1a0..1c925c4 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIAnagraficoService.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIAnagraficoService.java @@ -19,7 +19,7 @@ import it.cnr.isti.epasmed.sistemainformativo.repository.SIAnagraficoRepository; @Transactional("sistemaInformativoTransactionManager") public class SIAnagraficoService { - private final Logger log = LoggerFactory.getLogger(SIAnagraficoService.class); + private static final Logger logger = LoggerFactory.getLogger(SIAnagraficoService.class); private final SIAnagraficoRepository anagraficoRepository; @@ -28,9 +28,9 @@ public class SIAnagraficoService { this.anagraficoRepository = anagraficoRepository; } - public List readNewFlux(Long flusso) { - log.debug("Request Anagrafico Flux > {}",flusso); - return anagraficoRepository.readNewFlux(flusso); + public List readNewFlux(Long fluxId) { + logger.debug("Request SIAnagrafico Flux > {}",fluxId); + return anagraficoRepository.readNewFlux(fluxId); } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SICartelliniRendicontazioniService.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SICartelliniRendicontazioniService.java new file mode 100644 index 0000000..3347799 --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SICartelliniRendicontazioniService.java @@ -0,0 +1,33 @@ +package it.cnr.isti.epasmed.sistemainformativo.service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import it.cnr.isti.epasmed.sistemainformativo.model.SICartelliniRendicontazioni; +import it.cnr.isti.epasmed.sistemainformativo.repository.SICartelliniRendicontazioniRepository; + +/** + * Service class for managing CartelliniRendicontazioni. + */ +@Service +@Transactional("sistemaInformativoTransactionManager") +public class SICartelliniRendicontazioniService { + + private static final Logger logger = LoggerFactory.getLogger(SICartelliniRendicontazioniService.class); + + private final SICartelliniRendicontazioniRepository siCartelliniRendicontazioniRepository; + + public SICartelliniRendicontazioniService( + SICartelliniRendicontazioniRepository siCartelliniRendicontazioniRepository) { + super(); + this.siCartelliniRendicontazioniRepository = siCartelliniRendicontazioniRepository; + } + + public void writeNewFlux(Long fluxId, SICartelliniRendicontazioni siCartelliniRendicontazioni) { + logger.debug("Write SICartelliniRendicontazioni Flux = {}", fluxId); + siCartelliniRendicontazioniRepository.writeNewFlux(fluxId, siCartelliniRendicontazioni); + } + +} \ No newline at end of file diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SICartelliniService.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SICartelliniService.java new file mode 100644 index 0000000..acfe3da --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SICartelliniService.java @@ -0,0 +1,35 @@ +package it.cnr.isti.epasmed.sistemainformativo.service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import it.cnr.isti.epasmed.sistemainformativo.model.SICartellini; +import it.cnr.isti.epasmed.sistemainformativo.repository.SICartelliniRepository; + + + +/** + * Service class for managing Cartellini. + */ +@Service +@Transactional("sistemaInformativoTransactionManager") +public class SICartelliniService { + + private final Logger log = LoggerFactory.getLogger(getClass()); + + private final SICartelliniRepository siCartelliniRepository; + + public SICartelliniService(SICartelliniRepository siCartelliniRepository) { + super(); + this.siCartelliniRepository = siCartelliniRepository; + } + + public void writeNewFlux(Long fluxId, SICartellini siCartellini) { + log.debug("Write SICartellini Flux = {}",fluxId); + siCartelliniRepository.writeNewFlux(fluxId,siCartellini); + } + + +} \ No newline at end of file diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIEmailService.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIEmailService.java index 5efac2b..c726e41 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIEmailService.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIEmailService.java @@ -19,7 +19,7 @@ import it.cnr.isti.epasmed.sistemainformativo.repository.SIEmailRepository; @Transactional("sistemaInformativoTransactionManager") public class SIEmailService { - private final Logger log = LoggerFactory.getLogger(SIEmailService.class); + private final Logger log = LoggerFactory.getLogger(getClass()); private final SIEmailRepository emailRepository; @@ -28,9 +28,9 @@ public class SIEmailService { this.emailRepository = emailRepository; } - public List readNewFlux(Long flusso) { - log.debug("Request SIEmail Flux > {}",flusso); - return emailRepository.readNewFlux(flusso); + public List readNewFlux(Long fluxId) { + log.debug("Request SIEmail Flux > {}",fluxId); + return emailRepository.readNewFlux(fluxId); } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIGruppiPersService.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIGruppiPersService.java index 969598a..84059d0 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIGruppiPersService.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIGruppiPersService.java @@ -19,7 +19,7 @@ import it.cnr.isti.epasmed.sistemainformativo.repository.SIGruppiPersRepository; @Transactional("sistemaInformativoTransactionManager") public class SIGruppiPersService { - private final Logger log = LoggerFactory.getLogger(SIGruppiPersService.class); + private final Logger log = LoggerFactory.getLogger(getClass()); private final SIGruppiPersRepository gruppiPersRepository; @@ -28,9 +28,9 @@ public class SIGruppiPersService { this.gruppiPersRepository = gruppiPersRepository; } - public List readNewFlux(Long flusso) { - log.debug("Request GruppiPers Flux > {}",flusso); - return gruppiPersRepository.readNewFlux(flusso); + public List readNewFlux(Long fluxId) { + log.debug("Request SIGruppiPers Flux > {}",fluxId); + return gruppiPersRepository.readNewFlux(fluxId); } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIGruppiService.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIGruppiService.java index 5a7855d..fed84c0 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIGruppiService.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIGruppiService.java @@ -19,7 +19,7 @@ import it.cnr.isti.epasmed.sistemainformativo.repository.SIGruppiRepository; @Transactional("sistemaInformativoTransactionManager") public class SIGruppiService { - private final Logger log = LoggerFactory.getLogger(SIGruppiService.class); + private final Logger log = LoggerFactory.getLogger(getClass()); private final SIGruppiRepository gruppiRepository; @@ -28,9 +28,9 @@ public class SIGruppiService { this.gruppiRepository = gruppiRepository; } - public List readNewFlux(Long flusso) { - log.debug("Request Gruppi Flux > {}",flusso); - return gruppiRepository.readNewFlux(flusso); + public List readNewFlux(Long fluxId) { + log.debug("Request SIGruppi Flux > {}",fluxId); + return gruppiRepository.readNewFlux(fluxId); } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIMasterLogService.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIMasterLogService.java index ebbc4cc..690d53c 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIMasterLogService.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIMasterLogService.java @@ -45,8 +45,8 @@ public class SIMasterLogService { return masterLogRepository.startFluxWrites(); } - public void closeFluxWrites(Long idFlusso,String tabelleScritte) { + public void closeFluxWrites(Long fluxId,String tabelleScritte) { log.debug("Request Close Flux Writes"); - masterLogRepository.closeFluxWrites(idFlusso,tabelleScritte); + masterLogRepository.closeFluxWrites(fluxId,tabelleScritte); } } \ No newline at end of file diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIOrarioService.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIOrarioService.java new file mode 100644 index 0000000..e8e5125 --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIOrarioService.java @@ -0,0 +1,35 @@ +package it.cnr.isti.epasmed.sistemainformativo.service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import it.cnr.isti.epasmed.sistemainformativo.model.SIOrario; +import it.cnr.isti.epasmed.sistemainformativo.repository.SIOrarioRepository; + + + +/** + * Service class for managing Orario. + */ +@Service +@Transactional("sistemaInformativoTransactionManager") +public class SIOrarioService { + + private static final Logger log = LoggerFactory.getLogger(SIOrarioService.class); + + private final SIOrarioRepository siOrarioRepository; + + public SIOrarioService(SIOrarioRepository siOrarioRepository) { + super(); + this.siOrarioRepository = siOrarioRepository; + } + + public void writeNewFlux(Long fluxId, SIOrario siOrario) { + log.debug("Write SIOrario Flux = {}",fluxId); + siOrarioRepository.writeNewFlux(fluxId,siOrario); + } + + +} \ No newline at end of file diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIPosizioniService.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIPosizioniService.java index c999a5a..280b27c 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIPosizioniService.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIPosizioniService.java @@ -28,9 +28,9 @@ public class SIPosizioniService { this.posizioniRepository = posizioniRepository; } - public List readNewFlux(Long flusso) { - log.debug("Request Posizioni Flux > {}",flusso); - return posizioniRepository.readNewFlux(flusso); + public List readNewFlux(Long fluxId) { + log.debug("Request SIPosizioni Flux > {}",fluxId); + return posizioniRepository.readNewFlux(fluxId); } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIProrogheService.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIProrogheService.java index 7a4b5e6..e998b3d 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIProrogheService.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SIProrogheService.java @@ -28,9 +28,9 @@ public class SIProrogheService { this.prorogheRepository = prorogheRepository; } - public List readNewFlux(Long flusso) { - log.debug("Request Proroghe Flux > {}",flusso); - return prorogheRepository.readNewFlux(flusso); + public List readNewFlux(Long fluxId) { + log.debug("Request SIProroghe Flux > {}",fluxId); + return prorogheRepository.readNewFlux(fluxId); } diff --git a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SITelefoniService.java b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SITelefoniService.java index ac4be44..118b06e 100644 --- a/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SITelefoniService.java +++ b/src/main/java/it/cnr/isti/epasmed/sistemainformativo/service/SITelefoniService.java @@ -28,9 +28,9 @@ public class SITelefoniService { this.telefoniRepository = telefoniRepository; } - public List readNewFlux(Long flusso) { - log.debug("Request Telefoni Flux > {}",flusso); - return telefoniRepository.readNewFlux(flusso); + public List readNewFlux(Long fluxId) { + log.debug("Request SITelefoni Flux > {}",fluxId); + return telefoniRepository.readNewFlux(fluxId); } diff --git a/src/main/java/it/cnr/isti/epasmed/sync/SyncService.java b/src/main/java/it/cnr/isti/epasmed/sync/SyncService.java index efbe556..fe2e7a0 100644 --- a/src/main/java/it/cnr/isti/epasmed/sync/SyncService.java +++ b/src/main/java/it/cnr/isti/epasmed/sync/SyncService.java @@ -1,9 +1,10 @@ package it.cnr.isti.epasmed.sync; +import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.time.LocalDateTime; +import java.time.YearMonth; import java.util.Date; -import java.util.GregorianCalendar; import java.util.List; import java.util.Optional; @@ -20,8 +21,10 @@ import it.cnr.isti.epasmed.epas.dto.EPASPersonsDTO; import it.cnr.isti.epasmed.epas.mapper.EPASAffiliationsMapper; import it.cnr.isti.epasmed.epas.mapper.EPASGroupsMapper; import it.cnr.isti.epasmed.epas.mapper.EPASPersonsMapper; +import it.cnr.isti.epasmed.epas.model.EPASAbsences; import it.cnr.isti.epasmed.epas.model.EPASAffiliations; import it.cnr.isti.epasmed.epas.model.EPASGroups; +import it.cnr.isti.epasmed.epas.model.EPASPersonDays; import it.cnr.isti.epasmed.epas.model.EPASPersons; import it.cnr.isti.epasmed.epas.model.EPASTimeCards; import it.cnr.isti.epasmed.epas.model.EPASValidates; @@ -33,11 +36,15 @@ import it.cnr.isti.epasmed.epas.service.EPASValidatesService; import it.cnr.isti.epasmed.service.TabsSIService; import it.cnr.isti.epasmed.service.TimeCardsReportingService; import it.cnr.isti.epasmed.sistemainformativo.model.SIAnagrafico; +import it.cnr.isti.epasmed.sistemainformativo.model.SICartellini; +import it.cnr.isti.epasmed.sistemainformativo.model.SICartelliniRendicontazioni; import it.cnr.isti.epasmed.sistemainformativo.model.SIEmail; import it.cnr.isti.epasmed.sistemainformativo.model.SIGruppi; import it.cnr.isti.epasmed.sistemainformativo.model.SIGruppiPers; import it.cnr.isti.epasmed.sistemainformativo.model.SITelefoni; import it.cnr.isti.epasmed.sistemainformativo.service.SIAnagraficoService; +import it.cnr.isti.epasmed.sistemainformativo.service.SICartelliniRendicontazioniService; +import it.cnr.isti.epasmed.sistemainformativo.service.SICartelliniService; import it.cnr.isti.epasmed.sistemainformativo.service.SIEmailService; import it.cnr.isti.epasmed.sistemainformativo.service.SIGruppiPersService; import it.cnr.isti.epasmed.sistemainformativo.service.SIGruppiService; @@ -55,7 +62,7 @@ public class SyncService { private static final String SI_TIPO_EMAIL_ISTITUZIONALE = "Istituzionale"; private static final String SI_TIPO_EMAIL_CNR = "C.N.R."; - private final Logger log = LoggerFactory.getLogger(SyncService.class); + private static final Logger logger = LoggerFactory.getLogger(SyncService.class); private final SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd"); @Autowired TabsSIService tabsSIService; @@ -74,6 +81,10 @@ public class SyncService { SIGruppiService siGruppiService; @Autowired SIGruppiPersService siGruppiPersService; + @Autowired + SICartelliniService siCartelliniService; + @Autowired + SICartelliniRendicontazioniService siCartelliniRendicontazioniService; @Autowired EPASPersonsService epasPersonsService; @@ -127,9 +138,9 @@ public class SyncService { baspettative = false; List tabsSI = tabsSIService.getAllTabsSI(); - Long idFlux = siMasterLogService.startFluxWrites(); - writeData(idFlux, tabsSI); - siMasterLogService.closeFluxWrites(idFlux, writeTabs()); + Long fluxId = siMasterLogService.startFluxWrites(); + writeData(fluxId, tabsSI); + siMasterLogService.closeFluxWrites(fluxId, writeTabs()); } @@ -137,7 +148,7 @@ public class SyncService { // TabsSI posizioniTab = null; // TabsSI prorogheTab = null; for (TabsSI tab : tabsSI) { - log.info("TabSI: {}", tab); + logger.info("TabSI: {}", tab); if (tab.getOperazioni() != null && !tab.getOperazioni().isEmpty() && tab.getOperazioni().compareTo("R") == 0) { if (tab.getNome() == null || tab.getNome().isEmpty()) { @@ -178,7 +189,7 @@ public class SyncService { private void syncAnagrafico(TabsSI tab) { if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) { - log.error("Invalid Id Flusso for tab: {}", tab); + logger.error("Invalid Id Flusso for tab: {}", tab); return; } long maxIdFlusso = 0; @@ -199,13 +210,13 @@ public class SyncService { epasPersonsDTO.setSurname(sia.getCognome()); epasPersonsDTO.setOfficeId(ISTI_OFFICE_ID); epasPerson = epasPersonsService.create(epasPersonsDTO); - log.info("EPAS Created Person: {}", epasPerson); + logger.info("EPAS Created Person: {}", epasPerson); } else { EPASPersonsDTO epasPersonsDTO = epasPersonsMapper.epasPersonsToEPASPersonsDTO(epasPerson); epasPersonsDTO.setName(sia.getNome()); epasPersonsDTO.setSurname(sia.getCognome()); epasPersonsService.updateByFiscalCode(epasPersonsDTO.getFiscalCode(), epasPersonsDTO); - log.info("EPAS Updated Person: {}", epasPersonsDTO); + logger.info("EPAS Updated Person: {}", epasPersonsDTO); } } } @@ -224,7 +235,7 @@ public class SyncService { private void syncMail(TabsSI tab) { if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) { - log.error("Invalid Id Flusso for tab: {}", tab); + logger.error("Invalid Id Flusso for tab: {}", tab); return; } long maxIdFlusso = 0; @@ -257,7 +268,7 @@ public class SyncService { epasPersonsDTO.setEppn(se.getEmail()); epasPersonsService.updateByFiscalCode(epasPersonsDTO.getFiscalCode(), epasPersonsDTO); - log.info("EPAS Updated Person: {}", epasPersonsDTO); + logger.info("EPAS Updated Person: {}", epasPersonsDTO); break; default: break; @@ -282,7 +293,7 @@ public class SyncService { private void syncTelefoni(TabsSI tab) { if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) { - log.info("Invalid Id Flusso for tab: {}", tab); + logger.info("Invalid Id Flusso for tab: {}", tab); return; } long maxIdFlusso = 0; @@ -306,7 +317,7 @@ public class SyncService { epasPersonsDTO.setTelephone(sit.getRecapitotelefonico()); epasPersonsService.updateByFiscalCode(epasPersonsDTO.getFiscalCode(), epasPersonsDTO); - log.info("EPAS Updated Person: {}", epasPersonsDTO); + logger.info("EPAS Updated Person: {}", epasPersonsDTO); } } } @@ -328,7 +339,7 @@ public class SyncService { private void syncGruppi(TabsSI tab) { if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) { - log.info("Invalid Id Flusso for tab: {}", tab); + logger.info("Invalid Id Flusso for tab: {}", tab); return; } long maxIdFlusso = 0; @@ -355,20 +366,20 @@ public class SyncService { EPASGroupsDTO epasGroupsDTO = new EPASGroupsDTO(sig.getDescrizione(), null, String.valueOf(sig.getId()), null, null, sig.getSigla(), ISTI_OFFICE_ID); EPASGroups epasGroup = epasGroupsService.create(epasGroupsDTO); - log.info("EPAS Created Group: {}", epasGroup); + logger.info("EPAS Created Group: {}", epasGroup); } else { EPASGroupsMapper epasGroupsMapper = new EPASGroupsMapper(); EPASGroupsDTO epasGroupsDTO = epasGroupsMapper.epasGroupsToEPASGroupsDTO(groupPresent); epasGroupsDTO.setDescription(sig.getDescrizione()); epasGroupsDTO.setName(sig.getSigla()); epasGroupsService.updateById(groupPresent.getId(), epasGroupsDTO); - log.info("EPAS Updated Group: {}", epasGroupsDTO); + logger.info("EPAS Updated Group: {}", epasGroupsDTO); } } else { EPASGroupsDTO epasGroupsDTO = new EPASGroupsDTO(sig.getDescrizione(), null, String.valueOf(sig.getId()), null, null, sig.getSigla(), ISTI_OFFICE_ID); EPASGroups epasGroup = epasGroupsService.create(epasGroupsDTO); - log.info("EPAS Created Group: {}", epasGroup); + logger.info("EPAS Created Group: {}", epasGroup); } } else { List epasGroups = epasGroupsService.getList(ISTI_OFFICE_ID); @@ -390,7 +401,7 @@ public class SyncService { EPASGroupsDTO epasGroupsDTO = epasGroupsMapper .epasGroupsToEPASGroupsDTO(groupPresent); epasGroupsService.updateById(groupPresent.getId(), epasGroupsDTO); - log.info("EPAS Delete Group: {}", epasGroupsDTO); + logger.info("EPAS Delete Group: {}", epasGroupsDTO); } } } @@ -411,7 +422,7 @@ public class SyncService { private void syncGruppoPers(TabsSI tab) { if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) { - log.info("Invalid Id Flusso for tab: {}", tab); + logger.info("Invalid Id Flusso for tab: {}", tab); return; } long maxIdFlusso = 0; @@ -452,7 +463,7 @@ public class SyncService { groupPresent.getId(), null, String.valueOf(sigp.getPercentuale()), epasPerson.getId(), String.valueOf(sigp.getId())); epasAffiliationsService.updateById(affPresent.getId(), epasAffiliationsDTO); - log.info("EPAS Updated Affilation: {}", epasAffiliationsDTO); + logger.info("EPAS Updated Affilation: {}", epasAffiliationsDTO); } @@ -477,7 +488,7 @@ public class SyncService { epasPerson.getId(), String.valueOf(sigp.getId())); EPASAffiliations epasAffiliationNew = epasAffiliationsService .create(epasAffiliationsDTO); - log.info("EPAS Created Affilation: {}", epasAffiliationNew); + logger.info("EPAS Created Affilation: {}", epasAffiliationNew); } @@ -503,7 +514,7 @@ public class SyncService { epasPerson.getId(), String.valueOf(sigp.getId())); EPASAffiliations epasAffiliationNew = epasAffiliationsService .create(epasAffiliationsDTO); - log.info("EPAS Created Affilation: {}", epasAffiliationNew); + logger.info("EPAS Created Affilation: {}", epasAffiliationNew); } @@ -522,11 +533,12 @@ public class SyncService { } } if (affPresent != null) { - EPASAffiliationsMapper epasAffiliationsMapper=new EPASAffiliationsMapper(); - EPASAffiliationsDTO epasAffiliationsDTO=epasAffiliationsMapper.epasAffiliationsToEPASAffiliationsDTO(affPresent); + EPASAffiliationsMapper epasAffiliationsMapper = new EPASAffiliationsMapper(); + EPASAffiliationsDTO epasAffiliationsDTO = epasAffiliationsMapper + .epasAffiliationsToEPASAffiliationsDTO(affPresent); epasAffiliationsDTO.setEndDate(sdfDate.format(sigp.getAl())); epasAffiliationsService.updateById(affPresent.getId(), epasAffiliationsDTO); - log.info("EPAS Delete Affilation: {}", epasAffiliationsDTO); + logger.info("EPAS Delete Affilation: {}", epasAffiliationsDTO); } } } @@ -642,13 +654,13 @@ public class SyncService { } return writeTabs; } - - private void writeData(Long idFlux, List tabsSI) { - //TabsSI caretelliniRendicontazioniTab = null; - //TabsSI cartelliniTab = null; + + private void writeData(Long fluxId, List tabsSI) { + // TabsSI caretelliniRendicontazioniTab = null; + // TabsSI cartelliniTab = null; for (TabsSI tab : tabsSI) { - log.info("TabSI: {}", tab); + logger.info("TabSI: {}", tab); if (tab.getOperazioni() != null && !tab.getOperazioni().isEmpty() && tab.getOperazioni().compareTo("W") == 0) { if (tab.getNome() == null || tab.getNome().isEmpty()) { @@ -656,16 +668,16 @@ public class SyncService { } switch (tab.getNome()) { - // case "orario": - // syncOrario(idFlux,tab); - // break; + case "orario": + syncOrario(fluxId,tab); + break; // case "pers_orario": // syncPersOrario(idFlux,tab); // break; case "cartellini": break; case "cartellini_rendicontazioni": - syncCartelliniRendicontazioni(idFlux, tab); + syncCartelliniRendicontazioni(fluxId, tab); break; // case "lavoro_fuori_sede": // syncLavoroFuoriSede(idFlux,tab); @@ -681,37 +693,111 @@ public class SyncService { } } - private void syncCartelliniRendicontazioni(Long idFlux, TabsSI tab) { + private void syncOrario(Long fluxId, TabsSI tab) { if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) { - log.error("Invalid Id Flusso for tab: {}", tab); + logger.error("Invalid Id Flusso for tab: {}", tab); return; } - long maxIdFlusso = 0; - GregorianCalendar lastMonthSent = new GregorianCalendar(2021, 11, 1); - Optional lastTcR=timeCardsReportingService.getLastTimeCardsReporting(); - if(!lastTcR.isPresent()) { - log.error("Invalid TimeCardsReporting start point: {}", tab); + + } + + private void syncCartelliniRendicontazioni(Long fluxId, TabsSI tab) { + if (tab.getIdFlusso() == null || tab.getIdFlusso().longValue() == 0) { + logger.error("Invalid Id Flusso for tab: {}", tab); return; } - GregorianCalendar nextMonthToSent = new GregorianCalendar(); - nextMonthToSent.setTime(lastMonthSent.getTime()); - nextMonthToSent.add(GregorianCalendar.MONTH, 1); - String y = String.valueOf(nextMonthToSent.get(GregorianCalendar.YEAR)); - String m = String.valueOf(nextMonthToSent.get(GregorianCalendar.YEAR)); - EPASValidates epasValidates = epasValidatesService.getValidatesByOfficeCodeId(ISTI_OFFICE_CODEID, y, m); + + Optional lastTcR = timeCardsReportingService.getLastTimeCardsReporting(); + if (!lastTcR.isPresent()) { + logger.error("Invalid TimeCardsReporting start point: {}", tab); + return; + } + Integer year = lastTcR.get().getYear(); + Integer month = lastTcR.get().getMonth(); + + YearMonth nextMonthToSent = YearMonth.of(year, month); + nextMonthToSent = nextMonthToSent.plusMonths(1); + + EPASValidates epasValidates = epasValidatesService.getValidatesByOfficeCodeId(ISTI_OFFICE_CODEID, + String.valueOf(nextMonthToSent.getYear()), String.valueOf(nextMonthToSent.getMonthValue())); if (!epasValidates.getAllCertificationsValidated()) { - log.info("No new month closed on EPAS: [year={}, month={}]", y, m); + logger.info("No new month closed on EPAS: {}", nextMonthToSent); return; } - log.info("Certifications Validated: [year={}, month={}]", y, m); - for (EPASPersons person : epasValidates.getValidatedPersons()) { - log.info("Writing TimeCard for Person: {}", person); - EPASTimeCards epasTimeCards = epasTimeCardsService.getTimeCardByPersonEmail(person.getEmail(), y, m); - } + logger.info("Certifications Validated: {}", nextMonthToSent); + // Set Update DateTime + LocalDateTime now = LocalDateTime.now(); + Timestamp dataMod = Timestamp.valueOf(now); + // EPASMed + TimeCardsReporting timeCardsReporting = new TimeCardsReporting(); + timeCardsReporting.setYear(nextMonthToSent.getYear()); + timeCardsReporting.setMonth(nextMonthToSent.getMonthValue()); + timeCardsReporting.setIdFlusso(fluxId); + timeCardsReporting.setLastUpdate(now); + + timeCardsReporting = timeCardsReportingService.createTimeCardsReporting(timeCardsReporting); + + // SI + for (EPASPersons person : epasValidates.getValidatedPersons()) { + logger.info("Writing TimeCard for Person: {}", person); + EPASTimeCards epasTimeCards = epasTimeCardsService.getTimeCardByPersonFiscalCode(person.getFiscalCode(), + String.valueOf(nextMonthToSent.getYear()), String.valueOf(nextMonthToSent.getMonthValue())); + + EPASPersons epasPerson = epasTimeCards.getPerson(); + Integer personId = Integer.valueOf(epasPerson.getId()); + + for (EPASPersonDays epasPersonDay : epasTimeCards.getPersonDays()) { + Long id = Long.valueOf(epasPersonDay.getId()); + + StringBuilder motivo = new StringBuilder(); + if (epasPersonDay.getIsHoliday()) { + motivo.append("[Festivo]"); + } + if (epasPersonDay.getAbsences() != null && epasPersonDay.getAbsences().length > 0) { + for (EPASAbsences epasAbsences : epasPersonDay.getAbsences()) { + motivo.append("["); + motivo.append(epasAbsences.getJustifiedType()); + motivo.append("-"); + motivo.append(epasAbsences.getJustifiedTime()); + motivo.append("-"); + motivo.append(epasAbsences.getNote()); + motivo.append("]"); + } + } + + java.sql.Date date = null; + try { + date = java.sql.Date.valueOf(epasPersonDay.getDate()); + } catch (Exception e) { + logger.error("Invalid date format: {}", epasPersonDay.getDate()); + break; + } + + SICartellini siCartellini = new SICartellini(id, personId, epasPerson.getFiscalCode(), date, + motivo.toString(), epasPersonDay.getTimeAtWork(), epasPersonDay.getDifference(), dataMod, "0", + fluxId); + siCartelliniService.writeNewFlux(fluxId, siCartellini); + } + + } + logger.info("SICartellini Updated"); + + SICartelliniRendicontazioni siCartelliniRendicontazioni = new SICartelliniRendicontazioni( + timeCardsReporting.getId(), timeCardsReporting.getYear(), timeCardsReporting.getMonth(), + Timestamp.valueOf(timeCardsReporting.getLastUpdate()), "0", fluxId); + siCartelliniRendicontazioniService.writeNewFlux(fluxId, siCartelliniRendicontazioni); + logger.info("SICartelliniRendicontazioni Updated"); + + bcartellini_rendicontazioni = true; + bcartellini=true; + tab.setIdFlusso(fluxId); + tab.setLastUpdate(LocalDateTime.now()); + tabsSIService.updateTabsSI(tab); + } } diff --git a/src/main/java/it/cnr/isti/epasmed/web/rest/SyncResource.java b/src/main/java/it/cnr/isti/epasmed/web/rest/SyncResource.java index 7c88e6a..26cdecc 100644 --- a/src/main/java/it/cnr/isti/epasmed/web/rest/SyncResource.java +++ b/src/main/java/it/cnr/isti/epasmed/web/rest/SyncResource.java @@ -7,7 +7,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -27,19 +27,19 @@ import it.cnr.isti.epasmed.sync.SyncService; @RequestMapping("/api") public class SyncResource { - private final Logger log = LoggerFactory.getLogger(SyncResource.class); + private static final Logger logger = LoggerFactory.getLogger(SyncResource.class); @Value("${jhipster.clientApp.name}") private String applicationName; - private final SyncService syncReads; + private final SyncService syncService; - public SyncResource(SyncService syncReads) { - this.syncReads = syncReads; + public SyncResource(SyncService syncService) { + this.syncService = syncService; } /** - * {@code POST /sync/reads} : Retrieve new flux from Sistema Informativo and + * {@code GET /sync/reads} : Retrieve new flux from Sistema Informativo and * update ePAS. * * @return the {@link ResponseEntity} with status {@code 201 (Executed)} @@ -47,24 +47,52 @@ public class SyncResource { * */ - @PostMapping("/sync/reads") + @GetMapping("/sync/reads") @PreAuthorize("hasAuthority(\"" + AuthoritiesConstants.ADMIN + "\")") public ResponseEntity syncReads() throws URISyntaxException { - log.info("REST request syncReads()"); + logger.info("REST request syncReads()"); ResponseEntity res; try { - syncReads.executeReads(); - log.info("Sincronizzazione delle Letture eseguita correttamente."); + syncService.executeReads(); + logger.info("Sincronizzazione delle Letture eseguita correttamente."); res=ResponseEntity.noContent().headers(HeaderUtil.createAlert(applicationName, "Sincronizzazione delle letture eseguita corretamente.","")).build(); } catch (Throwable e) { - log.error("Errore nella sincronizzazione delle letture: {}", e.getLocalizedMessage(), e); + logger.error("Errore nella sincronizzazione delle letture: {}", e.getLocalizedMessage(), e); res=ResponseEntity.noContent().headers(HeaderUtil.createAlert(applicationName, "Errore nella sincronizzazione delle letture: {}", e.getLocalizedMessage())).build(); } - return res; - - + return res; } + + /** + * {@code GET /sync/writes} : Retrieve new flux from ePAS and + * update SistemaInformativo. + * + * @return the {@link ResponseEntity} with status {@code 201 (Executed)} + * or with status {@code 400 (Bad Request)} if there is a error. + * + + */ + @GetMapping("/sync/writes") + @PreAuthorize("hasAuthority(\"" + AuthoritiesConstants.ADMIN + "\")") + public ResponseEntity syncWrites() throws URISyntaxException { + logger.info("REST request syncWrites)"); + ResponseEntity res; + try { + syncService.executeWrites(); + String msg="Sincronizzazione delle scritture eseguita correttamente."; + logger.info(msg); + res=ResponseEntity.noContent().headers(HeaderUtil.createAlert(applicationName, + msg,"")).build(); + + } catch (Throwable e) { + logger.error("Errore nella sincronizzazione delle scritture: {}", e.getLocalizedMessage(), e); + res=ResponseEntity.noContent().headers(HeaderUtil.createAlert(applicationName, + "Errore nella sincronizzazione delle scritture: {}", e.getLocalizedMessage())).build(); + } + return res; + } + } diff --git a/src/main/java/it/cnr/isti/epasmed/web/rest/epas/EPASPersonsResource.java b/src/main/java/it/cnr/isti/epasmed/web/rest/epas/EPASPersonsResource.java index 7107864..cfa205a 100644 --- a/src/main/java/it/cnr/isti/epasmed/web/rest/epas/EPASPersonsResource.java +++ b/src/main/java/it/cnr/isti/epasmed/web/rest/epas/EPASPersonsResource.java @@ -41,8 +41,8 @@ public class EPASPersonsResource { private final EPASPersonsService epasPersonsService; - public EPASPersonsResource(EPASPersonsService epasPersonsServiceService) { - this.epasPersonsService = epasPersonsServiceService; + public EPASPersonsResource(EPASPersonsService epasPersonsService) { + this.epasPersonsService = epasPersonsService; } @@ -98,7 +98,7 @@ public class EPASPersonsResource { *

* Creates a new persons if the id is not already used. * - * @param epasPersonsDTO the user to create. + * @param epasPersonsDTO the person to create. * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with * body the new ePAS Person, or with status {@code 400 (Bad Request)} if * the id is already in use. diff --git a/src/main/java/it/cnr/isti/epasmed/web/rest/epas/EPASStampingsResource.java b/src/main/java/it/cnr/isti/epasmed/web/rest/epas/EPASStampingsResource.java new file mode 100644 index 0000000..be961b2 --- /dev/null +++ b/src/main/java/it/cnr/isti/epasmed/web/rest/epas/EPASStampingsResource.java @@ -0,0 +1,89 @@ +package it.cnr.isti.epasmed.web.rest.epas; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Optional; + +import javax.validation.Valid; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +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.dto.EPASStampingsDTO; +import it.cnr.isti.epasmed.epas.model.EPASStampings; +import it.cnr.isti.epasmed.epas.service.EPASStampingsService; +import it.cnr.isti.epasmed.security.AuthoritiesConstants; +import it.cnr.isti.epasmed.web.rest.errors.BadRequestAlertException; + +@RestController +@RequestMapping("/api/epas") +public class EPASStampingsResource { + + private final Logger log = LoggerFactory.getLogger(getClass()); + + @Value("${jhipster.clientApp.name}") + private String applicationName; + + private final EPASStampingsService epasStampingsService; + + public EPASStampingsResource(EPASStampingsService epasStampingsService) { + this.epasStampingsService = epasStampingsService; + + } + + /** + * {@code GET /stampings/:id} : get stampings by id. + * + * @param id the id of the stampings to find. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body + * the EPAS Stampings, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/stampings/{id}") + public ResponseEntity getEPASStampingsById(@PathVariable String id) { + log.info("REST request to get ePAS Stampings by Id: {}", id); + EPASStampings epasStampings = epasStampingsService.getById(id); + log.info("Retrieved Stampings: {}", epasStampings); + return ResponseUtil.wrapOrNotFound(Optional.of(epasStampings)); + + } + + /** + * {@code POST /stampings} : Creates a new stampings. + *

+ * Creates a new stampings. + * + * @param epasStampingsDTO the stamping to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with + * body the new ePAS Stamping, or with status {@code 400 (Bad Request)} if + * the id is already in use. + * @throws URISyntaxException if the Location URI syntax is incorrect. + * @throws BadRequestAlertException {@code 400 (Bad Request)} if the id is + * already in use. + */ + @PostMapping("/stampings") + @PreAuthorize("hasAuthority(\"" + AuthoritiesConstants.ADMIN + "\")") + public ResponseEntity createEPASStampings(@Valid @RequestBody EPASStampingsDTO epasStampingsDTO) + throws URISyntaxException { + log.debug("REST request to create EPAS Stamping: {}", epasStampingsDTO); + + EPASStampings createdEPASStampings = epasStampingsService.create(epasStampingsDTO); + return ResponseEntity.created(new URI("/api/epas/stampings/" + createdEPASStampings.getId())) + .headers(HeaderUtil.createAlert(applicationName, + "A ePAS Stampings is created with identifier " + createdEPASStampings.getId(), + createdEPASStampings.getId())) + .body(createdEPASStampings); + + } + +} diff --git a/src/main/webapp/app/app-routing.module.ts b/src/main/webapp/app/app-routing.module.ts index 06e6829..93856f6 100644 --- a/src/main/webapp/app/app-routing.module.ts +++ b/src/main/webapp/app/app-routing.module.ts @@ -29,6 +29,10 @@ const LAYOUT_ROUTES = [navbarRoute, ...errorRoute]; path: 'entities', loadChildren: () => import('./entities/entity.module').then(m => m.EpasmedEntityModule), }, + { + path: 'operations', + loadChildren: () => import('./operations/operations.module').then(m => m.EpasmedOperationsModule), + }, ...LAYOUT_ROUTES, ], diff --git a/src/main/webapp/app/app.module.ts b/src/main/webapp/app/app.module.ts index c8a0556..d3f53ff 100644 --- a/src/main/webapp/app/app.module.ts +++ b/src/main/webapp/app/app.module.ts @@ -7,6 +7,7 @@ import { EpasmedCoreModule } from 'app/core/core.module'; import { EpasmedAppRoutingModule } from './app-routing.module'; import { EpasmedHomeModule } from './home/home.module'; import { EpasmedEntityModule } from './entities/entity.module'; +import { EpasmedOperationsModule } from './operations/operations.module'; // jhipster-needle-angular-add-module-import JHipster will add new module here import { MainComponent } from './layouts/main/main.component'; import { NavbarComponent } from './layouts/navbar/navbar.component'; @@ -22,6 +23,7 @@ import { ErrorComponent } from './layouts/error/error.component'; EpasmedHomeModule, // jhipster-needle-angular-add-module JHipster will add new module here EpasmedEntityModule, + EpasmedOperationsModule, EpasmedAppRoutingModule, ], declarations: [MainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, FooterComponent], diff --git a/src/main/webapp/app/layouts/navbar/navbar.component.html b/src/main/webapp/app/layouts/navbar/navbar.component.html index 5669414..158b954 100644 --- a/src/main/webapp/app/layouts/navbar/navbar.component.html +++ b/src/main/webapp/app/layouts/navbar/navbar.component.html @@ -41,6 +41,22 @@ +