Pull request #590: RED-4904
Merge in RED/persistence-service from RED-4904_Rework to master * commit '917dc3582aa427928716872c7d1c9f71513c71ea': RED-4904: Added method to remove not existing users
This commit is contained in:
commit
dae9c2d0bd
@ -50,11 +50,13 @@ public interface StatusResource {
|
||||
@GetMapping(value = STATUS_PATH + DOSSIER_ID_PATH_PARAM, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
List<FileModel> getDossierStatus(@PathVariable(DOSSIER_ID_PARAM) String dossierId);
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@GetMapping(value = STATUS_PATH + DOSSIER_ID_PATH_PARAM + ALL_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
List<FileModel> getAllDossierStatus(@PathVariable(DOSSIER_ID_PARAM) String dossierId);
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@GetMapping(value = STATUS_PATH + DELETED_PATH + DOSSIER_ID_PATH_PARAM, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ -124,4 +126,8 @@ public interface StatusResource {
|
||||
@PostMapping(value = STATUS_PATH + "/include-pages" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE)
|
||||
void includePages(@PathVariable(DOSSIER_ID_PARAM) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestBody Set<Integer> pages);
|
||||
|
||||
|
||||
@PostMapping(value = STATUS_PATH + "/remove-not-existing-users", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void removeNotExistingUsers(@RequestBody Set<String> deletedUsers);
|
||||
|
||||
}
|
||||
|
||||
@ -527,4 +527,12 @@ public class FileStatusPersistenceService {
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void removeNotExistingUsers(Set<String> users) {
|
||||
|
||||
fileRepository.deleteLastReviewers(users, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
fileRepository.deleteLastApprovers(users, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -127,6 +127,16 @@ public interface FileRepository extends JpaRepository<FileEntity, String> {
|
||||
int setAssignee(String fileId, String assignee, String lastReviewer, String lastApprover, OffsetDateTime lastUpdated);
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.lastReviewer = null, f.lastUpdated = :lastUpdated where f.lastReviewer IN :users")
|
||||
int deleteLastReviewers(Set<String> users, OffsetDateTime lastUpdated);
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.lastApprover = null, f.lastUpdated = :lastUpdated where f.lastApprover IN :users")
|
||||
int deleteLastApprovers(Set<String> users, OffsetDateTime lastUpdated);
|
||||
|
||||
|
||||
@Modifying(clearAutomatically = true)
|
||||
@Query("update FileEntity f set f.excluded = :excluded, f.lastUpdated = :lastUpdated where f.id = :fileId")
|
||||
int toggleExclusion(String fileId, boolean excluded, OffsetDateTime lastUpdated);
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.iqser.red.service.peristence.v1.server.controller;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@ -47,6 +46,7 @@ public class FileStatusController implements StatusResource {
|
||||
return fileStatusService.getDossierStatus(dossierId).stream().filter(f -> !f.isSoftOrHardDeleted()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<FileModel> getAllDossierStatus(@PathVariable(DOSSIER_ID_PARAM) String dossierId) {
|
||||
|
||||
@ -95,6 +95,13 @@ public class FileStatusController implements StatusResource {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeNotExistingUsers(@RequestBody Set<String> notExistingUsers) {
|
||||
|
||||
fileStatusService.removeNotExistingUsers(notExistingUsers);
|
||||
}
|
||||
|
||||
|
||||
public void setStatusUnderReview(@PathVariable(DOSSIER_ID_PARAM) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestParam(value = USER_ID_REQUEST_PARAM, required = false) String userId) {
|
||||
|
||||
@ -747,4 +747,10 @@ public class FileStatusService {
|
||||
fileStatusPersistenceService.updateOCRStatus(response);
|
||||
}
|
||||
|
||||
|
||||
public void removeNotExistingUsers(Set<String> notExistingUsers) {
|
||||
|
||||
fileStatusPersistenceService.removeNotExistingUsers(notExistingUsers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user