diff --git a/CHANGELOG.md b/CHANGELOG.md index ceafe7196..e43d8c0b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [2.19.2] - UNRELEASED +## [2.20.0] - 2024-11-12 ### Added - Aggiunto un parametro JAVA_OPTIONS per controllare i parametri passati in fase di avvio della JVM Java. Impostato di default il parametro -XX:MaxRAMPercentage=50 che assegna il 50% della memoria disponibile al container docker. + - Corretta visualizzazione dei flussi di richiesta uscita di servizio da parte del responsabile + di sede se è anche responsabile di gruppo ## [2.19.1] - 2024-10-30 ### Added diff --git a/VERSION b/VERSION index b87b08b5b..a4cc673ab 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.19.2 \ No newline at end of file +2.20.0 \ No newline at end of file diff --git a/app/controllers/InformationRequests.java b/app/controllers/InformationRequests.java index 0e1472c43..5c71534f6 100644 --- a/app/controllers/InformationRequests.java +++ b/app/controllers/InformationRequests.java @@ -203,13 +203,13 @@ public static void listToApprove(InformationType type) { Verify.verifyNotNull(type); val person = Security.getUser().get().getPerson(); - val fromDate = LocalDateTime.now().withDayOfYear(1).withMonth(1).minusMonths(1); + val fromDate = LocalDateTime.now().withDayOfMonth(1).minusMonths(3); log.debug("Prelevo le richieste da approvare di assenze di tipo {} a partire da {}", type, fromDate); List roleList = uroDao.getUsersRolesOfficesByUser(person.getUser()); List myResults = - informationRequestDao.toApproveResults(roleList, Optional.absent(), + informationRequestDao.toApproveResults(roleList, Optional.of(fromDate), Optional.absent(), type, person); List approvedResults = informationRequestDao.totallyApproved(roleList, fromDate, diff --git a/app/dao/InformationRequestDao.java b/app/dao/InformationRequestDao.java index 73f405536..8c8979db7 100644 --- a/app/dao/InformationRequestDao.java +++ b/app/dao/InformationRequestDao.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 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 @@ -14,23 +14,28 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - package dao; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; -import com.google.inject.Provider; -import com.querydsl.core.BooleanBuilder; -import com.querydsl.jpa.JPQLQuery; -import com.querydsl.jpa.JPQLQueryFactory; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; + import javax.inject.Inject; import javax.persistence.EntityManager; + +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; +import com.google.inject.Provider; +import com.querydsl.core.BooleanBuilder; +import com.querydsl.jpa.JPQLQuery; +import com.querydsl.jpa.JPQLQueryFactory; + +import lombok.val; import models.Office; import models.Person; import models.Role; @@ -38,7 +43,6 @@ import models.base.InformationRequest; import models.base.query.QInformationRequest; import models.enumerate.InformationType; -import models.flows.AbsenceRequest; import models.flows.query.QAffiliation; import models.flows.query.QGroup; import models.informationrequests.IllnessRequest; @@ -98,7 +102,7 @@ public List toApproveResults(List uroList .and(informationRequest.flowStarted.isTrue()) .and(informationRequest.flowEnded.isFalse())); - List results = new ArrayList<>(); + Set results = new HashSet(); if ((informationType.equals(InformationType.ILLNESS_INFORMATION) || informationType.equals(InformationType.PARENTAL_LEAVE_INFORMATION)) && uroList.stream().anyMatch(uro -> uro.getRole().getName().equals(Role.PERSONNEL_ADMIN))) { @@ -109,7 +113,6 @@ public List toApproveResults(List uroList && uroList.stream().anyMatch(uro -> uro.getRole().getName().equals(Role.GROUP_MANAGER))) { List officeList = uroList.stream().map(u -> u.getOffice()).collect(Collectors.toList()); - conditions = groupManagerQuery(officeList, conditions, signer); final QAffiliation affiliation = QAffiliation.affiliation; List queryResults = getQueryFactory().selectFrom(informationRequest) .join(informationRequest.person, person).fetchJoin() @@ -117,16 +120,18 @@ public List toApproveResults(List uroList .on(affiliation.beginDate.before(LocalDate.now()) .and(affiliation.endDate.isNull().or(affiliation.endDate.after(LocalDate.now())))) .join(affiliation.group, group) - .where(group.manager.eq(signer).and(conditions)) + .where(group.manager.eq(signer).and(groupManagerQuery(officeList, conditions, signer))) .distinct() .fetch(); results.addAll(queryResults); - } else { - results.addAll(toApproveResultsAsSeatSuperVisor(uroList, - informationType, signer, conditions)); + } + if (uroList.stream().anyMatch(uro -> uro.getRole().getName().equals(Role.SEAT_SUPERVISOR))) { + val resultsAsSeatSupervisor = toApproveResultsAsSeatSuperVisor(uroList, + informationType, signer, conditions); + results.addAll(resultsAsSeatSupervisor); } - return results; + return Lists.newArrayList(results); } /** @@ -361,7 +366,7 @@ public List illnessByIds(List ids) { public List servicesByIds(List ids) { final QServiceRequest serviceRequest = QServiceRequest.serviceRequest; return getQueryFactory().selectFrom(serviceRequest) - .where(serviceRequest.id.in(ids)).fetch(); + .where(serviceRequest.id.in(ids)).orderBy(QServiceRequest.serviceRequest.day.desc()).fetch(); } /** @@ -477,11 +482,13 @@ private List toApproveResultsAsPersonnelAdmin(List officeList, BooleanBuilder condition, Person signer) { - final QInformationRequest informationRequest = QInformationRequest.informationRequest; + BooleanBuilder isGroupManagerStaff = + new BooleanBuilder(informationRequest.managerApprovalRequired.isTrue()) + .and(informationRequest.managerApproved.isNull()); condition.and(informationRequest.person.office.in(officeList)) .and(informationRequest.officeHeadApprovalRequired.isTrue() - .and(informationRequest.officeHeadApproved.isNull())); + .and(informationRequest.officeHeadApproved.isNull())).andNot(isGroupManagerStaff); return condition; } @@ -513,14 +520,15 @@ private BooleanBuilder personnelAdminQuery(List officeList, * @param signer colui che deve firmare la richiesta * @return le condizioni per determinare se il responsabile di gruppo è coinvolto * nell'approvazione. + * @throws CloneNotSupportedException */ private BooleanBuilder groupManagerQuery(List officeList, BooleanBuilder condition, Person signer) { final QInformationRequest informationRequest = QInformationRequest.informationRequest; - condition.and(informationRequest.person.office.in(officeList)) + val groupCondition = new BooleanBuilder(condition); + return groupCondition.and(informationRequest.person.office.in(officeList)) .and(informationRequest.managerApprovalRequired.isTrue() .and(informationRequest.managerApproved.isNull())); - return condition; } /** diff --git a/app/models/informationrequests/query/QServiceRequest.java b/app/models/informationrequests/query/QServiceRequest.java index aed835f4d..ec838f58b 100644 --- a/app/models/informationrequests/query/QServiceRequest.java +++ b/app/models/informationrequests/query/QServiceRequest.java @@ -9,7 +9,6 @@ import com.querydsl.core.types.PathMetadata; import javax.annotation.Generated; import com.querydsl.core.types.Path; -import com.querydsl.core.types.dsl.PathInits; /** @@ -26,6 +25,8 @@ public class QServiceRequest extends EntityPathBase { public final models.base.query.QInformationRequest _super; + public final DatePath day = createDate("day", java.time.LocalDate.class); + //inherited public final BooleanPath administrativeApprovalRequired; diff --git a/conf/permissions.drl b/conf/permissions.drl index 943519e97..01ff2be6d 100755 --- a/conf/permissions.drl +++ b/conf/permissions.drl @@ -1050,7 +1050,7 @@ end rule personInChargeForFlows when UsersRolesOffices(role.name == Role.GROUP_MANAGER) - $ar: AbsenceRequest(managerApprovalRequired == true && managerApproved == null) + $ar: AbsenceRequest(managerApprovalRequired == true && !isManagerApproved()) $c: PermissionCheck( action in ( "AbsenceRequests.blank", "AbsenceRequests.edit", @@ -1079,7 +1079,7 @@ end rule personInChargeForCompetenceRequestsFlows when UsersRolesOffices(role.name == Role.GROUP_MANAGER) - $cr: CompetenceRequest(managerApprovalRequired == true && managerApproved == null) + $cr: CompetenceRequest(managerApprovalRequired == true && !isManagerApproved()) $c: PermissionCheck( action in ( "CompetenceRequests.list", "CompetenceRequests.listToApprove", @@ -1095,7 +1095,7 @@ end rule personInChargeForInformationFlows when UsersRolesOffices(role.name == Role.GROUP_MANAGER) - $ir: InformationRequest(managerApprovalRequired == true && managerApproved == null) + $ir: InformationRequest(managerApprovalRequired == true && !isManagerApproved()) $c: PermissionCheck( action in ( "InformationRequests.serviceExitToApprove", "InformationRequests.listToApprove", diff --git a/publiccode.yml b/publiccode.yml index fdbe48e49..1c81cc0d9 100644 --- a/publiccode.yml +++ b/publiccode.yml @@ -4,10 +4,10 @@ publiccodeYmlVersion: '0.2' name: epas -releaseDate: '2024-10-30' +releaseDate: '2024-11-12' url: 'https://github.com/consiglionazionaledellericerche/epas' applicationSuite: epas -softwareVersion: 2.19.1 +softwareVersion: 2.20.0 developmentStatus: stable softwareType: standalone/web platforms: