RED-8702
This commit is contained in:
parent
4a22f97a88
commit
f6d169db43
@ -16,7 +16,7 @@ val layoutParserVersion = "0.96.0"
|
|||||||
val jacksonVersion = "2.15.2"
|
val jacksonVersion = "2.15.2"
|
||||||
val droolsVersion = "9.44.0.Final"
|
val droolsVersion = "9.44.0.Final"
|
||||||
val pdfBoxVersion = "3.0.0"
|
val pdfBoxVersion = "3.0.0"
|
||||||
val persistenceServiceVersion = "2.360.0"
|
val persistenceServiceVersion = "maverick-mongo"
|
||||||
val springBootStarterVersion = "3.1.5"
|
val springBootStarterVersion = "3.1.5"
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
@ -63,6 +63,8 @@ dependencies {
|
|||||||
|
|
||||||
implementation("org.reflections:reflections:0.10.2")
|
implementation("org.reflections:reflections:0.10.2")
|
||||||
|
|
||||||
|
//todo: remove
|
||||||
|
implementation("io.minio:minio:8.5.9")
|
||||||
|
|
||||||
testImplementation(project(":rules-management"))
|
testImplementation(project(":rules-management"))
|
||||||
testImplementation("org.apache.pdfbox:pdfbox:${pdfBoxVersion}")
|
testImplementation("org.apache.pdfbox:pdfbox:${pdfBoxVersion}")
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import org.springframework.data.mongodb.repository.config.EnableMongoRepositorie
|
|||||||
|
|
||||||
import com.iqser.red.service.dictionarymerge.commons.DictionaryMergeService;
|
import com.iqser.red.service.dictionarymerge.commons.DictionaryMergeService;
|
||||||
import com.iqser.red.service.redaction.v1.server.client.RulesClient;
|
import com.iqser.red.service.redaction.v1.server.client.RulesClient;
|
||||||
|
import com.iqser.red.service.redaction.v1.server.mongo.CascadeSaveMongoEventListener;
|
||||||
import com.iqser.red.storage.commons.StorageAutoConfiguration;
|
import com.iqser.red.storage.commons.StorageAutoConfiguration;
|
||||||
import com.knecon.fforesight.tenantcommons.MultiTenancyAutoConfiguration;
|
import com.knecon.fforesight.tenantcommons.MultiTenancyAutoConfiguration;
|
||||||
|
|
||||||
@ -110,4 +111,10 @@ public class Application {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public CascadeSaveMongoEventListener cascadingMongoEventListener() {
|
||||||
|
return new CascadeSaveMongoEventListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -227,7 +227,7 @@ public final class MigrationEntity {
|
|||||||
|
|
||||||
List<Position> positions = getPositionsFromOverride(image).orElse(List.of(new Position(image.getPosition(), image.getPage().getNumber())));
|
List<Position> positions = getPositionsFromOverride(image).orElse(List.of(new Position(image.getPosition(), image.getPage().getNumber())));
|
||||||
return EntityLogEntry.builder()
|
return EntityLogEntry.builder()
|
||||||
.id(image.getId())
|
.entryId(image.getId())
|
||||||
.value(image.value())
|
.value(image.value())
|
||||||
.type(image.type())
|
.type(image.type())
|
||||||
.reason(image.buildReasonWithManualChangeDescriptions())
|
.reason(image.buildReasonWithManualChangeDescriptions())
|
||||||
@ -252,7 +252,7 @@ public final class MigrationEntity {
|
|||||||
public EntityLogEntry createEntityLogEntry(PrecursorEntity precursorEntity) {
|
public EntityLogEntry createEntityLogEntry(PrecursorEntity precursorEntity) {
|
||||||
|
|
||||||
return EntityLogEntry.builder()
|
return EntityLogEntry.builder()
|
||||||
.id(precursorEntity.getId())
|
.entryId(precursorEntity.getId())
|
||||||
.reason(precursorEntity.buildReasonWithManualChangeDescriptions())
|
.reason(precursorEntity.buildReasonWithManualChangeDescriptions())
|
||||||
.legalBasis(precursorEntity.legalBasis())
|
.legalBasis(precursorEntity.legalBasis())
|
||||||
.value(precursorEntity.value())
|
.value(precursorEntity.value())
|
||||||
@ -285,7 +285,7 @@ public final class MigrationEntity {
|
|||||||
assert entity.getPositionsOnPagePerPage().size() == 1;
|
assert entity.getPositionsOnPagePerPage().size() == 1;
|
||||||
List<Position> rectanglesPerLine = getRectanglesPerLine(entity);
|
List<Position> rectanglesPerLine = getRectanglesPerLine(entity);
|
||||||
return EntityLogEntry.builder()
|
return EntityLogEntry.builder()
|
||||||
.id(entity.getId())
|
.entryId(entity.getId())
|
||||||
.positions(rectanglesPerLine)
|
.positions(rectanglesPerLine)
|
||||||
.reason(entity.buildReasonWithManualChangeDescriptions())
|
.reason(entity.buildReasonWithManualChangeDescriptions())
|
||||||
.legalBasis(entity.legalBasis())
|
.legalBasis(entity.legalBasis())
|
||||||
|
|||||||
@ -92,7 +92,7 @@ public class PrecursorEntity implements IEntity {
|
|||||||
.toList();
|
.toList();
|
||||||
EntityType entityType = getEntityType(entityLogEntry.getEntryType());
|
EntityType entityType = getEntityType(entityLogEntry.getEntryType());
|
||||||
return PrecursorEntity.builder()
|
return PrecursorEntity.builder()
|
||||||
.id(entityLogEntry.getId())
|
.id(entityLogEntry.getEntryId())
|
||||||
.value(entityLogEntry.getValue())
|
.value(entityLogEntry.getValue())
|
||||||
.entityPosition(rectangleWithPages)
|
.entityPosition(rectangleWithPages)
|
||||||
.ruleIdentifier(entityLogEntry.getMatchedRule())
|
.ruleIdentifier(entityLogEntry.getMatchedRule())
|
||||||
|
|||||||
@ -71,7 +71,7 @@ public class Entity {
|
|||||||
public static Entity fromEntityLogEntry(EntityLogEntry e, Document document) {
|
public static Entity fromEntityLogEntry(EntityLogEntry e, Document document) {
|
||||||
|
|
||||||
return Entity.builder()
|
return Entity.builder()
|
||||||
.id(e.getId())
|
.id(e.getEntryId())
|
||||||
.type(e.getType())
|
.type(e.getType())
|
||||||
.entryType(e.getEntryType())
|
.entryType(e.getEntryType())
|
||||||
.state(e.getState())
|
.state(e.getState())
|
||||||
|
|||||||
@ -0,0 +1,58 @@
|
|||||||
|
package com.iqser.red.service.redaction.v1.server.mongo;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InaccessibleObjectException;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import org.bouncycastle.util.Iterable;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.data.mongodb.core.MongoOperations;
|
||||||
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||||
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.CascadeSave;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CascadeCallback implements ReflectionUtils.FieldCallback {
|
||||||
|
|
||||||
|
private Object source;
|
||||||
|
private MongoTemplate mongoTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doWith(@NotNull final Field field) throws IllegalArgumentException, IllegalAccessException {
|
||||||
|
|
||||||
|
try {
|
||||||
|
ReflectionUtils.makeAccessible(field);
|
||||||
|
|
||||||
|
if (field.isAnnotationPresent(DBRef.class) && field.isAnnotationPresent(CascadeSave.class)) {
|
||||||
|
final Object fieldValue = field.get(getSource());
|
||||||
|
|
||||||
|
if(Collection.class.isAssignableFrom(field.getType())) {
|
||||||
|
Collection<?> collection = (Collection<?>) fieldValue;
|
||||||
|
mongoTemplate.insertAll(collection);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
if (fieldValue != null) {
|
||||||
|
//final FieldCallback callback = new FieldCallback();
|
||||||
|
//ReflectionUtils.doWithFields(fieldValue.getClass(), callback);
|
||||||
|
|
||||||
|
mongoTemplate.insert(fieldValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (InaccessibleObjectException ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.iqser.red.service.redaction.v1.server.mongo;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.mongodb.core.MongoOperations;
|
||||||
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent;
|
||||||
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
|
public class CascadeSaveMongoEventListener extends AbstractMongoEventListener<Object> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MongoTemplate mongoTemplate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBeforeConvert(BeforeConvertEvent<Object> event) {
|
||||||
|
Object source = event.getSource();
|
||||||
|
ReflectionUtils.doWithFields(source.getClass(),
|
||||||
|
new CascadeCallback(source, mongoTemplate));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -31,4 +31,5 @@ public class EntityLogDocumentService {
|
|||||||
public boolean entityLogDocumentExists(String id) {
|
public boolean entityLogDocumentExists(String id) {
|
||||||
return entityLogDocumentRepository.existsById(id);
|
return entityLogDocumentRepository.existsById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.iqser.red.service.redaction.v1.server.mongo;
|
||||||
|
|
||||||
|
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
|
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
||||||
|
|
||||||
|
public interface EntityLogMongoRepository extends MongoRepository<EntityLog, String> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.iqser.red.service.redaction.v1.server.mongo;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class EntityLogMongoService {
|
||||||
|
|
||||||
|
private final EntityLogMongoRepository entityLogMongoRepository;
|
||||||
|
|
||||||
|
|
||||||
|
public EntityLogMongoService(EntityLogMongoRepository entityLogMongoRepository) {this.entityLogMongoRepository = entityLogMongoRepository;}
|
||||||
|
|
||||||
|
public EntityLog saveEntityLogDocument(EntityLog entityLogDocument) {
|
||||||
|
return entityLogMongoRepository.save(entityLogDocument);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<EntityLog> findEntityLogDocumentById(String id) {
|
||||||
|
return entityLogMongoRepository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean entityLogDocumentExists(String id) {
|
||||||
|
return entityLogMongoRepository.existsById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.iqser.red.service.redaction.v1.server.mongo;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InaccessibleObjectException;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class FieldCallback implements ReflectionUtils.FieldCallback {
|
||||||
|
|
||||||
|
private boolean idFound;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doWith(@NotNull final Field field) throws IllegalArgumentException {
|
||||||
|
|
||||||
|
try {
|
||||||
|
ReflectionUtils.makeAccessible(field);
|
||||||
|
|
||||||
|
if (field.isAnnotationPresent(Id.class)) {
|
||||||
|
idFound = true;
|
||||||
|
}
|
||||||
|
} catch (InaccessibleObjectException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +18,6 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.AnalyzeResu
|
|||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.FileAttribute;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.FileAttribute;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.RuleFileType;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.RuleFileType;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLog;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLog;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogChanges;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogChanges;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactions;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactions;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;
|
||||||
@ -39,6 +38,7 @@ import com.iqser.red.service.redaction.v1.server.model.dictionary.DictionaryIncr
|
|||||||
import com.iqser.red.service.redaction.v1.server.model.dictionary.DictionaryVersion;
|
import com.iqser.red.service.redaction.v1.server.model.dictionary.DictionaryVersion;
|
||||||
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Document;
|
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Document;
|
||||||
import com.iqser.red.service.redaction.v1.server.model.document.nodes.SemanticNode;
|
import com.iqser.red.service.redaction.v1.server.model.document.nodes.SemanticNode;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
||||||
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocument;
|
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocument;
|
||||||
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocumentService;
|
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocumentService;
|
||||||
import com.iqser.red.service.redaction.v1.server.service.document.DocumentGraphMapper;
|
import com.iqser.red.service.redaction.v1.server.service.document.DocumentGraphMapper;
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public class EntityChangeLogService {
|
|||||||
|
|
||||||
for (EntityLogEntry entityLogEntry : newEntityLogEntries) {
|
for (EntityLogEntry entityLogEntry : newEntityLogEntries) {
|
||||||
Optional<EntityLogEntry> optionalPreviousEntity = previousEntityLogEntries.stream()
|
Optional<EntityLogEntry> optionalPreviousEntity = previousEntityLogEntries.stream()
|
||||||
.filter(entry -> entry.getId().equals(entityLogEntry.getId()))
|
.filter(entry -> entry.getEntryId().equals(entityLogEntry.getEntryId()))
|
||||||
.findAny();
|
.findAny();
|
||||||
if (optionalPreviousEntity.isEmpty()) {
|
if (optionalPreviousEntity.isEmpty()) {
|
||||||
hasChanges = true;
|
hasChanges = true;
|
||||||
@ -66,10 +66,10 @@ public class EntityChangeLogService {
|
|||||||
private void addRemovedEntriesAsRemoved(List<EntityLogEntry> previousEntityLogEntries, List<EntityLogEntry> newEntityLogEntries, int analysisNumber, OffsetDateTime now) {
|
private void addRemovedEntriesAsRemoved(List<EntityLogEntry> previousEntityLogEntries, List<EntityLogEntry> newEntityLogEntries, int analysisNumber, OffsetDateTime now) {
|
||||||
|
|
||||||
Set<String> existingIds = newEntityLogEntries.stream()
|
Set<String> existingIds = newEntityLogEntries.stream()
|
||||||
.map(EntityLogEntry::getId)
|
.map(EntityLogEntry::getEntryId)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
List<EntityLogEntry> removedEntries = previousEntityLogEntries.stream()
|
List<EntityLogEntry> removedEntries = previousEntityLogEntries.stream()
|
||||||
.filter(entry -> !existingIds.contains(entry.getId()))
|
.filter(entry -> !existingIds.contains(entry.getEntryId()))
|
||||||
.toList();
|
.toList();
|
||||||
removedEntries.forEach(entry -> entry.getChanges().add(new Change(analysisNumber, ChangeType.REMOVED, now)));
|
removedEntries.forEach(entry -> entry.getChanges().add(new Change(analysisNumber, ChangeType.REMOVED, now)));
|
||||||
removedEntries.forEach(entry -> entry.setState(EntryState.REMOVED));
|
removedEntries.forEach(entry -> entry.setState(EntryState.REMOVED));
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public class EntityLogCreatorService {
|
|||||||
|
|
||||||
entityChangeLogService.computeChanges(previousExistingEntityLogEntries, entityLogEntries, analyzeRequest.getAnalysisNumber());
|
entityChangeLogService.computeChanges(previousExistingEntityLogEntries, entityLogEntries, analyzeRequest.getAnalysisNumber());
|
||||||
|
|
||||||
return new EntityLog(redactionServiceSettings.getAnalysisVersion(),
|
return new EntityLog(analyzeRequest.getDossierId(), analyzeRequest.getFileId(), redactionServiceSettings.getAnalysisVersion(),
|
||||||
analyzeRequest.getAnalysisNumber(),
|
analyzeRequest.getAnalysisNumber(),
|
||||||
entityLogEntries,
|
entityLogEntries,
|
||||||
toEntityLogLegalBasis(legalBasis),
|
toEntityLogLegalBasis(legalBasis),
|
||||||
@ -118,12 +118,12 @@ public class EntityLogCreatorService {
|
|||||||
.get(0)))
|
.get(0)))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
Set<String> newEntityIds = newEntityLogEntries.stream()
|
Set<String> newEntityIds = newEntityLogEntries.stream()
|
||||||
.map(EntityLogEntry::getId)
|
.map(EntityLogEntry::getEntryId)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
List<EntityLogEntry> previousEntriesFromReAnalyzedSections = previousEntityLog.getEntityLogEntry()
|
List<EntityLogEntry> previousEntriesFromReAnalyzedSections = previousEntityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entry -> (newEntityIds.contains(entry.getId()) || entry.getContainingNodeId().isEmpty() || sectionsToReanalyseIds.contains(entry.getContainingNodeId()
|
.filter(entry -> (newEntityIds.contains(entry.getEntryId()) || entry.getContainingNodeId().isEmpty() || sectionsToReanalyseIds.contains(entry.getContainingNodeId()
|
||||||
.get(0))))
|
.get(0))))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
previousEntityLog.getEntityLogEntry().removeAll(previousEntriesFromReAnalyzedSections);
|
previousEntityLog.getEntityLogEntry().removeAll(previousEntriesFromReAnalyzedSections);
|
||||||
@ -173,7 +173,7 @@ public class EntityLogCreatorService {
|
|||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
// set the ID from the positions, since it might contain a "-" with the page number if the entity is split across multiple pages
|
// set the ID from the positions, since it might contain a "-" with the page number if the entity is split across multiple pages
|
||||||
entityLogEntry.setId(positionOnPage.getId());
|
entityLogEntry.setEntryId(positionOnPage.getId());
|
||||||
entityLogEntry.setPositions(rectanglesPerLine);
|
entityLogEntry.setPositions(rectanglesPerLine);
|
||||||
entityLogEntries.add(entityLogEntry);
|
entityLogEntries.add(entityLogEntry);
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ public class EntityLogCreatorService {
|
|||||||
|
|
||||||
boolean isHint = dictionaryService.isHint(image.type(), dossierTemplateId);
|
boolean isHint = dictionaryService.isHint(image.type(), dossierTemplateId);
|
||||||
return EntityLogEntry.builder()
|
return EntityLogEntry.builder()
|
||||||
.id(image.getId())
|
.entryId(image.getId())
|
||||||
.value(image.value())
|
.value(image.value())
|
||||||
.type(image.type())
|
.type(image.type())
|
||||||
.reason(image.buildReasonWithManualChangeDescriptions())
|
.reason(image.buildReasonWithManualChangeDescriptions())
|
||||||
@ -214,7 +214,7 @@ public class EntityLogCreatorService {
|
|||||||
.orElse(precursorEntity.getType());
|
.orElse(precursorEntity.getType());
|
||||||
boolean isHint = isHint(precursorEntity.getEntityType());
|
boolean isHint = isHint(precursorEntity.getEntityType());
|
||||||
return EntityLogEntry.builder()
|
return EntityLogEntry.builder()
|
||||||
.id(precursorEntity.getId())
|
.entryId(precursorEntity.getId())
|
||||||
.reason(precursorEntity.buildReasonWithManualChangeDescriptions())
|
.reason(precursorEntity.buildReasonWithManualChangeDescriptions())
|
||||||
.legalBasis(precursorEntity.legalBasis())
|
.legalBasis(precursorEntity.legalBasis())
|
||||||
.value(precursorEntity.value())
|
.value(precursorEntity.value())
|
||||||
|
|||||||
@ -79,7 +79,7 @@ public class UnprocessedChangesService {
|
|||||||
.toList();
|
.toList();
|
||||||
List<PrecursorEntity> manualEntitiesToBeResized = previousEntityLog.getEntityLogEntry()
|
List<PrecursorEntity> manualEntitiesToBeResized = previousEntityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entityLogEntry -> resizeIds.contains(entityLogEntry.getId()))
|
.filter(entityLogEntry -> resizeIds.contains(entityLogEntry.getEntryId()))
|
||||||
.toList()
|
.toList()
|
||||||
.stream()
|
.stream()
|
||||||
.map(PrecursorEntity::fromEntityLogEntry)
|
.map(PrecursorEntity::fromEntityLogEntry)
|
||||||
|
|||||||
@ -53,7 +53,7 @@ public class SectionFinderService {
|
|||||||
Set<String> relevantManuallyModifiedAnnotationIds = getRelevantManuallyModifiedAnnotationIds(analyzeRequest.getManualRedactions());
|
Set<String> relevantManuallyModifiedAnnotationIds = getRelevantManuallyModifiedAnnotationIds(analyzeRequest.getManualRedactions());
|
||||||
Set<Integer> sectionsToReanalyse = new HashSet<>();
|
Set<Integer> sectionsToReanalyse = new HashSet<>();
|
||||||
for (EntityLogEntry entry : entityLog.getEntityLogEntry()) {
|
for (EntityLogEntry entry : entityLog.getEntityLogEntry()) {
|
||||||
if (relevantManuallyModifiedAnnotationIds.contains(entry.getId())) {
|
if (relevantManuallyModifiedAnnotationIds.contains(entry.getEntryId())) {
|
||||||
if (entry.getContainingNodeId().isEmpty()) {
|
if (entry.getContainingNodeId().isEmpty()) {
|
||||||
continue; // Empty list means either Entity has not been found or it is between main sections. Thus, this might lead to wrong reanalysis.
|
continue; // Empty list means either Entity has not been found or it is between main sections. Thus, this might lead to wrong reanalysis.
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,13 +10,13 @@ import org.springframework.cache.annotation.Cacheable;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLog;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLog;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactions;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactions;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactionsPerPage;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactionsPerPage;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLog;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLog;
|
||||||
import com.iqser.red.service.redaction.v1.server.client.model.NerEntitiesModel;
|
import com.iqser.red.service.redaction.v1.server.client.model.NerEntitiesModel;
|
||||||
import com.iqser.red.service.redaction.v1.server.model.document.DocumentData;
|
import com.iqser.red.service.redaction.v1.server.model.document.DocumentData;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
||||||
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocumentService;
|
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocumentService;
|
||||||
import com.iqser.red.service.redaction.v1.server.utils.exception.NotFoundException;
|
import com.iqser.red.service.redaction.v1.server.utils.exception.NotFoundException;
|
||||||
import com.iqser.red.storage.commons.exception.StorageObjectDoesNotExist;
|
import com.iqser.red.storage.commons.exception.StorageObjectDoesNotExist;
|
||||||
|
|||||||
@ -266,7 +266,7 @@ public class MigrationIntegrationTest extends BuildDocumentIntegrationTest {
|
|||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
EntityLogEntry entityLogEntry = entityLog.getEntityLogEntry()
|
EntityLogEntry entityLogEntry = entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entry -> entry.getId().equals(newId))
|
.filter(entry -> entry.getEntryId().equals(newId))
|
||||||
.findAny()
|
.findAny()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,12 @@ package com.iqser.red.service.redaction.v1.server;
|
|||||||
|
|
||||||
import static com.mongodb.client.model.Filters.eq;
|
import static com.mongodb.client.model.Filters.eq;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
|
import org.bson.conversions.Bson;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
@ -17,12 +22,17 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.context.annotation.FilterType;
|
import org.springframework.context.annotation.FilterType;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration;
|
import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.iqser.red.commons.jackson.ObjectMapperFactory;
|
import com.iqser.red.commons.jackson.ObjectMapperFactory;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
||||||
|
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocument;
|
||||||
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocumentRepository;
|
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocumentRepository;
|
||||||
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocumentService;
|
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocumentService;
|
||||||
import com.iqser.red.storage.commons.StorageAutoConfiguration;
|
import com.iqser.red.storage.commons.StorageAutoConfiguration;
|
||||||
@ -32,6 +42,9 @@ import com.mongodb.client.MongoClient;
|
|||||||
import com.mongodb.client.MongoClients;
|
import com.mongodb.client.MongoClients;
|
||||||
import com.mongodb.client.MongoCollection;
|
import com.mongodb.client.MongoCollection;
|
||||||
import com.mongodb.client.MongoDatabase;
|
import com.mongodb.client.MongoDatabase;
|
||||||
|
import com.mongodb.client.model.Aggregates;
|
||||||
|
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
|
||||||
public class MyMongoTest {
|
public class MyMongoTest {
|
||||||
|
|
||||||
@ -39,10 +52,10 @@ public class MyMongoTest {
|
|||||||
private static final String PORT = "27017";
|
private static final String PORT = "27017";
|
||||||
private static final String DATABASE = "redaction";
|
private static final String DATABASE = "redaction";
|
||||||
private static final String USERNAME = "root";
|
private static final String USERNAME = "root";
|
||||||
private static final String PASSWORD = "a2sm7FUBAfLAjfIm1KubeFMAsrIt1pF4";
|
private static final String PASSWORD = "AP8ckozpAl55JDAAFR4rxpbPj1WXdBTL";
|
||||||
|
|
||||||
private static final String TEST_FILE_ID = "b2cbdd4dca0aa1aa0ebbfc5cc1462df0";
|
private static final String TEST_FILE_ID = "b2cbdd4dca0aa1aa0ebbfc5cc1462df0";
|
||||||
public static final String COLLECTION_ENTITY_LOG = "entity-log";
|
public static final String COLLECTION_ENTITY_LOG = "entity-logs";
|
||||||
|
|
||||||
|
|
||||||
private static final String CONNECTION_STRING = String.format("mongodb://%s:%s@%s:%s/", USERNAME, PASSWORD, HOSTNAME, PORT);
|
private static final String CONNECTION_STRING = String.format("mongodb://%s:%s@%s:%s/", USERNAME, PASSWORD, HOSTNAME, PORT);
|
||||||
@ -55,7 +68,7 @@ public class MyMongoTest {
|
|||||||
try (MongoClient mongoClient = MongoClients.create(CONNECTION_STRING)) {
|
try (MongoClient mongoClient = MongoClients.create(CONNECTION_STRING)) {
|
||||||
MongoDatabase database = mongoClient.getDatabase(DATABASE);
|
MongoDatabase database = mongoClient.getDatabase(DATABASE);
|
||||||
MongoCollection<Document> collection = database.getCollection(COLLECTION_ENTITY_LOG);
|
MongoCollection<Document> collection = database.getCollection(COLLECTION_ENTITY_LOG);
|
||||||
Document doc = collection.find(eq("id", TEST_FILE_ID)).first();
|
Document doc = collection.find(eq("_id", TEST_FILE_ID)).first();
|
||||||
if (doc != null) {
|
if (doc != null) {
|
||||||
System.out.println("Found doc with _id: " + doc.get("_id"));
|
System.out.println("Found doc with _id: " + doc.get("_id"));
|
||||||
} else {
|
} else {
|
||||||
@ -72,7 +85,7 @@ public class MyMongoTest {
|
|||||||
MongoTemplate mongoTemplate = new MongoTemplate(mongoClient, DATABASE);
|
MongoTemplate mongoTemplate = new MongoTemplate(mongoClient, DATABASE);
|
||||||
|
|
||||||
MongoCollection<Document> collection = mongoTemplate.getCollection(COLLECTION_ENTITY_LOG);
|
MongoCollection<Document> collection = mongoTemplate.getCollection(COLLECTION_ENTITY_LOG);
|
||||||
Document doc = collection.find(eq("id", TEST_FILE_ID)).first();
|
Document doc = collection.find(eq("_id", TEST_FILE_ID)).first();
|
||||||
if (doc != null) {
|
if (doc != null) {
|
||||||
System.out.println("Found doc with _id: " + doc.get("_id"));
|
System.out.println("Found doc with _id: " + doc.get("_id"));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -1,10 +1,7 @@
|
|||||||
package com.iqser.red.service.redaction.v1.server;
|
package com.iqser.red.service.redaction.v1.server;
|
||||||
|
|
||||||
import static com.mongodb.client.model.Filters.eq;
|
import java.io.ByteArrayInputStream;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import java.io.InputStream;
|
||||||
import static org.assertj.core.api.InstanceOfAssertFactories.FILE;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
|
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -12,7 +9,6 @@ import java.util.Date;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.kie.api.runtime.KieContainer;
|
import org.kie.api.runtime.KieContainer;
|
||||||
@ -30,10 +26,8 @@ import org.springframework.context.annotation.ComponentScan;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.FilterType;
|
import org.springframework.context.annotation.FilterType;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
||||||
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
|
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
|
||||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
@ -41,22 +35,19 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.iqser.red.commons.jackson.ObjectMapperFactory;
|
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
|
||||||
import com.iqser.red.service.redaction.v1.server.client.DictionaryClient;
|
import com.iqser.red.service.redaction.v1.server.client.DictionaryClient;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
||||||
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocument;
|
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocument;
|
||||||
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocumentRepository;
|
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocumentRepository;
|
||||||
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocumentService;
|
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogDocumentService;
|
||||||
import com.iqser.red.storage.commons.StorageAutoConfiguration;
|
import com.iqser.red.service.redaction.v1.server.mongo.EntityLogMongoService;
|
||||||
import com.iqser.red.storage.commons.service.StorageService;
|
import com.iqser.red.service.redaction.v1.server.mongo._EntityLogDocumentRepository;
|
||||||
import com.iqser.red.storage.commons.utils.FileSystemBackedStorageService;
|
import com.iqser.red.storage.commons.service.StorageServiceImpl;
|
||||||
import com.knecon.fforesight.service.layoutparser.processor.LayoutParsingServiceProcessorConfiguration;
|
import com.knecon.fforesight.service.layoutparser.processor.LayoutParsingServiceProcessorConfiguration;
|
||||||
import com.knecon.fforesight.tenantcommons.TenantsClient;
|
import com.knecon.fforesight.tenantcommons.TenantsClient;
|
||||||
import com.mongodb.client.MongoClient;
|
|
||||||
import com.mongodb.client.MongoClients;
|
|
||||||
import com.mongodb.client.MongoCollection;
|
|
||||||
import com.mongodb.client.MongoDatabase;
|
|
||||||
|
|
||||||
|
import io.minio.MinioClient;
|
||||||
|
import io.minio.PutObjectArgs;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@ -81,11 +72,11 @@ public class MyOtherMongoTest {
|
|||||||
private static final String HOSTNAME = "localhost";
|
private static final String HOSTNAME = "localhost";
|
||||||
private static final String PORT = "27017";
|
private static final String PORT = "27017";
|
||||||
private static final String DATABASE = "redaction";
|
private static final String DATABASE = "redaction";
|
||||||
private static final String USERNAME = "user";
|
private static final String USERNAME = "root";
|
||||||
private static final String PASSWORD = "password";
|
private static final String PASSWORD = "AP8ckozpAl55JDAAFR4rxpbPj1WXdBTL";
|
||||||
|
|
||||||
private static final String TEST_FILE_ID = "b2cbdd4dca0aa1aa0ebbfc5cc1462df0";
|
private static final String TEST_FILE_ID = "b2cbdd4dca0aa1aa0ebbfc5cc1462df0";
|
||||||
public static final String COLLECTION_ENTITY_LOG = "entity-log";
|
public static final String COLLECTION_ENTITY_LOG = "entity-logs";
|
||||||
|
|
||||||
private static final String CONNECTION_STRING = String.format("mongodb://%s:%s@%s:%s/", USERNAME, PASSWORD, HOSTNAME, PORT);
|
private static final String CONNECTION_STRING = String.format("mongodb://%s:%s@%s:%s/", USERNAME, PASSWORD, HOSTNAME, PORT);
|
||||||
|
|
||||||
@ -95,18 +86,15 @@ public class MyOtherMongoTest {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private EntityLogDocumentService entityLogDocumentService;
|
private EntityLogDocumentService entityLogDocumentService;
|
||||||
|
|
||||||
@Configuration
|
@Autowired
|
||||||
@EnableAutoConfiguration(exclude = {RabbitAutoConfiguration.class})
|
private StorageServiceImpl storageService;
|
||||||
public static class RedactionIntegrationTestConfiguration {
|
|
||||||
|
|
||||||
@Bean
|
@Autowired
|
||||||
@Primary
|
private _EntityLogDocumentRepository _entityLogDocumentRepository;
|
||||||
public StorageService inmemoryStorage() {
|
|
||||||
|
|
||||||
return new FileSystemBackedStorageService(ObjectMapperFactory.create());
|
@Autowired
|
||||||
}
|
private EntityLogMongoService entityLogMongoService;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -122,25 +110,133 @@ public class MyOtherMongoTest {
|
|||||||
|
|
||||||
entityLogDocumentService.saveEntityLogDocument(entityLogDocument);
|
entityLogDocumentService.saveEntityLogDocument(entityLogDocument);
|
||||||
|
|
||||||
Optional<EntityLogDocument> found = entityLogDocumentService.findEntityLogDocumentById(TEST_FILE_ID);
|
//Optional<EntityLogDocument> found = entityLogDocumentService.findEntityLogDocumentById(TEST_FILE_ID);
|
||||||
assert(found.isPresent());
|
//assert(found.isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SneakyThrows
|
||||||
|
public void testEntityLogDocumentRepoUsingTemplate() {
|
||||||
|
|
||||||
|
var file = new ClassPathResource(String.format("mongo/%s.ENTITY_LOG.json", TEST_FILE_ID));
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
|
|
||||||
|
EntityLog entityLog = objectMapper.readValue(file.getInputStream(), EntityLog.class);
|
||||||
|
EntityLogDocument entityLogDocument = new EntityLogDocument(TEST_FILE_ID, entityLog);
|
||||||
|
|
||||||
|
_entityLogDocumentRepository.saveEntityLogDocument(entityLogDocument);
|
||||||
|
|
||||||
|
//Optional<EntityLogDocument> found = entityLogDocumentService.findEntityLogDocumentById(TEST_FILE_ID);
|
||||||
|
//assert(found.isPresent());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SneakyThrows
|
||||||
|
public void testEntityLogDocumentRepoUsingTemplateEmpty() {
|
||||||
|
|
||||||
|
var file = new ClassPathResource(String.format("mongo/%s.ENTITY_LOG.json", TEST_FILE_ID));
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
|
|
||||||
|
EntityLogDocument entityLogDocument = new EntityLogDocument(TEST_FILE_ID, new EntityLog());
|
||||||
|
|
||||||
|
_entityLogDocumentRepository.saveEntityLogDocument(entityLogDocument);
|
||||||
|
|
||||||
|
//Optional<EntityLogDocument> found = entityLogDocumentService.findEntityLogDocumentById(TEST_FILE_ID);
|
||||||
|
//assert(found.isPresent());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SneakyThrows
|
||||||
|
public void testSaveEntityLogDocument() {
|
||||||
|
|
||||||
|
var file = new ClassPathResource(String.format("mongo/%s.ENTITY_LOG.json", TEST_FILE_ID));
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
|
|
||||||
|
EntityLog entityLog = objectMapper.readValue(file.getInputStream(), EntityLog.class);
|
||||||
|
|
||||||
|
entityLogMongoService.saveEntityLogDocument(entityLog);
|
||||||
|
|
||||||
|
//Optional<EntityLogDocument> found = entityLogDocumentService.findEntityLogDocumentById(TEST_FILE_ID);
|
||||||
|
//assert(found.isPresent());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SneakyThrows
|
||||||
|
public void testFindEntityLogDocumentById() {
|
||||||
|
|
||||||
|
Optional<EntityLog> entityLogDocumentById = entityLogMongoService.findEntityLogDocumentById(TEST_FILE_ID);
|
||||||
|
assert(entityLogDocumentById.isPresent());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SneakyThrows
|
||||||
|
public void testRedactionStorageService() {
|
||||||
|
|
||||||
|
var file = new ClassPathResource(String.format("mongo/%s.ENTITY_LOG.json", TEST_FILE_ID));
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
|
|
||||||
|
EntityLog entityLog = objectMapper.readValue(file.getInputStream(), EntityLog.class);
|
||||||
|
EntityLogDocument entityLogDocument = new EntityLogDocument(TEST_FILE_ID, entityLog);
|
||||||
|
|
||||||
|
String jsonData = objectMapper.writeValueAsString(entityLogDocument);
|
||||||
|
// Convert JSON data to InputStream
|
||||||
|
InputStream jsonDataStream = new ByteArrayInputStream(jsonData.getBytes());
|
||||||
|
|
||||||
|
minioInsert(jsonDataStream, jsonData.length());
|
||||||
|
|
||||||
|
//Optional<EntityLogDocument> found = entityLogDocumentService.findEntityLogDocumentById(TEST_FILE_ID);
|
||||||
|
//assert(found.isPresent());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void minioInsert(InputStream inputStream, int length) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
MinioClient minioClient = MinioClient.builder()
|
||||||
|
.endpoint("http://localhost:9000")
|
||||||
|
.credentials("L2U4tR5Beaqh6UHPwvtDKTJSxWBXIiya", "Spbv4vleaFnIrSiLLG3AhbdQk6DMraBQ")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
String contentType = "application/json";
|
||||||
|
|
||||||
|
minioClient.putObject(
|
||||||
|
PutObjectArgs.builder()
|
||||||
|
.bucket(DATABASE)
|
||||||
|
.object(TEST_FILE_ID)
|
||||||
|
.stream(inputStream, length, -1)
|
||||||
|
.contentType(contentType)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
|
System.out.println("JSON file uploaded successfully!");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableMongoRepositories
|
@EnableMongoRepositories
|
||||||
@EnableAutoConfiguration(exclude = {RabbitAutoConfiguration.class})
|
@EnableAutoConfiguration(exclude = {RabbitAutoConfiguration.class})
|
||||||
@Import({LayoutParsingServiceProcessorConfiguration.class})
|
@Import({LayoutParsingServiceProcessorConfiguration.class})
|
||||||
@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = StorageAutoConfiguration.class)})
|
@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE)})
|
||||||
public static class MongoTestConfiguration {
|
public static class MongoTestConfiguration {
|
||||||
|
|
||||||
@Bean
|
|
||||||
@Primary
|
|
||||||
public StorageService inmemoryStorage() {
|
|
||||||
|
|
||||||
return new FileSystemBackedStorageService(ObjectMapperFactory.create());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MongoCustomConversions mongoCustomConversions() {
|
public MongoCustomConversions mongoCustomConversions() {
|
||||||
return new MongoCustomConversions(Arrays.asList(new MongoOffsetDateTimeWriter(), new MongoOffsetDateTimeReader()
|
return new MongoCustomConversions(Arrays.asList(new MongoOffsetDateTimeWriter(), new MongoOffsetDateTimeReader()
|
||||||
@ -182,11 +278,14 @@ public class MyOtherMongoTest {
|
|||||||
|
|
||||||
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
|
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
|
||||||
|
|
||||||
TestPropertyValues.of("MONGODB_HOST=" + HOSTNAME, "MONGODB_PORT=" + PORT, "MONGODB_USERNAME=" + USERNAME, "MONGODB_PASSWORD=" + PASSWORD)
|
TestPropertyValues.of("MONGODB_HOST=" + HOSTNAME, "MONGODB_PORT=" + PORT, "MONGODB_USER=" + USERNAME, "MONGODB_PASSWORD=" + PASSWORD,
|
||||||
|
"storage.bucket=name=redaction", "storage.endpoint=http://localhost:9000",
|
||||||
|
"storage.key=L2U4tR5Beaqh6UHPwvtDKTJSxWBXIiya" , "storage.secret=Spbv4vleaFnIrSiLLG3AhbdQk6DMraBQ")
|
||||||
.applyTo(configurableApplicationContext.getEnvironment());
|
.applyTo(configurableApplicationContext.getEnvironment());
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -141,7 +141,7 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
|
|||||||
|
|
||||||
assertEquals(EntryState.SKIPPED, asyaLyon1.getState());
|
assertEquals(EntryState.SKIPPED, asyaLyon1.getState());
|
||||||
|
|
||||||
var idRemoval = buildIdRemoval(publishedInformationEntry1.getId());
|
var idRemoval = buildIdRemoval(publishedInformationEntry1.getEntryId());
|
||||||
|
|
||||||
var manualRedactions = ManualRedactions.builder().idsToRemove(Set.of(idRemoval)).build();
|
var manualRedactions = ManualRedactions.builder().idsToRemove(Set.of(idRemoval)).build();
|
||||||
request.setManualRedactions(manualRedactions);
|
request.setManualRedactions(manualRedactions);
|
||||||
@ -202,7 +202,7 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
|
|||||||
.filter(e -> e.getMatchedRule().startsWith("CBI.16"))
|
.filter(e -> e.getMatchedRule().startsWith("CBI.16"))
|
||||||
.findAny()
|
.findAny()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
IdRemoval removal = buildIdRemoval(desireeEtAl.getId());
|
IdRemoval removal = buildIdRemoval(desireeEtAl.getEntryId());
|
||||||
request.setManualRedactions(ManualRedactions.builder().idsToRemove(Set.of(removal)).build());
|
request.setManualRedactions(ManualRedactions.builder().idsToRemove(Set.of(removal)).build());
|
||||||
|
|
||||||
analyzeService.reanalyze(request);
|
analyzeService.reanalyze(request);
|
||||||
|
|||||||
@ -171,7 +171,7 @@ public class RedactionIntegrationTest extends AbstractRedactionIntegrationTest {
|
|||||||
|
|
||||||
entityLog.getEntityLogEntry()
|
entityLog.getEntityLogEntry()
|
||||||
.forEach(entry -> {
|
.forEach(entry -> {
|
||||||
duplicates.computeIfAbsent(entry.getId(), v -> new ArrayList<>()).add(entry);
|
duplicates.computeIfAbsent(entry.getEntryId(), v -> new ArrayList<>()).add(entry);
|
||||||
});
|
});
|
||||||
|
|
||||||
duplicates.forEach((key, value) -> assertThat(value.size()).isEqualTo(1));
|
duplicates.forEach((key, value) -> assertThat(value.size()).isEqualTo(1));
|
||||||
@ -401,7 +401,7 @@ public class RedactionIntegrationTest extends AbstractRedactionIntegrationTest {
|
|||||||
|
|
||||||
entityLog.getEntityLogEntry()
|
entityLog.getEntityLogEntry()
|
||||||
.forEach(entry -> {
|
.forEach(entry -> {
|
||||||
duplicates.computeIfAbsent(entry.getId(), v -> new ArrayList<>()).add(entry);
|
duplicates.computeIfAbsent(entry.getEntryId(), v -> new ArrayList<>()).add(entry);
|
||||||
});
|
});
|
||||||
|
|
||||||
duplicates.forEach((id, redactionLogEntries) -> assertThat(redactionLogEntries.size()).isEqualTo(1));
|
duplicates.forEach((id, redactionLogEntries) -> assertThat(redactionLogEntries.size()).isEqualTo(1));
|
||||||
@ -1305,7 +1305,7 @@ public class RedactionIntegrationTest extends AbstractRedactionIntegrationTest {
|
|||||||
var entityLog = redactionStorageService.getEntityLog(TEST_DOSSIER_ID, TEST_FILE_ID);
|
var entityLog = redactionStorageService.getEntityLog(TEST_DOSSIER_ID, TEST_FILE_ID);
|
||||||
var changedAnnotation = entityLog.getEntityLogEntry()
|
var changedAnnotation = entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entityLogEntry -> entityLogEntry.getId().equals("3029651d0842a625f2d23f8375c23600"))
|
.filter(entityLogEntry -> entityLogEntry.getEntryId().equals("3029651d0842a625f2d23f8375c23600"))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
@ -1342,10 +1342,10 @@ public class RedactionIntegrationTest extends AbstractRedactionIntegrationTest {
|
|||||||
|
|
||||||
assertTrue(entityLog.getEntityLogEntry()
|
assertTrue(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.anyMatch(entityLogEntry -> entityLogEntry.getId().equals(manualAddId)));
|
.anyMatch(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId)));
|
||||||
assertEquals(entityLog.getEntityLogEntry()
|
assertEquals(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entityLogEntry -> entityLogEntry.getId().equals(manualAddId))
|
.filter(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.get().getState(), EntryState.APPLIED);
|
.get().getState(), EntryState.APPLIED);
|
||||||
|
|
||||||
@ -1356,10 +1356,10 @@ public class RedactionIntegrationTest extends AbstractRedactionIntegrationTest {
|
|||||||
|
|
||||||
assertTrue(entityLog.getEntityLogEntry()
|
assertTrue(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.anyMatch(entityLogEntry -> entityLogEntry.getId().equals(manualAddId)));
|
.anyMatch(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId)));
|
||||||
assertEquals(entityLog.getEntityLogEntry()
|
assertEquals(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entityLogEntry -> entityLogEntry.getId().equals(manualAddId))
|
.filter(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.get().getState(), EntryState.REMOVED);
|
.get().getState(), EntryState.REMOVED);
|
||||||
|
|
||||||
@ -1370,18 +1370,18 @@ public class RedactionIntegrationTest extends AbstractRedactionIntegrationTest {
|
|||||||
|
|
||||||
assertTrue(entityLog.getEntityLogEntry()
|
assertTrue(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.anyMatch(entityLogEntry -> entityLogEntry.getId().equals(manualAddId)));
|
.anyMatch(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId)));
|
||||||
assertEquals(entityLog.getEntityLogEntry()
|
assertEquals(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entityLogEntry -> entityLogEntry.getId().equals(manualAddId))
|
.filter(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.get().getState(), EntryState.REMOVED);
|
.get().getState(), EntryState.REMOVED);
|
||||||
assertTrue(entityLog.getEntityLogEntry()
|
assertTrue(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.anyMatch(entityLogEntry -> entityLogEntry.getId().equals(manualAddId2)));
|
.anyMatch(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId2)));
|
||||||
assertEquals(entityLog.getEntityLogEntry()
|
assertEquals(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entityLogEntry -> entityLogEntry.getId().equals(manualAddId2))
|
.filter(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId2))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.get().getState(), EntryState.APPLIED);
|
.get().getState(), EntryState.APPLIED);
|
||||||
|
|
||||||
@ -1395,18 +1395,18 @@ public class RedactionIntegrationTest extends AbstractRedactionIntegrationTest {
|
|||||||
|
|
||||||
assertTrue(entityLog.getEntityLogEntry()
|
assertTrue(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.anyMatch(entityLogEntry -> entityLogEntry.getId().equals(manualAddId)));
|
.anyMatch(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId)));
|
||||||
assertEquals(entityLog.getEntityLogEntry()
|
assertEquals(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entityLogEntry -> entityLogEntry.getId().equals(manualAddId))
|
.filter(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.get().getState(), EntryState.REMOVED);
|
.get().getState(), EntryState.REMOVED);
|
||||||
assertTrue(entityLog.getEntityLogEntry()
|
assertTrue(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.anyMatch(entityLogEntry -> entityLogEntry.getId().equals(manualAddId2)));
|
.anyMatch(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId2)));
|
||||||
assertEquals(entityLog.getEntityLogEntry()
|
assertEquals(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entityLogEntry -> entityLogEntry.getId().equals(manualAddId2))
|
.filter(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId2))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.get().getState(), EntryState.REMOVED);
|
.get().getState(), EntryState.REMOVED);
|
||||||
|
|
||||||
@ -1418,18 +1418,18 @@ public class RedactionIntegrationTest extends AbstractRedactionIntegrationTest {
|
|||||||
|
|
||||||
assertTrue(entityLog.getEntityLogEntry()
|
assertTrue(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.anyMatch(entityLogEntry -> entityLogEntry.getId().equals(manualAddId)));
|
.anyMatch(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId)));
|
||||||
assertEquals(entityLog.getEntityLogEntry()
|
assertEquals(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entityLogEntry -> entityLogEntry.getId().equals(manualAddId))
|
.filter(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.get().getState(), EntryState.APPLIED);
|
.get().getState(), EntryState.APPLIED);
|
||||||
assertTrue(entityLog.getEntityLogEntry()
|
assertTrue(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.anyMatch(entityLogEntry -> entityLogEntry.getId().equals(manualAddId2)));
|
.anyMatch(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId2)));
|
||||||
assertEquals(entityLog.getEntityLogEntry()
|
assertEquals(entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entityLogEntry -> entityLogEntry.getId().equals(manualAddId2))
|
.filter(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId2))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.get().getState(), EntryState.REMOVED);
|
.get().getState(), EntryState.REMOVED);
|
||||||
}
|
}
|
||||||
@ -1455,7 +1455,7 @@ public class RedactionIntegrationTest extends AbstractRedactionIntegrationTest {
|
|||||||
request.setManualRedactions(ManualRedactions.builder()
|
request.setManualRedactions(ManualRedactions.builder()
|
||||||
.resizeRedactions(Set.of(ManualResizeRedaction.builder()
|
.resizeRedactions(Set.of(ManualResizeRedaction.builder()
|
||||||
.updateDictionary(true)
|
.updateDictionary(true)
|
||||||
.annotationId(david.getId())
|
.annotationId(david.getEntryId())
|
||||||
.requestDate(OffsetDateTime.now())
|
.requestDate(OffsetDateTime.now())
|
||||||
.value("David Ksenia")
|
.value("David Ksenia")
|
||||||
.positions(List.of(Rectangle.builder()
|
.positions(List.of(Rectangle.builder()
|
||||||
@ -1472,7 +1472,7 @@ public class RedactionIntegrationTest extends AbstractRedactionIntegrationTest {
|
|||||||
entityLog = redactionStorageService.getEntityLog(TEST_DOSSIER_ID, TEST_FILE_ID);
|
entityLog = redactionStorageService.getEntityLog(TEST_DOSSIER_ID, TEST_FILE_ID);
|
||||||
var resizedEntity = entityLog.getEntityLogEntry()
|
var resizedEntity = entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(e -> e.getId().equals(david.getId()))
|
.filter(e -> e.getEntryId().equals(david.getEntryId()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.get();
|
.get();
|
||||||
assertEquals(resizedEntity.getState(), EntryState.APPLIED);
|
assertEquals(resizedEntity.getState(), EntryState.APPLIED);
|
||||||
|
|||||||
@ -464,10 +464,10 @@ public class RulesTest {
|
|||||||
for (EntityLogEntry redactionLogEntry : entityLog.getEntityLogEntry()) {
|
for (EntityLogEntry redactionLogEntry : entityLog.getEntityLogEntry()) {
|
||||||
var savedRedactionLogEntry = savedRedactionLog.getRedactionLogEntry()
|
var savedRedactionLogEntry = savedRedactionLog.getRedactionLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(r -> r.getId().equalsIgnoreCase(redactionLogEntry.getId()))
|
.filter(r -> r.getId().equalsIgnoreCase(redactionLogEntry.getEntryId()))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
assertThat(savedRedactionLogEntry).isPresent();
|
assertThat(savedRedactionLogEntry).isPresent();
|
||||||
assertThat(savedRedactionLogEntry.get().getId()).isEqualTo(redactionLogEntry.getId());
|
assertThat(savedRedactionLogEntry.get().getId()).isEqualTo(redactionLogEntry.getEntryId());
|
||||||
assertThat(savedRedactionLogEntry.get().getType()).isEqualTo(redactionLogEntry.getType());
|
assertThat(savedRedactionLogEntry.get().getType()).isEqualTo(redactionLogEntry.getType());
|
||||||
assertThat(savedRedactionLogEntry.get().getValue()).isEqualTo(redactionLogEntry.getValue());
|
assertThat(savedRedactionLogEntry.get().getValue()).isEqualTo(redactionLogEntry.getValue());
|
||||||
assertThat(savedRedactionLogEntry.get().getReason()).isEqualTo(redactionLogEntry.getReason());
|
assertThat(savedRedactionLogEntry.get().getReason()).isEqualTo(redactionLogEntry.getReason());
|
||||||
|
|||||||
@ -152,8 +152,8 @@ public class AnnotationService {
|
|||||||
annotation.setRectangle(pdRectangle);
|
annotation.setRectangle(pdRectangle);
|
||||||
annotation.setQuadPoints(Floats.toArray(toQuadPoints(rectangles)));
|
annotation.setQuadPoints(Floats.toArray(toQuadPoints(rectangles)));
|
||||||
annotation.setContents(redactionLogEntry.getValue() + " " + createAnnotationContent(redactionLogEntry));
|
annotation.setContents(redactionLogEntry.getValue() + " " + createAnnotationContent(redactionLogEntry));
|
||||||
annotation.setTitlePopup(redactionLogEntry.getEntryType().name() + ":" + redactionLogEntry.getState().name() + ":" + redactionLogEntry.getId());
|
annotation.setTitlePopup(redactionLogEntry.getEntryType().name() + ":" + redactionLogEntry.getState().name() + ":" + redactionLogEntry.getEntryId());
|
||||||
annotation.setAnnotationName(redactionLogEntry.getId());
|
annotation.setAnnotationName(redactionLogEntry.getEntryId());
|
||||||
float[] color;
|
float[] color;
|
||||||
if (redactionLogEntry.getEntryType().equals(EntryType.RECOMMENDATION)) {
|
if (redactionLogEntry.getEntryType().equals(EntryType.RECOMMENDATION)) {
|
||||||
color = new float[]{0, 0.8f, 0};
|
color = new float[]{0, 0.8f, 0};
|
||||||
|
|||||||
@ -176,7 +176,7 @@ public class ManualChangesEnd2EndTest extends AbstractRedactionIntegrationTest {
|
|||||||
.stream()
|
.stream()
|
||||||
.filter(entry -> entry.getValue().equals(testEntityValue1))
|
.filter(entry -> entry.getValue().equals(testEntityValue1))
|
||||||
.max(Comparator.comparingInt(EntityLogEntry::getStartOffset))
|
.max(Comparator.comparingInt(EntityLogEntry::getStartOffset))
|
||||||
.get().getId();
|
.get().getEntryId();
|
||||||
ManualRedactions manualRedactions = new ManualRedactions();
|
ManualRedactions manualRedactions = new ManualRedactions();
|
||||||
manualRedactions.getResizeRedactions()
|
manualRedactions.getResizeRedactions()
|
||||||
.add(ManualResizeRedaction.builder()
|
.add(ManualResizeRedaction.builder()
|
||||||
@ -203,7 +203,7 @@ public class ManualChangesEnd2EndTest extends AbstractRedactionIntegrationTest {
|
|||||||
.filter(entry -> entry.getValue().equals(expandedEntityKeyword))
|
.filter(entry -> entry.getValue().equals(expandedEntityKeyword))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.get();
|
.get();
|
||||||
assertEquals(idToResize, resizedEntry.getId());
|
assertEquals(idToResize, resizedEntry.getEntryId());
|
||||||
assertEquals(1,
|
assertEquals(1,
|
||||||
redactionLog.getEntityLogEntry()
|
redactionLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
@ -318,7 +318,7 @@ public class ManualChangesEnd2EndTest extends AbstractRedactionIntegrationTest {
|
|||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
var optionalEntry = redactionLog.getEntityLogEntry()
|
var optionalEntry = redactionLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entityLogEntry -> entityLogEntry.getId().equals(manualAddId))
|
.filter(entityLogEntry -> entityLogEntry.getEntryId().equals(manualAddId))
|
||||||
.findAny();
|
.findAny();
|
||||||
assertTrue(optionalEntry.isPresent());
|
assertTrue(optionalEntry.isPresent());
|
||||||
assertEquals(2, optionalEntry.get().getContainingNodeId().size()); // 2 is the depth of the table instead of the table cell
|
assertEquals(2, optionalEntry.get().getContainingNodeId().size()); // 2 is the depth of the table instead of the table cell
|
||||||
@ -358,7 +358,7 @@ public class ManualChangesEnd2EndTest extends AbstractRedactionIntegrationTest {
|
|||||||
ManualRecategorization recategorization = ManualRecategorization.builder()
|
ManualRecategorization recategorization = ManualRecategorization.builder()
|
||||||
.requestDate(OffsetDateTime.now())
|
.requestDate(OffsetDateTime.now())
|
||||||
.type("vertebrate")
|
.type("vertebrate")
|
||||||
.annotationId(oxfordUniversityPress.getId())
|
.annotationId(oxfordUniversityPress.getEntryId())
|
||||||
.fileId(TEST_FILE_ID)
|
.fileId(TEST_FILE_ID)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ public class ManualChangesEnd2EndTest extends AbstractRedactionIntegrationTest {
|
|||||||
EntityLog entityLog = redactionStorageService.getEntityLog(request.getDossierId(), request.getFileId());
|
EntityLog entityLog = redactionStorageService.getEntityLog(request.getDossierId(), request.getFileId());
|
||||||
EntityLogEntry entityLogEntry = entityLog.getEntityLogEntry()
|
EntityLogEntry entityLogEntry = entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entry -> entry.getId().equals(annotationId))
|
.filter(entry -> entry.getEntryId().equals(annotationId))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
assertEquals("Expand to Hint", entityLogEntry.getValue());
|
assertEquals("Expand to Hint", entityLogEntry.getValue());
|
||||||
@ -458,7 +458,7 @@ public class ManualChangesEnd2EndTest extends AbstractRedactionIntegrationTest {
|
|||||||
.findFirst()
|
.findFirst()
|
||||||
.get();
|
.get();
|
||||||
ManualResizeRedaction manualResizeRedaction = ManualResizeRedaction.builder()
|
ManualResizeRedaction manualResizeRedaction = ManualResizeRedaction.builder()
|
||||||
.annotationId(dictionaryEntry.getId())
|
.annotationId(dictionaryEntry.getEntryId())
|
||||||
.requestDate(OffsetDateTime.now())
|
.requestDate(OffsetDateTime.now())
|
||||||
.value("Image")
|
.value("Image")
|
||||||
.positions(List.of(new Rectangle(new Point(56.8f, 496.27f), 61.25f, 12.83f, 1)))
|
.positions(List.of(new Rectangle(new Point(56.8f, 496.27f), 61.25f, 12.83f, 1)))
|
||||||
@ -472,7 +472,7 @@ public class ManualChangesEnd2EndTest extends AbstractRedactionIntegrationTest {
|
|||||||
entityLog = redactionStorageService.getEntityLog(request.getDossierId(), request.getFileId());
|
entityLog = redactionStorageService.getEntityLog(request.getDossierId(), request.getFileId());
|
||||||
EntityLogEntry entityLogEntry = entityLog.getEntityLogEntry()
|
EntityLogEntry entityLogEntry = entityLog.getEntityLogEntry()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(entry -> entry.getId().equals(dictionaryEntry.getId()))
|
.filter(entry -> entry.getEntryId().equals(dictionaryEntry.getEntryId()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
assertEquals(ManualRedactionType.RESIZE_IN_DICTIONARY,
|
assertEquals(ManualRedactionType.RESIZE_IN_DICTIONARY,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user