Merge pull request #142 from Kitzanos/develop
Sync master with develop branch(23/12/2024) Beneficiary can apply to call moe than once per company (SviluppUmbria Only)
This commit is contained in:
@@ -604,6 +604,20 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
|
|
||||||
log.info("Updating application amendement with ID: {}", id);
|
log.info("Updating application amendement with ID: {}", id);
|
||||||
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
|
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
|
||||||
|
Boolean isBeneficiary=false;
|
||||||
|
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
|
||||||
|
validator.validatePreInstructor(request, existingApplicationAmendment.getApplicationEvaluationEntity().getUserId());
|
||||||
|
isBeneficiary=false;
|
||||||
|
} else {
|
||||||
|
validator.validateUserId(request, existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
|
||||||
|
isBeneficiary=true;
|
||||||
|
}
|
||||||
|
if(Boolean.TRUE.equals(isBeneficiary) && existingApplicationAmendment.getStatus().equals(ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue())){
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
|
||||||
|
}
|
||||||
|
if(Boolean.FALSE.equals(isBeneficiary) && existingApplicationAmendment.getStatus().equals(ApplicationAmendmentRequestEnum.AWAITING.getValue())){
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
|
||||||
|
}
|
||||||
|
|
||||||
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
|
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
|
||||||
setIfUpdated(existingApplicationAmendment::getNote, existingApplicationAmendment::setNote, updateRequest.getNote());
|
setIfUpdated(existingApplicationAmendment::getNote, existingApplicationAmendment::setNote, updateRequest.getNote());
|
||||||
@@ -1053,7 +1067,7 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
log.info("Updating application amendment with status: {}", id);
|
log.info("Updating application amendment with status: {}", id);
|
||||||
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
|
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
|
||||||
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
|
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
|
||||||
if (Boolean.TRUE.equals(existingApplicationAmendment.getStatus().equals(ApplicationAmendmentRequestEnum.AWAITING.getValue())) || Boolean.TRUE.equals(statusTypeEnum.equals(ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED))) {
|
if (Boolean.TRUE.equals(existingApplicationAmendment.getStatus().equals(ApplicationAmendmentRequestEnum.AWAITING.getValue())) && Boolean.TRUE.equals(statusTypeEnum.equals(ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED))) {
|
||||||
existingApplicationAmendment.setStatus(ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue());
|
existingApplicationAmendment.setStatus(ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue());
|
||||||
existingApplicationAmendment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
existingApplicationAmendment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
applicationAmendmentRequestRepository.save(existingApplicationAmendment);
|
applicationAmendmentRequestRepository.save(existingApplicationAmendment);
|
||||||
@@ -1137,12 +1151,6 @@ public class ApplicationAmendmentRequestDao {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public List<ApplicationAmendmentRequestEntity> getApplicationAmendmentRequestEntitiesByApplicationEvaluationId(Long applicationEvaluationId){
|
|
||||||
List<ApplicationAmendmentRequestEntity> applicationAmendmentRequestEntities=new ArrayList<>();
|
|
||||||
applicationAmendmentRequestEntities=applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndStatusAndIsDeletedFalse(applicationEvaluationId,ApplicationAmendmentRequestEnum.CLOSE.getValue());
|
|
||||||
return applicationAmendmentRequestEntities;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void softDeleteDocument(Long documentId) {
|
private void softDeleteDocument(Long documentId) {
|
||||||
documentService.deleteFile(documentId);
|
documentService.deleteFile(documentId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -804,18 +804,18 @@ public class ApplicationDao {
|
|||||||
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyEntity.getId());
|
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyEntity.getId());
|
||||||
|
|
||||||
// call = callService.validatePublishedCall(call.getId());
|
// call = callService.validatePublishedCall(call.getId());
|
||||||
checkIfApplicationExists(call, userWithCompanyEntity, userEntity);
|
// checkIfApplicationExists(call, userWithCompanyEntity, userEntity);
|
||||||
ApplicationEntity applicationEntity = createApplicationEntity(userEntity, call, userWithCompanyEntity);
|
ApplicationEntity applicationEntity = createApplicationEntity(userEntity, call, userWithCompanyEntity);
|
||||||
applicationEntity.setComments(applicationRequest.getComments());
|
applicationEntity.setComments(applicationRequest.getComments());
|
||||||
applicationEntity = saveApplicationEntity(applicationEntity);
|
applicationEntity = saveApplicationEntity(applicationEntity);
|
||||||
return getApplicationResponse(applicationEntity);
|
return getApplicationResponse(applicationEntity);
|
||||||
}
|
}
|
||||||
public void checkIfApplicationExists(CallEntity call, UserWithCompanyEntity userWithCompanyEntity, UserEntity userEntity){
|
// public void checkIfApplicationExists(CallEntity call, UserWithCompanyEntity userWithCompanyEntity, UserEntity userEntity){
|
||||||
Optional<ApplicationEntity> applicationEntity=applicationRepository.findByUserIdAndUserWithCompanyIdAndCallIdAndIsDeletedFalse(userEntity.getId(), userWithCompanyEntity.getId(),call.getId());
|
// Optional<ApplicationEntity> applicationEntity=applicationRepository.findByUserIdAndUserWithCompanyIdAndCallIdAndIsDeletedFalse(userEntity.getId(), userWithCompanyEntity.getId(),call.getId());
|
||||||
if(applicationEntity.isPresent()){
|
// if(applicationEntity.isPresent()){
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_EXISTS));
|
// throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_EXISTS));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) {
|
public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) {
|
||||||
|
|
||||||
|
|||||||
@@ -640,7 +640,9 @@ public class ApplicationEvaluationDao {
|
|||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
applicationAmendmentRequestEntities.forEach(applicationAmendmentRequestEntity->{
|
applicationAmendmentRequestEntities.forEach(applicationAmendmentRequestEntity->{
|
||||||
|
ApplicationAmendmentRequestEntity oldEntity = Utils.getClonedEntityForData(applicationAmendmentRequestEntity);
|
||||||
updateAmendment(applicationAmendmentRequestEntity, amendmentFormFieldsMap.get(applicationAmendmentRequestEntity.getId()));
|
updateAmendment(applicationAmendmentRequestEntity, amendmentFormFieldsMap.get(applicationAmendmentRequestEntity.getId()));
|
||||||
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().actionType(VersionActionTypeEnum.UPDATE).oldData(oldEntity).newData(applicationAmendmentRequestEntity).build());
|
||||||
});
|
});
|
||||||
applicationAmendmentRequestRepository.saveAll(applicationAmendmentRequestEntities);
|
applicationAmendmentRequestRepository.saveAll(applicationAmendmentRequestEntities);
|
||||||
|
|
||||||
@@ -1766,7 +1768,7 @@ public class ApplicationEvaluationDao {
|
|||||||
ApplicationEvaluationEntity oldApplicationEvaluation = Utils.getClonedEntityForData(existingEntity);
|
ApplicationEvaluationEntity oldApplicationEvaluation = Utils.getClonedEntityForData(existingEntity);
|
||||||
AssignedApplicationsEntity oldAssignedApplication = Utils.getClonedEntityForData(assignedApplicationsEntity);
|
AssignedApplicationsEntity oldAssignedApplication = Utils.getClonedEntityForData(assignedApplicationsEntity);
|
||||||
|
|
||||||
List<ApplicationAmendmentRequestEntity> amendmentRequest = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndStatusAndIsDeletedFalse(existingEntity.getId(),ApplicationAmendmentRequestEnum.AWAITING.getValue());
|
List<ApplicationAmendmentRequestEntity> amendmentRequest = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndStatusAndIsDeletedFalse(existingEntity.getId(),List.of(ApplicationAmendmentRequestEnum.AWAITING.getValue(),ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue()));
|
||||||
if(amendmentRequest !=null && Boolean.FALSE.equals(amendmentRequest.isEmpty())){
|
if(amendmentRequest !=null && Boolean.FALSE.equals(amendmentRequest.isEmpty())){
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_CANNOT_APPROVED_OR_REJECTED));
|
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_CANNOT_APPROVED_OR_REJECTED));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -448,12 +448,14 @@ public class UserDao {
|
|||||||
return authService.validateNewUserToken(token);
|
return authService.validateNewUserToken(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserResponseBean> getAllUsers(UserEntity user, Long roleId) {
|
public List<UserResponseBean> getAllUsers(UserEntity user, List<Long> roleIds) {
|
||||||
List<UserEntity> users;
|
List<UserEntity> users;
|
||||||
if (roleId != null) {
|
if (roleIds != null) {
|
||||||
log.info("Fetching users by role ID: {}", roleId);
|
log.info("Fetching users by role ID: {}", roleIds);
|
||||||
RoleEntity roleEntity=roleService.validateRole(roleId);
|
List<RoleEntity> roleEntities = roleIds.stream()
|
||||||
users = userRepository.findByRoleEntityIdAndHubId(roleEntity.getId(), user.getHub().getId());
|
.map(roleService::validateRole) // Assuming `validateRole` takes an ID and returns a RoleEntity
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
users = userRepository.findByRoleEntityIdInAndHubId(roleIds, user.getHub().getId());
|
||||||
} else {
|
} else {
|
||||||
log.info("Fetching all users");
|
log.info("Fetching all users");
|
||||||
users = userRepository.findByHubId(user.getHub().getId());
|
users = userRepository.findByHubId(user.getHub().getId());
|
||||||
@@ -462,7 +464,7 @@ public class UserDao {
|
|||||||
.map(this::convertUserEntityToUserResponse)
|
.map(this::convertUserEntityToUserResponse)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
log.info("Total users found with role ID {}: {}", roleId, userResponseBeans.size());
|
log.info("Total users found with role ID {}: {}", roleIds, userResponseBeans.size());
|
||||||
return userResponseBeans;
|
return userResponseBeans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ public interface ApplicationAmendmentRequestRepository extends JpaRepository<App
|
|||||||
"WHERE amr.applicationEvaluationEntity.id = :id " +
|
"WHERE amr.applicationEvaluationEntity.id = :id " +
|
||||||
"AND amr.isDeleted = false " +
|
"AND amr.isDeleted = false " +
|
||||||
"AND amr.applicationEvaluationEntity.isDeleted = false " +
|
"AND amr.applicationEvaluationEntity.isDeleted = false " +
|
||||||
"AND amr.status = :status")
|
"AND amr.status IN (:statuses)")
|
||||||
List<ApplicationAmendmentRequestEntity> findAllByApplicationEvaluationIdAndStatusAndIsDeletedFalse(Long id, String status);
|
List<ApplicationAmendmentRequestEntity> findAllByApplicationEvaluationIdAndStatusAndIsDeletedFalse(Long id, List<String> statuses);
|
||||||
|
|
||||||
@Query("SELECT a FROM ApplicationAmendmentRequestEntity a " +
|
@Query("SELECT a FROM ApplicationAmendmentRequestEntity a " +
|
||||||
"WHERE a.isDeleted = false " +
|
"WHERE a.isDeleted = false " +
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
|||||||
|
|
||||||
boolean existsByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubUuid);
|
boolean existsByEmailIgnoreCaseAndHubUniqueUuid(String email, String hubUuid);
|
||||||
|
|
||||||
List<UserEntity> findByRoleEntityIdAndHubId(Long roleId, Long hubId);
|
List<UserEntity> findByRoleEntityIdInAndHubId(List<Long> roleIds, Long hubId);
|
||||||
|
|
||||||
List<UserEntity> findByHubId(Long hubId);
|
List<UserEntity> findByHubId(Long hubId);
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,6 @@ public interface UserService {
|
|||||||
UserEntity getUserByBeneficiaryId(Long beneficiaryId);
|
UserEntity getUserByBeneficiaryId(Long beneficiaryId);
|
||||||
|
|
||||||
public UserEntity getUserEntityById(Long userId);
|
public UserEntity getUserEntityById(Long userId);
|
||||||
List<UserResponseBean> getAllUsers(HttpServletRequest request, Long roleId);
|
List<UserResponseBean> getAllUsers(HttpServletRequest request, List<Long> roleIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,13 +91,6 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean) {
|
public ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean) {
|
||||||
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(id);
|
|
||||||
|
|
||||||
if (Boolean.FALSE.equals(validator.checkIsBeneficiary())) {
|
|
||||||
validator.validatePreInstructor(request, amendment.getApplicationEvaluationEntity().getUserId());
|
|
||||||
} else {
|
|
||||||
validator.validateUserId(request, amendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().getUserId());
|
|
||||||
}
|
|
||||||
return applicationAmendmentRequestDao.updateApplicationAmendment(id,applicationAmendmentRequestBean);
|
return applicationAmendmentRequestDao.updateApplicationAmendment(id,applicationAmendmentRequestBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,8 +126,8 @@ public class UserServiceImpl implements UserService {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<UserResponseBean> getAllUsers(HttpServletRequest request, Long roleId) {
|
public List<UserResponseBean> getAllUsers(HttpServletRequest request, List<Long> roleIds) {
|
||||||
UserEntity user=validator.validateUser(request);
|
UserEntity user=validator.validateUser(request);
|
||||||
return userDao.getAllUsers(user, roleId);
|
return userDao.getAllUsers(user, roleIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,9 +234,9 @@ public interface UserApi {
|
|||||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
||||||
@RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.GET)
|
@RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.GET)
|
||||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')|| hasRole('ROLE_INSTRUCTOR_MANAGER')")
|
||||||
ResponseEntity<Response<List<UserResponseBean>>> getAllUsers(HttpServletRequest request,
|
ResponseEntity<Response<List<UserResponseBean>>> getAllUsers(HttpServletRequest request,
|
||||||
@Parameter( required = false)@RequestParam(value ="roleId", required = false) Long roleId);
|
@Parameter( required = false)@RequestParam(value ="roleIds", required = false) List<Long> roleIds);
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("favicon.ico")
|
@RequestMapping("favicon.ico")
|
||||||
|
|||||||
@@ -216,14 +216,14 @@ public class UserApiController implements UserApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<List<UserResponseBean>>> getAllUsers(HttpServletRequest request, Long roleId) {
|
public ResponseEntity<Response<List<UserResponseBean>>> getAllUsers(HttpServletRequest request, List<Long> roleIds) {
|
||||||
|
|
||||||
log.info("Get all Users by Role ID - Role ID: {}", roleId);
|
log.info("Get all Users by Role ID - Role ID: {}", roleIds);
|
||||||
|
|
||||||
/** This code is responsible for creating user action logs for the "Get all users by role" operation. **/
|
/** This code is responsible for creating user action logs for the "Get all users by role" operation. **/
|
||||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_ALL_USERS_BY_ROLE).build());
|
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_ALL_USERS_BY_ROLE).build());
|
||||||
|
|
||||||
List<UserResponseBean> users = userService.getAllUsers(request, roleId);
|
List<UserResponseBean> users = userService.getAllUsers(request, roleIds);
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(users, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_USERS_SUCCESS_MSG)));
|
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(users, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_USERS_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user