RED-8773 - Wrong value for recategorized and forced logo - backport #330

Closed
corina.olariu.ext1 wants to merge 38 commits from RED-8773-bp into master
Showing only changes of commit 07d6fea992 - Show all commits

View File

@ -89,9 +89,10 @@ public class RedactionLogToEntityLogMigrationService {
.map(migrationEntity -> migrationEntity.toEntityLogEntry(oldToNewIDMapping)) .map(migrationEntity -> migrationEntity.toEntityLogEntry(oldToNewIDMapping))
.toList()); .toList());
if (getNumberOfApprovedEntries(redactionLog) != entityLog.getEntityLogEntry().size()) { if (getNumberOfApprovedEntries(redactionLog, document.getNumberOfPages()) != entityLog.getEntityLogEntry().size()) {
String message = String.format("Not all entities have been found during the migration redactionLog has %d entries and new entityLog %d", String message = String.format("Not all entities have been found during the migration redactionLog has %d entries and new entityLog %d",
redactionLog.getRedactionLogEntry().size(), redactionLog.getRedactionLogEntry()
.size(),
entityLog.getEntityLogEntry().size()); entityLog.getEntityLogEntry().size());
log.error(message); log.error(message);
throw new AssertionError(message); throw new AssertionError(message);
@ -135,9 +136,9 @@ public class RedactionLogToEntityLogMigrationService {
} }
private static long getNumberOfApprovedEntries(RedactionLog redactionLog) { private long getNumberOfApprovedEntries(RedactionLog redactionLog, int numberOfPages) {
return redactionLog.getRedactionLogEntry().size(); return redactionLog.getRedactionLogEntry().stream().filter(redactionLogEntry -> isOnExistingPage(redactionLogEntry, numberOfPages)).collect(Collectors.toList()).size();
} }
@ -250,6 +251,7 @@ public class RedactionLogToEntityLogMigrationService {
List<MigrationEntity> entitiesToMigrate = redactionLog.getRedactionLogEntry() List<MigrationEntity> entitiesToMigrate = redactionLog.getRedactionLogEntry()
.stream() .stream()
.filter(redactionLogEntry -> !redactionLogEntry.isImage()) .filter(redactionLogEntry -> !redactionLogEntry.isImage())
.filter(redactionLogEntry -> isOnExistingPage(redactionLogEntry, document.getNumberOfPages()))
.map(entry -> MigrationEntity.fromRedactionLogEntry(entry, dictionaryService.isHint(entry.getType(), dossierTemplateId), fileId)) .map(entry -> MigrationEntity.fromRedactionLogEntry(entry, dictionaryService.isHint(entry.getType(), dossierTemplateId), fileId))
.toList(); .toList();
@ -287,4 +289,18 @@ public class RedactionLogToEntityLogMigrationService {
return entitiesToMigrate; return entitiesToMigrate;
} }
private boolean isOnExistingPage(RedactionLogEntry redactionLogEntry, int numberOfPages){
var pages = redactionLogEntry.getPositions().stream().map(Rectangle::getPage).collect(Collectors.toSet());
for (int page: pages){
if(page > numberOfPages){
return false;
}
}
return true;
}
} }