Skip to content

Commit

Permalink
Merge pull request #52 from consiglionazionaledellericerche/46-implem…
Browse files Browse the repository at this point in the history
…entare-endpoint-rest-per-riepilogo-ore

46 implementare endpoint rest per riepilogo ore e delle ore di formazione
  • Loading branch information
criluc authored Oct 16, 2024
2 parents 65d54ca + b2f727a commit 524a876
Show file tree
Hide file tree
Showing 12 changed files with 1,031 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- API Rest per inserimento, modifica e cancellazione timbrature via interfaccia web
- API Rest per inserimento, modifica e cancellazione timbrature Fuori Sede via interfaccia web
- Creazione dei DTO e mapper per la gestione delle request/response per le timbrature
- Aggiunte drools per il funzionamento delle API Rest delle timbrature
- Sistemato problema su recupero Owner in StampingHistoryDao
- Aggiunto from userRolesOffices in alcune drools con target Stamping
- API Rest per la gestione dei PersonMonths hourRecap (Riepilogo Ore)
- API Rest per la gestione dei PersonMonths trainingHours (Ore Formazione)
- Aggiunte drools per il funzionamento delle API Rest delle timbrature e delle ore di formazione

## [0.4.1] - 2024-07-05
### Added
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (C) 2022 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.dto.v4;

import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDate;
import java.util.Optional;
import lombok.Data;

/**
* DTO per creare/aggiornare le ore di formazione PersonMonthRecap per TrainingHours.
*
* @author Andrea Generosi
*
*/
@Data
public class PersonMonthRecapCreateDto {
private Long id=null;
private Integer year;
private Integer month;
private Integer begin;
private Integer end;
private Integer trainingHours;
}
42 changes: 42 additions & 0 deletions src/main/java/it/cnr/iit/epas/dto/v4/PersonMonthRecapDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2022 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.dto.v4;

import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDate;
import lombok.Data;

/**
* DTO per i PersonMonthRecap per TrainingHours.
*
* @author Andrea Generosi
*
*/
@Data
public class PersonMonthRecapDto {
@Schema(description = "Persona")
private PersonShowDto person;
private Long id;
private Integer year;
private Integer month;
private LocalDate fromDate;
private LocalDate toDate;
private Integer trainingHours;
private boolean hoursApproved = false;
private boolean editable = false;
}
41 changes: 41 additions & 0 deletions src/main/java/it/cnr/iit/epas/dto/v4/PersonMonthsDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2023 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.dto.v4;

import java.util.Optional;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
* DTO per rappresentare i IWrapperContractMonthRecap.
*
* @author Cristian Lucchesi
*
*/
@Data
@AllArgsConstructor
public class PersonMonthsDto {

private ContractMonthRecapDto value;
private Optional<ContractMonthRecapDto> previousRecap;
private Optional<ContractMonthRecapDto> previousRecapInYear;
private boolean hasResidualInitInYearMonth;
private boolean hasResidualLastYear;
private int getResidualLastYearInit;

}
37 changes: 37 additions & 0 deletions src/main/java/it/cnr/iit/epas/dto/v4/TrainingHoursDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2022 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.dto.v4;

import java.time.LocalDate;
import java.util.List;
import lombok.Data;

/**
* DTO per i PersonMonthRecap per TrainingHours.
*
* @author Andrea Generosi
*
*/
@Data
public class TrainingHoursDto {

private PersonShowDto person;
private List<PersonMonthRecapDto> personMonthRecaps;
private LocalDate today;

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.mapstruct.Mapping;

/**
* Mapper da AbsenceGroups al suo DTO per la visualizzazione via REST.
* Mapper da Competences al suo DTO per la visualizzazione via REST.
*/
@Mapper(componentModel = "spring")
public interface CompetencesMapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2023 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.dto.v4.mapper;

import it.cnr.iit.epas.dto.v4.PersonMonthRecapDto;
import it.cnr.iit.epas.dto.v4.PersonReperibilityDayDto;
import it.cnr.iit.epas.dto.v4.PersonShowDto;
import it.cnr.iit.epas.models.Person;
import it.cnr.iit.epas.models.PersonMonthRecap;
import it.cnr.iit.epas.models.PersonReperibilityDay;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
* Mapper da PersonReperibilityDay al suo DTO per la visualizzazione via REST.
*/
@Mapper(componentModel = "spring")
public interface PersonMonthRecapMapper {

@Mapping(target = "qualification", source = "person.qualification.id")
PersonShowDto convert(Person person);

@Mapping(target = "id", expression = "java(personMonthRecap.getId())")
@Mapping(target = "editable", expression = "java(personMonthRecap.isEditable())")
PersonMonthRecapDto convert(PersonMonthRecap personMonthRecap);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright (C) 2023 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.dto.v4.mapper;

import it.cnr.iit.epas.dao.wrapper.IWrapperContractMonthRecap;
import it.cnr.iit.epas.dto.v4.AbsenceShowDto;
import it.cnr.iit.epas.dto.v4.AbsenceShowTerseDto;
import it.cnr.iit.epas.dto.v4.AbsenceToRecoverDto;
import it.cnr.iit.epas.dto.v4.AbsenceTypeShowTerseDto;
import it.cnr.iit.epas.dto.v4.ContractMonthRecapDto;
import it.cnr.iit.epas.dto.v4.PersonDayDto;
import it.cnr.iit.epas.dto.v4.PersonMonthsDto;
import it.cnr.iit.epas.dto.v4.PersonStampingDayRecapDto;
import it.cnr.iit.epas.dto.v4.PersonStampingRecapDto;
import it.cnr.iit.epas.dto.v4.StampingTemplateDto;
import it.cnr.iit.epas.dto.v4.WorkingTimeTypeDayDto;
import it.cnr.iit.epas.dto.v4.WorkingTimeTypeDto;
import it.cnr.iit.epas.manager.recaps.personstamping.PersonStampingDayRecap;
import it.cnr.iit.epas.manager.recaps.personstamping.PersonStampingRecap;
import it.cnr.iit.epas.manager.recaps.personstamping.StampingTemplate;
import it.cnr.iit.epas.models.ContractMonthRecap;
import it.cnr.iit.epas.models.PersonDay;
import it.cnr.iit.epas.models.WorkingTimeType;
import it.cnr.iit.epas.models.WorkingTimeTypeDay;
import it.cnr.iit.epas.models.absences.Absence;
import it.cnr.iit.epas.models.absences.AbsenceType;
import java.util.List;
import java.util.Optional;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
* Mapping delle informazioni per il riepilogo delle ore mensili nell'anno
* in un DTO da esportare via REST.
*
* @author cristian
*
*/
@Mapper(componentModel = "spring")
public interface PersonMonthsMapper {

@Mapping(target = ".", source = "value")
@Mapping(
target = "hasResidualInitInYearMonth",
expression =
"java(contractMonthRecap.residualInitInYearMonth(contractMonthRecap.getValue().getYear(), "
+ "contractMonthRecap.getValue().getMonth()))")
@Mapping(
target = "getResidualLastYearInit",
expression = "java(contractMonthRecap.getResidualLastYearInit())")
@Mapping(
target = "hasResidualLastYear",
expression = "java(contractMonthRecap.hasResidualLastYear())")
@Mapping(
target = "previousRecap",
source = "previousRecapInYear") // Mappatura esplicita del campo Optional
@Mapping(
target = "previousRecapInYear",
source = "previousRecapInYear") // Mappatura esplicita del campo Optional
PersonMonthsDto convert(IWrapperContractMonthRecap contractMonthRecap);

@Mapping(
target = "expireInMonth",
expression = "java(contractMonthRecap.expireInMonth())")
ContractMonthRecapDto convert(ContractMonthRecap contractMonthRecap);

// Metodo helper per mappare un Optional<ContractMonthRecap> in Optional<ContractMonthRecapDto>
default Optional<ContractMonthRecapDto> mapOptionalRecap(Optional<ContractMonthRecap> contractMonthRecapOptional) {
return contractMonthRecapOptional.map(this::convert); // Usa il metodo convert per l'oggetto effettivo
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2023 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.dto.v4.mapper;

import it.cnr.iit.epas.dto.v4.PersonMonthRecapDto;
import it.cnr.iit.epas.dto.v4.PersonShowDto;
import it.cnr.iit.epas.models.Person;
import it.cnr.iit.epas.models.PersonMonthRecap;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
* Mapper da TrainingHours al suo DTO per la visualizzazione via REST.
*/
@Mapper(componentModel = "spring")
public interface TrainingHoursMapper {

@Mapping(target = "qualification", source = "person.qualification.id")
PersonShowDto convert(Person person);

PersonMonthRecapDto convert(PersonMonthRecap personMonthRecap);
}
Loading

0 comments on commit 524a876

Please sign in to comment.