RED-8702: Explore document databases to store entityLog

* pre-test eval version
This commit is contained in:
maverickstuder 2024-03-19 15:33:52 +01:00
parent d53da45b5f
commit d9717b1638
2 changed files with 0 additions and 195 deletions

View File

@ -1,79 +0,0 @@
package com.iqser.red.service.redaction.v1.server.mongo;
import java.util.ArrayList;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.IndexDirection;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;
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.EntityLogLegalBasis;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Document(collection = "entity-logs")
public class EntityLogDocument {
@Id
@EqualsAndHashCode.Include
private String id;
private String dossierId;
private String fileId;
private long analysisVersion;
//@Indexed(direction = IndexDirection.DESCENDING)
private int analysisNumber;
@DBRef
private List<EntityLogEntryDocument> entityLogEntryDocument = new ArrayList<>();
private List<EntityLogLegalBasis> legalBasis = new ArrayList<>();
private long dictionaryVersion = -1;
private long dossierDictionaryVersion = -1;
private long rulesVersion = -1;
private long legalBasisVersion = -1;
public EntityLogDocument(String dossierId, String fileId, EntityLog entityLog) {
this.id = getDocumentId(dossierId, fileId);
this.dossierId = dossierId;
this.fileId = fileId;
this.analysisVersion = entityLog.getAnalysisVersion();
this.analysisNumber = entityLog.getAnalysisNumber();
this.entityLogEntryDocument = new ArrayList<>(entityLog.getEntityLogEntry()
.stream()
.map(entityLogEntry -> new EntityLogEntryDocument(this.id, entityLogEntry)).toList());
this.legalBasis = entityLog.getLegalBasis();
this.dictionaryVersion = entityLog.getDictionaryVersion();
this.dossierDictionaryVersion = entityLog.getDossierDictionaryVersion();
this.rulesVersion = entityLog.getRulesVersion();
this.legalBasisVersion = entityLog.getLegalBasisVersion();
}
@NotNull
public static String getDocumentId(String dossierId, String fileId) {
return dossierId + "/" + fileId;
}
}

View File

@ -1,116 +0,0 @@
package com.iqser.red.service.redaction.v1.server.mongo;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.redis.core.index.Indexed;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Change;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Engine;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogEntry;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntryState;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntryType;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.ManualChange;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Position;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldDefaults;
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@FieldDefaults(level = AccessLevel.PRIVATE)
@Document(collection = "entity-log-entries")
/**@CompoundIndexes({
@CompoundIndex(name = "changes_analysisNumber", def = "{ 'changes.analysisNumber': 1 }")
})**/ public class EntityLogEntryDocument {
@Id
@EqualsAndHashCode.Include
String id;
String entryId;
String entityLogId;
String type;
EntryType entryType;
EntryState state;
String value;
String reason;
String matchedRule;
String legalBasis;
List<Integer> containingNodeId;
String closestHeadline;
String section;
List<Position> positions = new ArrayList<>();
String textBefore;
String textAfter;
int startOffset;
int endOffset;
boolean imageHasTransparency;
boolean dictionaryEntry;
boolean dossierDictionaryEntry;
boolean excluded;
List<Change> changes = new ArrayList<>();
List<ManualChange> manualChanges = new ArrayList<>();
Set<Engine> engines = new HashSet<>();
Set<String> reference = new HashSet<>();
Set<String> importedRedactionIntersections = new HashSet<>();
int numberOfComments;
public EntityLogEntryDocument(String entityLogId, EntityLogEntry entityLogEntry) {
this.id = entityLogId + "/" + entityLogEntry.getId();
this.entryId = entityLogEntry.getId();
this.entityLogId = entityLogId;
this.type = entityLogEntry.getType();
this.entryType = entityLogEntry.getEntryType();
this.state = entityLogEntry.getState();
this.value = entityLogEntry.getValue();
this.reason = entityLogEntry.getReason();
this.matchedRule = entityLogEntry.getMatchedRule();
this.legalBasis = entityLogEntry.getLegalBasis();
this.containingNodeId = new ArrayList<>(entityLogEntry.getContainingNodeId());
this.closestHeadline = entityLogEntry.getClosestHeadline();
this.section = entityLogEntry.getSection();
this.positions = new ArrayList<>(entityLogEntry.getPositions());
this.textBefore = entityLogEntry.getTextBefore();
this.textAfter = entityLogEntry.getTextAfter();
this.startOffset = entityLogEntry.getStartOffset();
this.endOffset = entityLogEntry.getEndOffset();
this.imageHasTransparency = entityLogEntry.isImageHasTransparency();
this.dictionaryEntry = entityLogEntry.isDictionaryEntry();
this.dossierDictionaryEntry = entityLogEntry.isDossierDictionaryEntry();
this.excluded = entityLogEntry.isExcluded();
this.changes = new ArrayList<>(entityLogEntry.getChanges());
this.manualChanges = new ArrayList<>(entityLogEntry.getManualChanges());
this.engines = new HashSet<>(entityLogEntry.getEngines());
this.reference = new HashSet<>(entityLogEntry.getReference());
this.importedRedactionIntersections = new HashSet<>(entityLogEntry.getImportedRedactionIntersections());
this.numberOfComments = entityLogEntry.getNumberOfComments();
}
}