RED-3243 Added db and api for ImportedAnnotations (either finished nor working)
This commit is contained in:
parent
abd311a2e0
commit
9043f5904e
@ -0,0 +1,25 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.annotations;
|
||||
|
||||
import com.iqser.red.service.redaction.v1.model.Rectangle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AddImportedAnnotationRequest {
|
||||
|
||||
private String annotationId;
|
||||
private List<Rectangle> positions = new ArrayList<>();
|
||||
private ImportedAnnotationStatus status;
|
||||
private String userId;
|
||||
private String comment;
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.annotations;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ImportedAnnotation {
|
||||
|
||||
private String annotationId;
|
||||
private String fileId;
|
||||
private List<Rectangle> positions = new ArrayList<>();
|
||||
private ImportedAnnotationStatus status;
|
||||
private String user;
|
||||
private String comment;
|
||||
private OffsetDateTime processedDate;
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.annotations;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UpdateImportedAnnotationStatusRequest {
|
||||
|
||||
private ImportedAnnotationStatus status;
|
||||
private String user;
|
||||
private String comment;
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.resources;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AddImportedAnnotationRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ImportedAnnotation;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.UpdateImportedAnnotationStatusRequest;
|
||||
|
||||
public interface ImportedAnnotationResource {
|
||||
|
||||
String IMPORTED_ANNOTATION_PATH = "/imported-annotation";
|
||||
|
||||
String FILE_ID_PARAM = "fileId";
|
||||
String FILE_ID_PATH_PARAM = "/{" + FILE_ID_PARAM + "}";
|
||||
|
||||
String ANNOTATION_ID_PARAM = "fileId";
|
||||
String ANNOTATION_ID_PATH_PARAM = "/{" + ANNOTATION_ID_PARAM + "}";
|
||||
|
||||
|
||||
@GetMapping(value = IMPORTED_ANNOTATION_PATH + FILE_ID_PATH_PARAM, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
List<ImportedAnnotation> getByFileId(@PathVariable(FILE_ID_PARAM) String fileId);
|
||||
|
||||
|
||||
@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);
|
||||
|
||||
|
||||
@PostMapping(value = IMPORTED_ANNOTATION_PATH + FILE_ID_PATH_PARAM)
|
||||
void insert(@PathVariable(FILE_ID_PARAM) String fileId,
|
||||
@RequestBody AddImportedAnnotationRequest annotation);
|
||||
|
||||
|
||||
@PostMapping(value = IMPORTED_ANNOTATION_PATH + FILE_ID_PATH_PARAM + ANNOTATION_ID_PATH_PARAM)
|
||||
void updateStatus(@PathVariable(FILE_ID_PARAM) String fileId,
|
||||
@PathVariable(ANNOTATION_ID_PATH_PARAM) String annotationId,
|
||||
@RequestBody UpdateImportedAnnotationStatusRequest UpdateImportedAnnotationRequest);
|
||||
|
||||
}
|
||||
@ -14,6 +14,7 @@ import com.iqser.red.service.persistence.management.v1.processor.entity.annotati
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ImportedAnnotationEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.RectangleEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.ImportedAnnotationRepository;
|
||||
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.Rectangle;
|
||||
|
||||
@ -26,6 +27,20 @@ public class ImportedAnnotationPersistenceService {
|
||||
private final ImportedAnnotationRepository importedAnnotationRepository;
|
||||
|
||||
|
||||
@Transactional
|
||||
public void insert(String fileId, AddImportedAnnotationRequest annotation) {
|
||||
|
||||
ImportedAnnotationEntity importedAnnotationEntity = new ImportedAnnotationEntity();
|
||||
importedAnnotationEntity.setId(new AnnotationEntityId(annotation.getAnnotationId(), fileId));
|
||||
importedAnnotationEntity.setStatus(annotation.getStatus() != null ? annotation.getStatus() : ImportedAnnotationStatus.NEW);
|
||||
importedAnnotationEntity.setProcessedDate(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
importedAnnotationEntity.setPositions(convert(annotation.getPositions()));
|
||||
importedAnnotationEntity.setUser(annotation.getUserId());
|
||||
importedAnnotationEntity.setComment(annotation.getComment());
|
||||
importedAnnotationRepository.save(importedAnnotationEntity);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void insert(String fileId, List<Annotation> annotations) {
|
||||
|
||||
@ -34,12 +49,14 @@ public class ImportedAnnotationPersistenceService {
|
||||
|
||||
|
||||
@Transactional
|
||||
public void insert(String fileId, Annotation annotation, ImportedAnnotationStatus status, String userId, String comment) {
|
||||
public void insert(String fileId, Annotation annotation, ImportedAnnotationStatus status, String userId,
|
||||
String comment) {
|
||||
|
||||
ImportedAnnotationEntity importedAnnotationEntity = new ImportedAnnotationEntity();
|
||||
importedAnnotationEntity.setId(new AnnotationEntityId(annotation.getId(), fileId));
|
||||
importedAnnotationEntity.setStatus(status);
|
||||
importedAnnotationEntity.setProcessedDate(status == ImportedAnnotationStatus.ADDED ? OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS) : null);
|
||||
importedAnnotationEntity.setProcessedDate(status == ImportedAnnotationStatus.ADDED ? OffsetDateTime.now()
|
||||
.truncatedTo(ChronoUnit.MILLIS) : null);
|
||||
importedAnnotationEntity.setUser(userId);
|
||||
importedAnnotationEntity.setComment(comment);
|
||||
importedAnnotationEntity.setPositions(convert(annotation.getPositions()));
|
||||
@ -57,7 +74,8 @@ public class ImportedAnnotationPersistenceService {
|
||||
|
||||
|
||||
@Transactional
|
||||
public void delete(String fileId, String annotationId){
|
||||
public void delete(String fileId, String annotationId) {
|
||||
|
||||
importedAnnotationRepository.deleteById(new AnnotationEntityId(annotationId, fileId));
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
package com.iqser.red.service.peristence.v1.server.controller;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.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;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.UpdateImportedAnnotationStatusRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.ImportedAnnotationResource;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class ImportedAnnotationController implements ImportedAnnotationResource {
|
||||
|
||||
private final ImportedAnnotationPersistenceService importedAnnotationPersistenceService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<ImportedAnnotation> getByFileId(@PathVariable(FILE_ID_PARAM) String fileId) {
|
||||
|
||||
return convert(importedAnnotationPersistenceService.findImportedAnnotations(fileId), ImportedAnnotation.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void insert(@PathVariable(FILE_ID_PARAM) String fileId,
|
||||
@RequestBody AddImportedAnnotationRequest annotation) {
|
||||
|
||||
importedAnnotationPersistenceService.insert(fileId, annotation);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateStatus(@PathVariable(FILE_ID_PARAM) String fileId,
|
||||
@PathVariable(ANNOTATION_ID_PATH_PARAM) String annotationId,
|
||||
@RequestBody UpdateImportedAnnotationStatusRequest updateImportedAnnotationStatusRequest) {
|
||||
|
||||
importedAnnotationPersistenceService.updateStatus(fileId, annotationId, updateImportedAnnotationStatusRequest.getStatus(), updateImportedAnnotationStatusRequest.getComment(), updateImportedAnnotationStatusRequest.getUser());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(@PathVariable(FILE_ID_PARAM) String fileId,
|
||||
@PathVariable(ANNOTATION_ID_PATH_PARAM) String annotationId) {
|
||||
|
||||
importedAnnotationPersistenceService.delete(fileId, annotationId);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: imported-annotation
|
||||
author: philipp
|
||||
changes:
|
||||
- createTable:
|
||||
columns:
|
||||
- column:
|
||||
constraints:
|
||||
nullable: false
|
||||
primaryKey: true
|
||||
primaryKeyName: imported_annotation_pkey
|
||||
name: annotation_id
|
||||
type: VARCHAR(255)
|
||||
- column:
|
||||
constraints:
|
||||
nullable: false
|
||||
primaryKey: true
|
||||
primaryKeyName: imported_annotation_pkey
|
||||
name: file_id
|
||||
type: VARCHAR(255)
|
||||
- column:
|
||||
name: user_id
|
||||
type: VARCHAR(255)
|
||||
- column:
|
||||
name: status
|
||||
type: VARCHAR(255)
|
||||
- column:
|
||||
name: processed_date
|
||||
type: TIMESTAMP WITHOUT TIME ZONE
|
||||
- column:
|
||||
name: TODO-positions
|
||||
type: TIMESTAMP WITHOUT TIME ZONE
|
||||
- column:
|
||||
name: TODO-file_status_id
|
||||
type: VARCHAR(255)
|
||||
- column:
|
||||
name: comment
|
||||
type: VARCHAR(255)
|
||||
tableName: imported_annotation
|
||||
@ -7,3 +7,5 @@ databaseChangeLog:
|
||||
file: db/changelog/3-added-annotation-modification-date.changelog.yaml
|
||||
- include:
|
||||
file: db/changelog/4-archived-dossier.changelog.yaml
|
||||
- include:
|
||||
file: db/changelog/5-imported-annotation.changelog.yaml
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user