Skip to content

Commit

Permalink
Esportazione via REST dei log in tabella di frontiera.
Browse files Browse the repository at this point in the history
Commentato l'utilizzo del boot-docker-compose.
  • Loading branch information
criluc committed Mar 18, 2024
1 parent 1a65e64 commit f3f00b3
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 8 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-docker-compose</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-docker-compose</artifactId>-->
<!-- <scope>runtime</scope>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/
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;

}
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/
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<DetailLog,Long> {
//Empty interface
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;

Expand Down Expand Up @@ -87,4 +94,13 @@ public ResponseEntity<TimeDetailTypeDto> create(
log.info("Creato Result {}", result);
return ResponseEntity.status(HttpStatus.CREATED).body(mapper.convert(result));
}

@GetMapping("/logs")
public ResponseEntity<Page<DetailLogDto>> 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);
}

}
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/
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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -33,5 +35,8 @@ public interface PersonTimeDetailMapper {

TimeDetailTypeDto convert(TimeDetailType type);

DetailLogDto convert(DetailLog log);

void update(@MappingTarget TimeDetailType type, TimeDetailTypeDto dto);

}

0 comments on commit f3f00b3

Please sign in to comment.