Skip to content

Commit

Permalink
Merge pull request #51 from consiglionazionaledellericerche/49-timbra…
Browse files Browse the repository at this point in the history
…tura-già-esistente-quando-si-modifica-una-timbratura

Corretto mapping per metodo aggiornamento timbrature.
  • Loading branch information
criluc authored Oct 8, 2024
2 parents 5f4ff21 + e01cdd7 commit 65d54ca
Show file tree
Hide file tree
Showing 36 changed files with 232 additions and 245 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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

## [0.4.1] - 2024-07-05
### Added
- API Rest per il controllo della secure.check
Expand Down
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.15</version>
<version>2.7.18</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>it.cnr.iit</groupId>
<artifactId>epas-service</artifactId>
<version>0.3.0</version>
<version>0.5.0</version>
<name>epas-service</name>
<description>Personnel Attendance System</description>
<properties>
<java.version>17</java.version>
<org.mapstruct.version>1.5.5.Final</org.mapstruct.version>
<guava.version>32.1.1-jre</guava.version>
<guava.version>33.3.1-jre</guava.version>
<drools.version>7.74.0.Final</drools.version>
<lombok.version>1.18.28</lombok.version>
<dbunit.version>2.7.3</dbunit.version>
<springdoc.openapi.version>1.7.0</springdoc.openapi.version>
<jib.maven-plugin.version>3.3.2</jib.maven-plugin.version>
<lombok.version>1.18.34</lombok.version>
<dbunit.version>2.8.0</dbunit.version>
<springdoc.openapi.version>1.8.0</springdoc.openapi.version>
<jib.maven-plugin.version>3.4.3</jib.maven-plugin.version>
</properties>
<profiles>
<profile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Consiglio Nazionale delle Ricerche
* 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
Expand All @@ -14,13 +14,34 @@
* 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.controller.v4;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.SortedMap;

import javax.persistence.EntityNotFoundException;
import javax.transaction.Transactional;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand All @@ -34,7 +55,6 @@
import it.cnr.iit.epas.dao.AbsenceTypeDao;
import it.cnr.iit.epas.dao.CategoryTabDao;
import it.cnr.iit.epas.dao.GroupAbsenceTypeDao;
import it.cnr.iit.epas.dao.UserDao;
import it.cnr.iit.epas.dao.absences.AbsenceComponentDao;
import it.cnr.iit.epas.dto.v4.AbsenceFormDto;
import it.cnr.iit.epas.dto.v4.AbsenceFormSaveDto;
Expand All @@ -60,36 +80,15 @@
import it.cnr.iit.epas.manager.services.absences.model.AbsencePeriod;
import it.cnr.iit.epas.manager.services.absences.model.DayInPeriod;
import it.cnr.iit.epas.manager.services.absences.model.DayInPeriod.TemplateRow;
import it.cnr.iit.epas.manager.services.absences.model.PeriodChain;
import it.cnr.iit.epas.models.Person;
import it.cnr.iit.epas.models.User;
import it.cnr.iit.epas.models.absences.AbsenceType;
import it.cnr.iit.epas.models.absences.CategoryGroupAbsenceType;
import it.cnr.iit.epas.models.absences.CategoryTab;
import it.cnr.iit.epas.models.absences.GroupAbsenceType;
import it.cnr.iit.epas.models.absences.JustifiedType;
import it.cnr.iit.epas.security.SecureUtils;
import it.cnr.iit.epas.security.SecurityRules;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.SortedMap;
import javax.persistence.EntityNotFoundException;
import javax.transaction.Transactional;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
* Metodi REST per la gestione dei gruppi di assenza.
Expand Down Expand Up @@ -122,7 +121,6 @@ public class AbsencesGroupsController {
private final AbsenceManager absenceManager;
private final PersonFinder personFinder;
private final SecurityRules rules;
private final SecureUtils securityUtils;

/**
* Elenco delle assenze in un mese.
Expand Down Expand Up @@ -561,7 +559,6 @@ public ResponseEntity<Set<AbsenceTypeDto>> findCode(
@RequestParam("fiscalCode") Optional<String> fiscalCode,
@RequestParam("from") String from) {
log.debug("AbsencesGroupsController::findCode id = {} from = {} ", id, from);
LocalDate fromDate = LocalDate.parse(from);

Person person =
personFinder.getPerson(id, fiscalCode)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* 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.controller.v4;

import java.time.LocalDate;
Expand Down Expand Up @@ -46,7 +62,6 @@
import it.cnr.iit.epas.dao.PersonDao;
import it.cnr.iit.epas.dao.StampingDao;
import it.cnr.iit.epas.dao.UserDao;
import it.cnr.iit.epas.dao.history.HistoricalDao;
import it.cnr.iit.epas.dao.history.HistoryValue;
import it.cnr.iit.epas.dao.history.StampingHistoryDao;
import it.cnr.iit.epas.dao.wrapper.IWrapperPerson;
Expand All @@ -57,7 +72,6 @@
import it.cnr.iit.epas.dto.v4.StampingEditFormDto;
import it.cnr.iit.epas.dto.v4.StampingFormDto;
import it.cnr.iit.epas.dto.v4.ZoneDto;
import it.cnr.iit.epas.dto.v4.mapper.DtoToEntityMapper;
import it.cnr.iit.epas.dto.v4.mapper.EntityToDtoConverter;
import it.cnr.iit.epas.dto.v4.mapper.StampingFormDtoMapper;
import it.cnr.iit.epas.manager.PersonDayManager;
Expand Down Expand Up @@ -94,14 +108,11 @@
@RequestMapping(ApiRoutes.BASE_PATH + "/stampings")
public class StampingsController {

private final UserDao userDao;
private final PersonDao personDao;
private final StampingDao stampingDao;
private final StampingHistoryDao stampingsHistoryDao;

private final HistoricalDao historicalDao;
private final EntityToDtoConverter entityToDtoConverter;
private final DtoToEntityMapper dtoToEntityMapper;
private final StampingManager stampingManager;
private final PersonDayManager personDayManager;
private final SecurityRules rules;
Expand Down Expand Up @@ -200,7 +211,7 @@ public ResponseEntity<StampingFormDto> insertStampingForm(

IWrapperPerson wrperson = wrapperFactory.create(user.getPerson());
if (user.getPerson() != null && user.getPerson().equals(person)) {
if (userDao.getAllowedStampTypes(user).contains(StampTypes.LAVORO_FUORI_SEDE)) {
if (UserDao.getAllowedStampTypes(user).contains(StampTypes.LAVORO_FUORI_SEDE)) {
insertOffsite = true;
insertNormal = false;
}
Expand Down Expand Up @@ -371,7 +382,6 @@ public ResponseEntity<Map<String, String>> create(
Map<Integer, String> resultMap = manageStamping(stampingCreateDto, true);
Map<String, String> response = new HashMap<>();
Integer statusCode = resultMap.keySet().iterator().next();
String result = resultMap.get(statusCode);

if (statusCode == 404) {
return ResponseEntity.notFound().build();
Expand Down Expand Up @@ -480,7 +490,6 @@ public ResponseEntity<Map<String, String>> saveServiceReasons(
final User currentUser = securityUtils.getCurrentUser().get();

Person person = currentStamping.getPersonDay().getPerson();
LocalDateTime date = currentStamping.getDate();

if (!currentUser.isSystemUser() && !currentUser.hasRoles(Role.PERSONNEL_ADMIN)
&& currentUser.getPerson().getId().equals(person.getId())) {
Expand Down Expand Up @@ -556,11 +565,6 @@ private Map<Integer, String> manageStamping(StampingCreateDto stampingCreateDto,
if (stamping.getWay() == null) {
log.debug("StampingsController::stampingDao.isPersistent(stamping) = {}",
stampingDao.isPersistent(stamping));
List<HistoryValue<Stamping>> historyStamping = Lists.newArrayList();
if (stampingDao.isPersistent(stamping)) {
historyStamping = stampingsHistoryDao.stampings(stamping.getId());
}
//render("@edit", stamping, person, date, time, historyStamping);
resultMap.put(400, null);
return resultMap;
}
Expand All @@ -573,17 +577,8 @@ private Map<Integer, String> manageStamping(StampingCreateDto stampingCreateDto,
if (!violations.isEmpty()) {
List<StampTypes> offsiteList = Lists.newArrayList();
offsiteList.add(StampTypes.LAVORO_FUORI_SEDE);
boolean disableInsert = false;
User user = securityUtils.getCurrentUser().get();
if (user.getPerson() != null) {
if (person.getOffice().checkConf(EpasParam.WORKING_OFF_SITE, "true")
&& person.checkConf(EpasParam.OFF_SITE_STAMPING, "true")) {
disableInsert = true;
}
}
resultMap.put(400, null);
return resultMap;
//render("@editOffSite", stamping, person, date, time, disableInsert, offsite);
}
}

Expand Down Expand Up @@ -613,12 +608,8 @@ private Map<Integer, String> manageStamping(StampingCreateDto stampingCreateDto,
stamping.setStampingZone(zone);
}

log.debug("StampingsController::newInsert = {}", newInsert);
log.debug("StampingsController::newInsert = {}", newInsert);

String result = stampingManager
.persistStamping(stamping, person, currentUser, newInsert, false);
log.debug("StampingsController::result = {}", result);

if (!Strings.isNullOrEmpty(result)) {
// Stamping already present (409)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,27 @@
*/
package it.cnr.iit.epas.dao.history;

import com.google.common.collect.FluentIterable;

import it.cnr.iit.epas.models.Stamping;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Provider;
import javax.persistence.EntityManager;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.hibernate.envers.AuditReader;

import org.hibernate.envers.AuditReaderFactory;
import org.hibernate.envers.query.AuditEntity;
import org.hibernate.envers.query.AuditQuery;
import org.springframework.stereotype.Component;

import com.google.common.collect.FluentIterable;

import it.cnr.iit.epas.models.Stamping;
import lombok.val;

/**
* Dao sullo storico delle timbrature.
*
* @author Marco Andreini
*/
@Slf4j
@Component
public class StampingHistoryDao {

Expand Down Expand Up @@ -67,4 +66,4 @@ public List<HistoryValue<Stamping>> stampings(long stampingId) {
.toList();
}

}
}
7 changes: 2 additions & 5 deletions src/main/java/it/cnr/iit/epas/dto/v4/AbsenceErrorDto.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Consiglio Nazionale delle Ricerche
* 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
Expand All @@ -14,13 +14,10 @@
* 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 com.google.common.collect.Lists;
import java.time.LocalDate;
import java.util.List;
import java.util.Set;

import lombok.Data;

/**
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/it/cnr/iit/epas/dto/v4/AbsenceFormDto.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Consiglio Nazionale delle Ricerche
* 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
Expand All @@ -14,18 +14,17 @@
* 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 com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import io.swagger.v3.oas.annotations.media.Schema;
import it.cnr.iit.epas.models.absences.CategoryGroupAbsenceType;
import it.cnr.iit.epas.models.absences.GroupAbsenceType;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

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

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Consiglio Nazionale delle Ricerche
* 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
Expand All @@ -14,10 +14,8 @@
* 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.Data;

/**
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/it/cnr/iit/epas/dto/v4/CategoryTabDto.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Consiglio Nazionale delle Ricerche
* 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
Expand All @@ -14,12 +14,9 @@
* 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 com.google.common.collect.Sets;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Set;
import lombok.Data;

/**
Expand Down
Loading

0 comments on commit 65d54ca

Please sign in to comment.