RED-8702: Explore document databases to store entityLog
* refactoring
This commit is contained in:
parent
d4c97cd970
commit
93708b4efc
@ -2,12 +2,12 @@ package com.iqser.red.service.persistence.management.v1.processor.document;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.DBRef;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.utils.ObjectConverterUtils;
|
||||
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;
|
||||
|
||||
@ -51,13 +51,21 @@ public class EntityLogDocument {
|
||||
|
||||
public EntityLogDocument(String dossierId, String fileId, EntityLog entityLog) {
|
||||
|
||||
ObjectConverterUtils.copyAllFields(entityLog, this);
|
||||
this.id = getDocumentId(dossierId, fileId);
|
||||
this.dossierId = dossierId;
|
||||
this.fileId = fileId;
|
||||
this.entityLogEntryDocument = new ArrayList<>(entityLog.getEntityLogEntry()
|
||||
.stream()
|
||||
.map(entityLogEntry -> new EntityLogEntryDocument(this.id, entityLogEntry)).toList());
|
||||
.map(entityLogEntry -> new EntityLogEntryDocument(this.id, entityLogEntry))
|
||||
.toList());
|
||||
|
||||
this.setAnalysisVersion(entityLog.getAnalysisVersion());
|
||||
this.setAnalysisNumber(entityLog.getAnalysisNumber());
|
||||
this.setLegalBasis(entityLog.getLegalBasis());
|
||||
this.setDictionaryVersion(entityLog.getDictionaryVersion());
|
||||
this.setDossierDictionaryVersion(entityLog.getDossierDictionaryVersion());
|
||||
this.setRulesVersion(entityLog.getRulesVersion());
|
||||
this.setLegalBasisVersion(entityLog.getLegalBasisVersion());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.document;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.ObjectConverterUtils.copyAllFields;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -83,11 +81,34 @@ public class EntityLogEntryDocument {
|
||||
|
||||
public EntityLogEntryDocument(String entityLogId, EntityLogEntry entityLogEntry) {
|
||||
|
||||
copyAllFields(entityLogEntry, this);
|
||||
this.id = entityLogId + "/" + entityLogEntry.getId();
|
||||
this.entryId = entityLogEntry.getId();
|
||||
this.entityLogId = entityLogId;
|
||||
|
||||
this.setEntryType(entityLogEntry.getEntryType());
|
||||
this.setState(entityLogEntry.getState());
|
||||
this.setValue(entityLogEntry.getValue());
|
||||
this.setReason(entityLogEntry.getReason());
|
||||
this.setMatchedRule(entityLogEntry.getMatchedRule());
|
||||
this.setLegalBasis(entityLogEntry.getLegalBasis());
|
||||
this.setContainingNodeId(entityLogEntry.getContainingNodeId());
|
||||
this.setClosestHeadline(entityLogEntry.getClosestHeadline());
|
||||
this.setSection(entityLogEntry.getSection());
|
||||
this.setPositions(entityLogEntry.getPositions());
|
||||
this.setTextBefore(entityLogEntry.getTextBefore());
|
||||
this.setTextAfter(entityLogEntry.getTextAfter());
|
||||
this.setStartOffset(entityLogEntry.getStartOffset());
|
||||
this.setEndOffset(entityLogEntry.getEndOffset());
|
||||
this.setImageHasTransparency(entityLogEntry.isImageHasTransparency());
|
||||
this.setDictionaryEntry(entityLogEntry.isDictionaryEntry());
|
||||
this.setDossierDictionaryEntry(entityLogEntry.isDossierDictionaryEntry());
|
||||
this.setExcluded(entityLogEntry.isExcluded());
|
||||
this.setChanges(entityLogEntry.getChanges());
|
||||
this.setManualChanges(entityLogEntry.getManualChanges());
|
||||
this.setEngines(entityLogEntry.getEngines());
|
||||
this.setReference(entityLogEntry.getReference());
|
||||
this.setImportedRedactionIntersections(entityLogEntry.getImportedRedactionIntersections());
|
||||
this.setNumberOfComments(entityLogEntry.getNumberOfComments());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -209,6 +209,7 @@ public class EntityLogMongoService {
|
||||
|
||||
EntityLogEntry entityLogEntry = new EntityLogEntry();
|
||||
entityLogEntry.setId(entityLogEntryDocument.getEntryId());
|
||||
entityLogEntry.setEntryType(entityLogEntryDocument.getEntryType());
|
||||
entityLogEntry.setState(entityLogEntryDocument.getState());
|
||||
entityLogEntry.setValue(entityLogEntryDocument.getValue());
|
||||
entityLogEntry.setReason(entityLogEntryDocument.getReason());
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class ObjectConverterUtils {
|
||||
|
||||
public static void copyAllFields(Object source, Object target) {
|
||||
Class<?> sourceClass = source.getClass();
|
||||
Class<?> targetClass = target.getClass();
|
||||
Field[] sourceFields = sourceClass.getDeclaredFields();
|
||||
Field[] var5 = sourceFields;
|
||||
int var6 = sourceFields.length;
|
||||
|
||||
for(int var7 = 0; var7 < var6; ++var7) {
|
||||
Field field = var5[var7];
|
||||
|
||||
try {
|
||||
Field targetField = targetClass.getDeclaredField(field.getName());
|
||||
field.setAccessible(true);
|
||||
targetField.setAccessible(true);
|
||||
targetField.set(target, field.get(source));
|
||||
} catch (IllegalAccessException | NoSuchFieldException var10) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user