RED-7834: fix migration stuff
This commit is contained in:
parent
b73b3a74cf
commit
7f94f0c1e4
@ -60,7 +60,9 @@ public class EntityLogCreatorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public EntityLog createInitialEntityLog(AnalyzeRequest analyzeRequest, Document document, List<ManualEntity> notFoundManualEntities,
|
public EntityLog createInitialEntityLog(AnalyzeRequest analyzeRequest,
|
||||||
|
Document document,
|
||||||
|
List<ManualEntity> notFoundManualEntities,
|
||||||
DictionaryVersion dictionaryVersion,
|
DictionaryVersion dictionaryVersion,
|
||||||
long rulesVersion) {
|
long rulesVersion) {
|
||||||
|
|
||||||
@ -124,8 +126,8 @@ public class EntityLogCreatorService {
|
|||||||
|
|
||||||
List<EntityLogEntry> previousEntriesFromReAnalyzedSections = previousEntityLog.getEntityLogEntry()
|
List<EntityLogEntry> previousEntriesFromReAnalyzedSections = previousEntityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entry -> !entry.getType()
|
.filter(entry -> !entry.getType().equals(ImportedRedactionService.IMPORTED_REDACTION_TYPE) && (newEntityIds.contains(entry.getId()) || entry.getContainingNodeId()
|
||||||
.equals(ImportedRedactionService.IMPORTED_REDACTION_TYPE) && (newEntityIds.contains(entry.getId()) || entry.getContainingNodeId().isEmpty() || sectionsToReanalyseIds.contains(entry.getContainingNodeId().get(0))))
|
.isEmpty() || sectionsToReanalyseIds.contains(entry.getContainingNodeId().get(0))))
|
||||||
.toList();
|
.toList();
|
||||||
previousEntityLog.getEntityLogEntry().removeAll(previousEntriesFromReAnalyzedSections);
|
previousEntityLog.getEntityLogEntry().removeAll(previousEntriesFromReAnalyzedSections);
|
||||||
|
|
||||||
@ -176,7 +178,9 @@ public class EntityLogCreatorService {
|
|||||||
EntityLogEntry entityLogEntries = createEntityLogEntry(textEntity, dossierTemplateId);
|
EntityLogEntry entityLogEntries = createEntityLogEntry(textEntity, dossierTemplateId);
|
||||||
entityLogEntries.setId(positionOnPage.getId());
|
entityLogEntries.setId(positionOnPage.getId());
|
||||||
|
|
||||||
List<Position> rectanglesPerLine = positionOnPage.getRectanglePerLine().stream().map(rectangle2D -> new Position(rectangle2D, positionOnPage.getPage().getNumber()))
|
List<Position> rectanglesPerLine = positionOnPage.getRectanglePerLine()
|
||||||
|
.stream()
|
||||||
|
.map(rectangle2D -> new Position(rectangle2D, positionOnPage.getPage().getNumber()))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
entityLogEntries.setPositions(rectanglesPerLine);
|
entityLogEntries.setPositions(rectanglesPerLine);
|
||||||
@ -207,7 +211,8 @@ public class EntityLogCreatorService {
|
|||||||
.section(image.getManualOverwrite().getSection().orElse(image.getParent().toString()))
|
.section(image.getManualOverwrite().getSection().orElse(image.getParent().toString()))
|
||||||
.imageHasTransparency(image.isTransparent())
|
.imageHasTransparency(image.isTransparent())
|
||||||
.manualChanges(manualChangeFactory.toManualChangeList(image.getManualOverwrite().getManualChangeLog(), isHint))
|
.manualChanges(manualChangeFactory.toManualChangeList(image.getManualOverwrite().getManualChangeLog(), isHint))
|
||||||
.state(buildEntryState(image)).entryType(isHint ? EntryType.IMAGE_HINT : EntryType.IMAGE)
|
.state(buildEntryState(image))
|
||||||
|
.entryType(isHint ? EntryType.IMAGE_HINT : EntryType.IMAGE)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,7 @@ import com.iqser.red.service.redaction.v1.server.migration.RedactionLogToEntityL
|
|||||||
|
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
|
||||||
@Disabled
|
//@Disabled
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@Import(MigrationIntegrationTest.TestConfiguration.class)
|
@Import(MigrationIntegrationTest.TestConfiguration.class)
|
||||||
@ -143,16 +143,16 @@ public class MigrationIntegrationTest extends BuildDocumentIntegrationTest {
|
|||||||
if (p1.getPage() != p2.getPageNumber()) {
|
if (p1.getPage() != p2.getPageNumber()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Math.abs(p1.getHeight() - p2.getRectangle()[3]) > tolerance) {
|
if (Math.abs(p1.getHeight() - p2.h()) > tolerance) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Math.abs(p1.getWidth() - p2.getRectangle()[2]) > tolerance) {
|
if (Math.abs(p1.getWidth() - p2.w()) > tolerance) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Math.abs(p1.getTopLeft().getX() - p2.getRectangle()[0]) > tolerance) {
|
if (Math.abs(p1.getTopLeft().getX() - p2.x()) > tolerance) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Math.abs(p1.getTopLeft().getY() - p2.getRectangle()[1]) > tolerance) {
|
if (Math.abs(p1.getTopLeft().getY() - p2.y()) > tolerance) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,42 @@
|
|||||||
|
package com.iqser.red.service.redaction.v1.server;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import com.iqser.red.commons.jackson.ObjectMapperFactory;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLog;
|
||||||
|
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
|
||||||
|
public class RedactionLogCrawler {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SneakyThrows
|
||||||
|
public void findRedactionLogVersion0() {
|
||||||
|
|
||||||
|
String redactionLogsDir = "/home/kschuettler/Nextcloud/redaction_logs/";
|
||||||
|
Files.walk(Path.of(redactionLogsDir))
|
||||||
|
.map(Path::toFile)
|
||||||
|
.filter(File::isFile)
|
||||||
|
.filter(file -> file.toString().endsWith("redactionlog.json"))
|
||||||
|
.peek(System.out::println)
|
||||||
|
.map(this::parseRedactionLog)
|
||||||
|
.filter(log -> log.getAnalysisVersion() == 0)
|
||||||
|
.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
private RedactionLog parseRedactionLog(File file) {
|
||||||
|
|
||||||
|
var mapper = ObjectMapperFactory.create();
|
||||||
|
try (var in = new FileInputStream(file)) {
|
||||||
|
return mapper.readValue(in.readAllBytes(), RedactionLog.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user