diff --git a/pom.xml b/pom.xml index 1f6920b..a1db126 100644 --- a/pom.xml +++ b/pom.xml @@ -67,12 +67,12 @@ runtime true - - org.springframework.boot - spring-boot-docker-compose - runtime - true - + + + + + + com.oracle.database.jdbc ojdbc11 diff --git a/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/model/DetailLog.java b/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/model/DetailLog.java new file mode 100644 index 0000000..5ea22eb --- /dev/null +++ b/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/model/DetailLog.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2024 Consiglio Nazionale delle Ricerche + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package it.cnr.iit.epas.timesheet.ugovpj.model; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; +import java.time.LocalDate; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +/** + * Modello per il mapping della Tabella Oracle di UGOV-Pj-Timesheet che contiene i tipi + * con i log del passaggio dei dati. + * + * @author Cristian Lucchesi + */ +@NoArgsConstructor +@AllArgsConstructor +@Builder +@ToString +@Data +@Entity +@Table(name = "IE_PJ_MARCATURE_LOGS") +public class DetailLog { + + @Id + @Column(name = "ID_LOG") + private Long id; + + @NotNull + @Column(name = "DATA") + private LocalDate date; + + @NotNull + @Column(name = "ESITO") + private String outcome; + + @Column(name = "NUM_MARCATURE") + private Long numberOfDetails; + +} \ No newline at end of file diff --git a/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/repo/DetailLogRepo.java b/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/repo/DetailLogRepo.java new file mode 100644 index 0000000..cb1b257 --- /dev/null +++ b/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/repo/DetailLogRepo.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2024 Consiglio Nazionale delle Ricerche + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package it.cnr.iit.epas.timesheet.ugovpj.repo; + +import it.cnr.iit.epas.timesheet.ugovpj.model.DetailLog; +import org.springframework.data.jpa.repository.JpaRepository; + +/** + * Repository per l'accesso ai log su tabella del passaggio dei dati. + * + * @author Cristian Lucchesi + */ +public interface DetailLogRepo extends JpaRepository { + //Empty interface +} \ No newline at end of file diff --git a/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/v1/controller/TimesheetController.java b/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/v1/controller/TimesheetController.java index b60efca..8543dd0 100644 --- a/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/v1/controller/TimesheetController.java +++ b/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/v1/controller/TimesheetController.java @@ -29,10 +29,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; - +import it.cnr.iit.epas.timesheet.ugovpj.repo.DetailLogRepo; import it.cnr.iit.epas.timesheet.ugovpj.repo.PersonTimeDetailRepo; import it.cnr.iit.epas.timesheet.ugovpj.repo.TimeDetailTypeRepo; import it.cnr.iit.epas.timesheet.ugovpj.v1.ApiRoutes; +import it.cnr.iit.epas.timesheet.ugovpj.v1.dto.DetailLogDto; import it.cnr.iit.epas.timesheet.ugovpj.v1.dto.DtoToEntityConverter; import it.cnr.iit.epas.timesheet.ugovpj.v1.dto.PersonTimeDetailDto; import it.cnr.iit.epas.timesheet.ugovpj.v1.dto.PersonTimeDetailMapper; @@ -43,6 +44,11 @@ import lombok.val; import lombok.extern.slf4j.Slf4j; +/** + * Controller REST per la visualizzazione delle informazioni presenti + * nelle tabelle Oracle di frontiera. + * + */ @Slf4j @RequestMapping(ApiRoutes.BASE_PATH + "/timesheet") @RestController @@ -51,6 +57,7 @@ public class TimesheetController { private final TimeDetailTypeRepo timeDetailTypeRepo; private final PersonTimeDetailRepo personTimeDetailRepo; + private final DetailLogRepo detailLogRepo; private final PersonTimeDetailMapper mapper; private final DtoToEntityConverter dtoToEntityConverter; @@ -87,4 +94,13 @@ public ResponseEntity create( log.info("Creato Result {}", result); return ResponseEntity.status(HttpStatus.CREATED).body(mapper.convert(result)); } + + @GetMapping("/logs") + public ResponseEntity> logs( + Pageable pageable) { + log.debug("Ricevuta richiesta visualizzazione log in tabella Oracle"); + val details = detailLogRepo.findAll(pageable).map(mapper::convert); + return ResponseEntity.ok().body(details); + } + } \ No newline at end of file diff --git a/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/v1/dto/DetailLogDto.java b/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/v1/dto/DetailLogDto.java new file mode 100644 index 0000000..618a7e9 --- /dev/null +++ b/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/v1/dto/DetailLogDto.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2024 Consiglio Nazionale delle Ricerche + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package it.cnr.iit.epas.timesheet.ugovpj.v1.dto; + +import java.time.LocalDate; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; + +/** + * Dto per esportare via REST i log presenti nella tabella di frontiera Oracle. + * + * @author Cristian Lucchesi + */ +@NoArgsConstructor +@ToString +@Data +public class DetailLogDto { + + private Long id; + private LocalDate date; + private String outcome; + private Long numberOfDetails; + +} \ No newline at end of file diff --git a/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/v1/dto/PersonTimeDetailMapper.java b/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/v1/dto/PersonTimeDetailMapper.java index 2ddffec..d205f16 100644 --- a/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/v1/dto/PersonTimeDetailMapper.java +++ b/src/main/java/it/cnr/iit/epas/timesheet/ugovpj/v1/dto/PersonTimeDetailMapper.java @@ -18,13 +18,15 @@ import org.mapstruct.Mapper; import org.mapstruct.MappingTarget; - +import it.cnr.iit.epas.timesheet.ugovpj.model.DetailLog; import it.cnr.iit.epas.timesheet.ugovpj.model.PersonTimeDetail; import it.cnr.iit.epas.timesheet.ugovpj.model.TimeDetailType; /** * Mapping dei dati delle Entity nei rispettivi DTO. * + * @author Cristian Lucchesi + * */ @Mapper(componentModel = "spring") public interface PersonTimeDetailMapper { @@ -33,5 +35,8 @@ public interface PersonTimeDetailMapper { TimeDetailTypeDto convert(TimeDetailType type); + DetailLogDto convert(DetailLog log); + void update(@MappingTarget TimeDetailType type, TimeDetailTypeDto dto); + } \ No newline at end of file