Skip to content

Commit

Permalink
Corretta visualizzazione flussi uscita servizio per responsabili sede.
Browse files Browse the repository at this point in the history
Versione 2.20.
  • Loading branch information
criluc committed Nov 12, 2024
1 parent 32f87b3 commit b7ba611
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 32 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.19.2
2.20.0
4 changes: 2 additions & 2 deletions app/controllers/InformationRequests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<UsersRolesOffices> roleList = uroDao.getUsersRolesOfficesByUser(person.getUser());
List<InformationRequest> myResults =
informationRequestDao.toApproveResults(roleList, Optional.absent(),
informationRequestDao.toApproveResults(roleList, Optional.of(fromDate),
Optional.absent(), type, person);
List<InformationRequest> approvedResults =
informationRequestDao.totallyApproved(roleList, fromDate,
Expand Down
52 changes: 30 additions & 22 deletions app/dao/InformationRequestDao.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,31 +14,35 @@
* 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 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;
import models.UsersRolesOffices;
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;
Expand Down Expand Up @@ -98,7 +102,7 @@ public List<InformationRequest> toApproveResults(List<UsersRolesOffices> uroList
.and(informationRequest.flowStarted.isTrue())
.and(informationRequest.flowEnded.isFalse()));

List<InformationRequest> results = new ArrayList<>();
Set<InformationRequest> 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))) {
Expand All @@ -109,24 +113,25 @@ public List<InformationRequest> toApproveResults(List<UsersRolesOffices> uroList
&& uroList.stream().anyMatch(uro -> uro.getRole().getName().equals(Role.GROUP_MANAGER))) {
List<Office> officeList =
uroList.stream().map(u -> u.getOffice()).collect(Collectors.toList());
conditions = groupManagerQuery(officeList, conditions, signer);
final QAffiliation affiliation = QAffiliation.affiliation;
List<InformationRequest> queryResults = getQueryFactory().selectFrom(informationRequest)
.join(informationRequest.person, person).fetchJoin()
.join(person.affiliations, affiliation)
.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);
}

/**
Expand Down Expand Up @@ -361,7 +366,7 @@ public List<IllnessRequest> illnessByIds(List<Long> ids) {
public List<ServiceRequest> servicesByIds(List<Long> 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();
}

/**
Expand Down Expand Up @@ -477,11 +482,13 @@ private List<InformationRequest> toApproveResultsAsPersonnelAdmin(List<UsersRole
*/
private BooleanBuilder seatSupervisorQuery(List<Office> 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;
}
Expand Down Expand Up @@ -513,14 +520,15 @@ private BooleanBuilder personnelAdminQuery(List<Office> 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<Office> 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;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion app/models/informationrequests/query/QServiceRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;


/**
Expand All @@ -26,6 +25,8 @@ public class QServiceRequest extends EntityPathBase<ServiceRequest> {

public final models.base.query.QInformationRequest _super;

public final DatePath<java.time.LocalDate> day = createDate("day", java.time.LocalDate.class);

//inherited
public final BooleanPath administrativeApprovalRequired;

Expand Down
6 changes: 3 additions & 3 deletions conf/permissions.drl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions publiccode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b7ba611

Please sign in to comment.