Pull request #11: RED-2256: Fix Sonar Bug Findings in persistence-service
Merge in RED/persistence-service from RED-2256-ps1 to master * commit 'f48f2994b685b014938b7e8a4c54c156ec08582f':
This commit is contained in:
commit
ac2f7a8ddd
@ -9,6 +9,7 @@ public class IdentityTest {
|
||||
|
||||
@Test
|
||||
public void mockTest(){
|
||||
assertThat(1).isEqualTo(1);
|
||||
int i = 1;
|
||||
assertThat(i).isEqualTo(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,12 +145,6 @@ public class FileStatusPersistenceService {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void updateLastManualRedaction(String fileId) {
|
||||
|
||||
updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateLastManualRedaction(String fileId, OffsetDateTime date) {
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ public class IdentityTest {
|
||||
|
||||
@Test
|
||||
public void mockTest(){
|
||||
assertThat(1).isEqualTo(1);
|
||||
int i = 1;
|
||||
assertThat(i).isEqualTo(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,7 +279,7 @@ public class DictionaryController implements DictionaryResource {
|
||||
|
||||
List<Type> typeResponse = dictionaryPersistenceService.getCumulatedTypes(dossierTemplateId, dossierId);
|
||||
for (Type res : typeResponse) {
|
||||
if (typeId != res.getId() && labelToCheck.equals(res.getLabel())) {
|
||||
if (!typeId.equals(res.getId()) && labelToCheck.equals(res.getLabel())) {
|
||||
throw new ConflictException("Label must be unique.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,7 +68,6 @@ public class DossierAttributesController implements DossierAttributesResource {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public List<DossierAttribute> getDossierAttributes(@PathVariable(DOSSIER_ID_PARAM) String dossierId) {
|
||||
return dossierAttributePersistenceService.getDossierAttributes(dossierId);
|
||||
}
|
||||
|
||||
@ -263,7 +263,7 @@ public class FileStatusService {
|
||||
fileStatusPersistenceService.updateLastOCRTime(fileId, OffsetDateTime.now());
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void overwriteFile(String dossierId, String fileId, String uploader, String filename, int length) {
|
||||
|
||||
fileStatusPersistenceService.overwriteFile(fileId, uploader, filename);
|
||||
|
||||
@ -4,6 +4,7 @@ import com.google.common.hash.HashFunction;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.iqser.red.service.peristence.v1.server.controller.DictionaryController;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.*;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.*;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.data.annotations.*;
|
||||
@ -17,7 +18,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -253,7 +254,7 @@ public class ManualRedactionService {
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId);
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,7 +273,7 @@ public class ManualRedactionService {
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId);
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,7 +288,7 @@ public class ManualRedactionService {
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId);
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,7 +302,7 @@ public class ManualRedactionService {
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId);
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,7 +317,7 @@ public class ManualRedactionService {
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId);
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
fileStatusService.setStatusReprocess(dossierId, fileId, 100);
|
||||
}
|
||||
}
|
||||
@ -324,7 +325,7 @@ public class ManualRedactionService {
|
||||
|
||||
public void deleteComment(String fileId, long commentId) {
|
||||
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId);
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
commentPersistenceService.softDelete(commentId, OffsetDateTime.now());
|
||||
|
||||
// update indicator
|
||||
@ -341,11 +342,17 @@ public class ManualRedactionService {
|
||||
if (idRemoval.isRemoveFromDictionary()) {
|
||||
|
||||
RedactionLog redactionLog = fileManagementStorageService.getRedactionLog(dossierId, fileId);
|
||||
RedactionLogEntry redactionLogEntry = redactionLog.getRedactionLogEntry()
|
||||
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(entry -> entry.getId().equals(idRemoval.getId().getId()))
|
||||
.findFirst()
|
||||
.get();
|
||||
.findFirst();
|
||||
|
||||
if(!redactionLogEntryOptional.isPresent()) {
|
||||
throw new NotFoundException("Annotation does not exist in redaction log.");
|
||||
}
|
||||
|
||||
var redactionLogEntry = redactionLogEntryOptional.get();
|
||||
|
||||
|
||||
if (annotationStatus == AnnotationStatus.APPROVED) {
|
||||
removeFromDictionary(redactionLogEntry.getTypeId(), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
@ -460,11 +467,17 @@ public class ManualRedactionService {
|
||||
|
||||
if (removeFromDictionary) {
|
||||
RedactionLog redactionLog = fileManagementStorageService.getRedactionLog(dossierId, fileId);
|
||||
RedactionLogEntry redactionLogEntry = redactionLog.getRedactionLogEntry()
|
||||
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(entry -> entry.getId().equals(annotationId))
|
||||
.findFirst()
|
||||
.get();
|
||||
.findFirst();
|
||||
|
||||
if(!redactionLogEntryOptional.isPresent()) {
|
||||
throw new NotFoundException("Annotation does not exist in redaction log.");
|
||||
}
|
||||
|
||||
var redactionLogEntry = redactionLogEntryOptional.get();
|
||||
|
||||
if (revert) {
|
||||
addToDictionary(redactionLogEntry.getTypeId(), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user