Pull request #199: RED-3239: Fixed persistence for imported redactions
Merge in RED/persistence-service from RED-3243-1 to master * commit 'd9aa5c4efe12afe4247ee24551e0896a995559d6': RED-3239: Fixed persistence for imported redactions
This commit is contained in:
commit
440275da30
@ -30,17 +30,17 @@ public interface ImportedAnnotationResource {
|
||||
|
||||
@DeleteMapping(value = IMPORTED_ANNOTATION_PATH + FILE_ID_PATH_PARAM + ANNOTATION_ID_PATH_PARAM)
|
||||
void delete(@PathVariable(FILE_ID_PARAM) String fileId,
|
||||
@PathVariable(ANNOTATION_ID_PATH_PARAM) String annotationId);
|
||||
@PathVariable(ANNOTATION_ID_PARAM) String annotationId);
|
||||
|
||||
|
||||
@PostMapping(value = IMPORTED_ANNOTATION_PATH + FILE_ID_PATH_PARAM)
|
||||
@PostMapping(value = IMPORTED_ANNOTATION_PATH + FILE_ID_PATH_PARAM, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void insert(@PathVariable(FILE_ID_PARAM) String fileId,
|
||||
@RequestBody AddImportedAnnotationRequest annotation);
|
||||
|
||||
|
||||
@PostMapping(value = IMPORTED_ANNOTATION_PATH + FILE_ID_PATH_PARAM + ANNOTATION_ID_PATH_PARAM)
|
||||
@PostMapping(value = IMPORTED_ANNOTATION_PATH + FILE_ID_PATH_PARAM + ANNOTATION_ID_PATH_PARAM, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void updateStatus(@PathVariable(FILE_ID_PARAM) String fileId,
|
||||
@PathVariable(ANNOTATION_ID_PATH_PARAM) String annotationId,
|
||||
@PathVariable(ANNOTATION_ID_PARAM) String annotationId,
|
||||
@RequestBody UpdateImportedAnnotationStatusRequest UpdateImportedAnnotationRequest);
|
||||
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.iqser.red.service.peristence.v1.server.utils.ImportedRedactionMapper;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.ImportedAnnotationPersistenceService;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AddImportedAnnotationRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ImportedAnnotation;
|
||||
@ -26,7 +27,7 @@ public class ImportedAnnotationController implements ImportedAnnotationResource
|
||||
@Override
|
||||
public List<ImportedAnnotation> getByFileId(@PathVariable(FILE_ID_PARAM) String fileId) {
|
||||
|
||||
return convert(importedAnnotationPersistenceService.findImportedAnnotations(fileId), ImportedAnnotation.class);
|
||||
return convert(importedAnnotationPersistenceService.findImportedAnnotations(fileId), ImportedAnnotation.class, new ImportedRedactionMapper());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
package com.iqser.red.service.peristence.v1.server.utils;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ImportedAnnotationEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualRedactionEntryEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ImportedAnnotation;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ManualRedactionEntry;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.Rectangle;
|
||||
|
||||
public class ImportedRedactionMapper implements BiConsumer<ImportedAnnotationEntity, ImportedAnnotation> {
|
||||
|
||||
@Override
|
||||
public void accept(ImportedAnnotationEntity manualRedactionEntryEntity, ImportedAnnotation manualRedactionEntry) {
|
||||
manualRedactionEntry.setPositions(convert(manualRedactionEntryEntity.getPositions(), Rectangle.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -29,12 +29,81 @@ databaseChangeLog:
|
||||
name: processed_date
|
||||
type: TIMESTAMP WITHOUT TIME ZONE
|
||||
- column:
|
||||
name: TODO-positions
|
||||
type: TIMESTAMP WITHOUT TIME ZONE
|
||||
- column:
|
||||
name: TODO-file_status_id
|
||||
name: file_status_id
|
||||
type: VARCHAR(255)
|
||||
- column:
|
||||
name: comment
|
||||
type: VARCHAR(255)
|
||||
tableName: imported_annotation
|
||||
- changeSet:
|
||||
id: imported-annotation_positions
|
||||
author: generated
|
||||
changes:
|
||||
- createTable:
|
||||
columns:
|
||||
- column:
|
||||
constraints:
|
||||
nullable: false
|
||||
name: imported_annotation_entity_annotation_id
|
||||
type: VARCHAR(255)
|
||||
- column:
|
||||
constraints:
|
||||
nullable: false
|
||||
name: imported_annotation_entity_file_id
|
||||
type: VARCHAR(255)
|
||||
- column:
|
||||
constraints:
|
||||
nullable: false
|
||||
name: height
|
||||
type: FLOAT4
|
||||
- column:
|
||||
constraints:
|
||||
nullable: false
|
||||
name: page
|
||||
type: INTEGER
|
||||
- column:
|
||||
constraints:
|
||||
nullable: false
|
||||
name: top_leftx
|
||||
type: FLOAT4
|
||||
- column:
|
||||
constraints:
|
||||
nullable: false
|
||||
name: top_lefty
|
||||
type: FLOAT4
|
||||
- column:
|
||||
constraints:
|
||||
nullable: false
|
||||
name: width
|
||||
type: FLOAT4
|
||||
tableName: imported_annotation_entity_positions
|
||||
- changeSet:
|
||||
id: imported-annotation-file-fk
|
||||
author: dom
|
||||
changes:
|
||||
- addForeignKeyConstraint:
|
||||
baseColumnNames: file_status_id
|
||||
baseTableName: imported_annotation
|
||||
constraintName: fkeur9q7l2tp5n12c2t9dfp3a10
|
||||
deferrable: false
|
||||
initiallyDeferred: false
|
||||
onDelete: NO ACTION
|
||||
onUpdate: NO ACTION
|
||||
referencedColumnNames: id
|
||||
referencedTableName: file
|
||||
validate: true
|
||||
- changeSet:
|
||||
id: imported-annotation-file-positions
|
||||
author: dom
|
||||
changes:
|
||||
- addForeignKeyConstraint:
|
||||
baseColumnNames: imported_annotation_entity_annotation_id,imported_annotation_entity_file_id
|
||||
baseTableName: imported_annotation_entity_positions
|
||||
constraintName: fkol1r7vwjc1uvu36p5ju7cj28j
|
||||
deferrable: false
|
||||
initiallyDeferred: false
|
||||
onDelete: NO ACTION
|
||||
onUpdate: NO ACTION
|
||||
referencedColumnNames: annotation_id,file_id
|
||||
referencedTableName: imported_annotation
|
||||
validate: true
|
||||
@ -0,0 +1,10 @@
|
||||
package com.iqser.red.service.peristence.v1.server.integration.client;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.ImportedAnnotationResource;
|
||||
|
||||
@FeignClient(name = "ImportedRedactionClient", url = "http://localhost:${server.port}")
|
||||
public interface ImportedRedactionClient extends ImportedAnnotationResource {
|
||||
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package com.iqser.red.service.peristence.v1.server.integration.tests;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.iqser.red.service.peristence.v1.server.integration.client.ImportedRedactionClient;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.service.DossierTemplateTesterAndProvider;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.service.DossierTesterAndProvider;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.service.FileTesterAndProvider;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.utils.AbstractPersistenceServerServiceTest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AddImportedAnnotationRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ImportedAnnotationStatus;
|
||||
import com.iqser.red.service.redaction.v1.model.Point;
|
||||
import com.iqser.red.service.redaction.v1.model.Rectangle;
|
||||
|
||||
public class ImportedRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
@Autowired
|
||||
private FileTesterAndProvider fileTesterAndProvider;
|
||||
|
||||
@Autowired
|
||||
private DossierTesterAndProvider dossierTesterAndProvider;
|
||||
|
||||
@Autowired
|
||||
private DossierTemplateTesterAndProvider dossierTemplateTesterAndProvider;
|
||||
|
||||
@Autowired
|
||||
private ImportedRedactionClient importedRedactionClient;
|
||||
|
||||
|
||||
@Test
|
||||
public void testManualRedaction() {
|
||||
|
||||
var dossierTemplate = dossierTemplateTesterAndProvider.provideTestTemplate();
|
||||
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier(dossierTemplate);
|
||||
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||
|
||||
importedRedactionClient.insert(file.getId(), AddImportedAnnotationRequest.builder()
|
||||
.positions(List.of(new Rectangle(new Point(1, 1), 1, 1, 1)))
|
||||
.annotationId("annotationId")
|
||||
.status(ImportedAnnotationStatus.NEW)
|
||||
.userId("userId")
|
||||
.comment("comment")
|
||||
.build());
|
||||
var loadedImportedRedaction = importedRedactionClient.getByFileId(file.getId());
|
||||
assertThat(loadedImportedRedaction.get(0).getPositions().size()).isEqualTo(1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user