RED-7384: Ignore redactionLog entries on non existing pages for migration
This commit is contained in:
parent
88888545e5
commit
07d6fea992
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user