Merge branch 'master' of ssh://git.iqser.com:2222/red/persistence-service
This commit is contained in:
commit
dcb260ea17
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>com.iqser.red</groupId>
|
||||
<artifactId>platform-docker-dependency</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -36,11 +36,6 @@
|
||||
<artifactId>feign-core</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/jakarta.persistence/jakarta.persistence-api -->
|
||||
<dependency>
|
||||
<groupId>jakarta.persistence</groupId>
|
||||
<artifactId>jakarta.persistence-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- spring -->
|
||||
|
||||
@ -28,4 +28,6 @@ public class AddRedactionRequest {
|
||||
|
||||
private String comment;
|
||||
|
||||
private boolean forceAddToDictionary;
|
||||
|
||||
}
|
||||
|
||||
@ -16,5 +16,6 @@ public class ForceRedactionRequest {
|
||||
private AnnotationStatus status;
|
||||
private String legalBasis;
|
||||
private String comment;
|
||||
private int page;
|
||||
|
||||
}
|
||||
|
||||
@ -16,5 +16,6 @@ public class ImageRecategorizationRequest {
|
||||
private AnnotationStatus status;
|
||||
private String typeId;
|
||||
private String comment;
|
||||
private int page;
|
||||
|
||||
}
|
||||
|
||||
@ -16,5 +16,6 @@ public class LegalBasisChangeRequest {
|
||||
private AnnotationStatus status;
|
||||
private String legalBasis;
|
||||
private String comment;
|
||||
private int page;
|
||||
|
||||
}
|
||||
|
||||
@ -5,16 +5,12 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "manual_force_redaction")
|
||||
public class ManualForceRedaction {
|
||||
|
||||
private String annotationId;
|
||||
|
||||
@ -5,16 +5,12 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "manual_image_recategorization")
|
||||
public class ManualImageRecategorization {
|
||||
|
||||
private String annotationId;
|
||||
|
||||
@ -5,16 +5,12 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "manual_legal_basis_change")
|
||||
public class ManualLegalBasisChange {
|
||||
|
||||
private String annotationId;
|
||||
|
||||
@ -5,18 +5,14 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Table(name = "manual_redaction")
|
||||
public class ManualRedactionEntry {
|
||||
|
||||
private String annotationId;
|
||||
|
||||
@ -28,6 +28,9 @@ public class ManualRedactions {
|
||||
@Builder.Default
|
||||
private Set<ManualLegalBasisChange> legalBasisChanges = new HashSet<>();
|
||||
|
||||
@Builder.Default
|
||||
private Set<ManualResizeRedaction> resizeRedactions = new HashSet<>();
|
||||
|
||||
@Builder.Default
|
||||
private Map<String, List<Comment>> comments = new HashMap<>();
|
||||
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
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 ManualResizeRedaction {
|
||||
|
||||
private String annotationId;
|
||||
private String fileId;
|
||||
private String user;
|
||||
private AnnotationStatus status;
|
||||
private OffsetDateTime requestDate;
|
||||
private OffsetDateTime processedDate;
|
||||
private OffsetDateTime softDeletedTime;
|
||||
private String value;
|
||||
@Builder.Default
|
||||
private List<Rectangle> positions = new ArrayList<>();
|
||||
|
||||
}
|
||||
@ -5,20 +5,12 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "rectangle")
|
||||
public class Rectangle {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private long id;
|
||||
|
||||
|
||||
private float topLeftX;
|
||||
|
||||
@ -30,6 +22,4 @@ public class Rectangle {
|
||||
|
||||
private int page;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private ManualRedactionEntry manualRedaction;
|
||||
}
|
||||
|
||||
@ -16,5 +16,6 @@ public class RemoveRedactionRequest {
|
||||
private AnnotationStatus status;
|
||||
private boolean removeFromDictionary;
|
||||
private String comment;
|
||||
private int page;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.annotations;
|
||||
|
||||
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 ResizeRedactionRequest {
|
||||
|
||||
private String annotationId;
|
||||
private String user;
|
||||
private AnnotationStatus status;
|
||||
private String comment;
|
||||
private int page;
|
||||
private String value;
|
||||
|
||||
@Builder.Default
|
||||
private List<Rectangle> positions = new ArrayList<>();
|
||||
}
|
||||
@ -5,8 +5,6 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -15,8 +13,6 @@ import java.util.Map;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "audit")
|
||||
public class AuditModel {
|
||||
|
||||
private long recordId;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -23,14 +22,6 @@ public class CreateOrUpdateDossierTemplateRequest {
|
||||
|
||||
private String description;
|
||||
|
||||
private OffsetDateTime dateAdded;
|
||||
|
||||
private OffsetDateTime dateModified;
|
||||
|
||||
private String createdBy;
|
||||
|
||||
private String modifiedBy;
|
||||
|
||||
private OffsetDateTime validFrom;
|
||||
|
||||
private OffsetDateTime validTo;
|
||||
|
||||
@ -6,8 +6,6 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Id;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@ -15,7 +13,6 @@ import javax.persistence.Id;
|
||||
@AllArgsConstructor
|
||||
public class DossierAttributeConfig {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
private String label;
|
||||
private boolean editable;
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.ProcessingStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.WorkflowStatus;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DossierStats {
|
||||
private String dossierId;
|
||||
private int numberOfFiles;
|
||||
private int numberOfAnalysedPages; // sum of analysedPages
|
||||
private boolean hasRedactionsFilePresent; // true if at least one file in the dossier has redactions
|
||||
private boolean hasHintsNoRedactionsFilePresent; // true if at least one file in the dossier has hints but doesn't have redactions
|
||||
private boolean hasSuggestionsFilePresent; // true if at least one file in the dossier has suggestions
|
||||
private boolean hasUpdatesFilePresent; //true if at least one file in the dossier has updates
|
||||
private boolean hasNoFlagsFilePresent; // true if at least one file in the dossier has none of the other flags
|
||||
private Map<ProcessingStatus,Integer> fileCountPerProcessingStatus;
|
||||
private Map<WorkflowStatus,Integer> fileCountPerWorkflowStatus;
|
||||
}
|
||||
@ -6,8 +6,6 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -18,15 +16,13 @@ import java.util.Set;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "file")
|
||||
public class FileModel {
|
||||
|
||||
@JsonProperty("fileId")
|
||||
private String id;
|
||||
private String filename;
|
||||
private FileStatus status;
|
||||
private FileStatus lastSuccessfulStatus;
|
||||
private ProcessingStatus processingStatus;
|
||||
private WorkflowStatus workflowStatus;
|
||||
private int numberOfPages;
|
||||
private OffsetDateTime added;
|
||||
private OffsetDateTime lastUpdated;
|
||||
@ -42,6 +38,7 @@ public class FileModel {
|
||||
private boolean hasSuggestions;
|
||||
private boolean hasImages;
|
||||
private boolean hasUpdates;
|
||||
private boolean analysisRequired;
|
||||
private String uploader;
|
||||
private long dictionaryVersion;
|
||||
private long rulesVersion;
|
||||
@ -59,6 +56,7 @@ public class FileModel {
|
||||
private Set<Integer> excludedPages = new HashSet<>();
|
||||
private Map<String, String> fileAttributes = new HashMap<>();
|
||||
private String dossierId;
|
||||
private String dossierTemplateId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file;
|
||||
|
||||
public enum FileStatus {
|
||||
UNPROCESSED, REPROCESS, PROCESSING, ERROR, DELETED, UNASSIGNED, UNDER_REVIEW, UNDER_APPROVAL, APPROVED, FULLREPROCESS, OCR_PROCESSING, INDEXING
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file;
|
||||
|
||||
public enum ProcessingStatus {
|
||||
UNPROCESSED, REPROCESS, PROCESSING, PROCESSED, ERROR, DELETED, FULLREPROCESS, OCR_PROCESSING, INDEXING
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file;
|
||||
|
||||
public enum WorkflowStatus {
|
||||
UNASSIGNED, UNDER_REVIEW, UNDER_APPROVAL, APPROVED
|
||||
}
|
||||
@ -11,7 +11,6 @@ import lombok.NoArgsConstructor;
|
||||
@Builder
|
||||
public class LegalBasis {
|
||||
|
||||
private long id;
|
||||
private String name;
|
||||
private String description;
|
||||
private String reason;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.type;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -29,4 +30,10 @@ public class Type {
|
||||
private String dossierId;
|
||||
private List<DictionaryEntry> entries = new ArrayList<>();
|
||||
|
||||
// For auto-mappers
|
||||
@JsonIgnore
|
||||
public String getTypeId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.license;
|
||||
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileStatus;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -9,6 +7,8 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.WorkflowStatus;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@ -22,7 +22,7 @@ public class ReportData {
|
||||
private Instant deletedDate;
|
||||
private int numberOfAnalyzedPages;
|
||||
private int numberOfOcrPages;
|
||||
private FileStatus status;
|
||||
private WorkflowStatus workflowStatus;
|
||||
private int analysisCount;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.notification;
|
||||
|
||||
public enum EmailNotificationType {
|
||||
DAILY, DAILY_SUMMARY, WEEKLY_SUMMARY
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.notification;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class NotificationPreferences {
|
||||
|
||||
private String userId;
|
||||
private boolean inAppNotificationsEnabled;
|
||||
private boolean emailNotificationsEnabled;
|
||||
private EmailNotificationType emailNotificationType;
|
||||
@Builder.Default
|
||||
private List<String> emailNotifications = new ArrayList<>();
|
||||
@Builder.Default
|
||||
private List<String> inAppNotifications = new ArrayList<>();
|
||||
}
|
||||
@ -1,11 +1,13 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.resources;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.common.JSONPrimitive;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.CreateOrUpdateDossierRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.Dossier;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -20,6 +22,17 @@ public interface DossierResource {
|
||||
String DOSSIER_ID_PARAM = "dossierId";
|
||||
String DOSSIER_ID_PATH_PARAM = "/{" + DOSSIER_ID_PARAM + "}";
|
||||
|
||||
String INCLUDE_DELETED_PARAM = "includeDeleted";
|
||||
|
||||
String SINCE_REQUEST_PARAM="since";
|
||||
|
||||
String CHANGES_PATH = "/has-changes";
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@GetMapping(value = REST_PATH+CHANGES_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
JSONPrimitive<Boolean> hasChangesSince(@RequestParam(SINCE_REQUEST_PARAM) OffsetDateTime since);
|
||||
|
||||
@PostMapping(value = REST_PATH, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
Dossier addDossier(@RequestBody CreateOrUpdateDossierRequest dossierRequest);
|
||||
|
||||
@ -33,7 +46,8 @@ public interface DossierResource {
|
||||
List<Dossier> getAllDossiers();
|
||||
|
||||
@GetMapping(value = REST_PATH + DOSSIER_ID_PATH_PARAM, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
Dossier getDossierById(@PathVariable(DOSSIER_ID_PARAM) String dossierId);
|
||||
Dossier getDossierById(@PathVariable(DOSSIER_ID_PARAM) String dossierId,
|
||||
@RequestParam(name = INCLUDE_DELETED_PARAM, defaultValue = "false", required = false) boolean includeDeleted);
|
||||
|
||||
@GetMapping(value = DELETED_DOSSIERS_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
List<Dossier> getSoftDeletedDossiers();
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.resources;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.DossierStats;
|
||||
import org.springframework.http.MediaType;
|
||||
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 java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface DossierStatsResource {
|
||||
|
||||
String REST_PATH = "/dossier-stats";
|
||||
|
||||
String DOSSIER_ID_PARAM = "dossierId";
|
||||
String DOSSIER_ID_PATH_PARAM = "/{" + DOSSIER_ID_PARAM + "}";
|
||||
|
||||
@GetMapping(value = REST_PATH + DOSSIER_ID_PATH_PARAM, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
DossierStats getDossierStats(@PathVariable(DOSSIER_ID_PARAM) String dossierId);
|
||||
|
||||
@PostMapping(value = REST_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
List<DossierStats> getDossierStats(@RequestBody Set<String> dossierIds);
|
||||
}
|
||||
@ -10,16 +10,22 @@ import java.util.List;
|
||||
public interface LegalBasisMappingResource {
|
||||
|
||||
String LEGAL_BASIS_PATH = "/legalBasis";
|
||||
String DELETE_PATH = "/delete";
|
||||
String VERSION_PATH = "/version";
|
||||
String DOSSIER_TEMPLATE_PARAMETER_NAME = "dossierTemplateId";
|
||||
String DOSSIER_TEMPLATE_PATH_VARIABLE = "/{" + DOSSIER_TEMPLATE_PARAMETER_NAME + "}";
|
||||
|
||||
|
||||
@PostMapping(value = LEGAL_BASIS_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE + DELETE_PATH, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void deleteLegalBasis(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId, @RequestBody List<String> legalBasisNames);
|
||||
|
||||
@PutMapping(value = LEGAL_BASIS_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void addOrUpdateLegalBasis(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId, @RequestBody LegalBasis legalBasis);
|
||||
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
@PostMapping(value = LEGAL_BASIS_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void setLegalBasisMapping(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId, @RequestBody List<LegalBasis> legalBasisMapping);
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@GetMapping(value = LEGAL_BASIS_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@ -58,6 +58,12 @@ public interface ManualRedactionResource {
|
||||
@PathVariable(ANNOTATION_ID) String annotationId, @RequestBody CommentRequest comment);
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/resize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ManualAddResponse addResizeRedaction(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody ResizeRedactionRequest resizeRedactionRequest);
|
||||
|
||||
|
||||
@GetMapping(value = MANUAL_REDACTION_REST_PATH + "/add" + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ManualRedactionEntry getAddRedaction(@PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId);
|
||||
@ -87,6 +93,11 @@ public interface ManualRedactionResource {
|
||||
Comment getComment(@PathVariable(COMMENT_ID) long commentId);
|
||||
|
||||
|
||||
@GetMapping(value = MANUAL_REDACTION_REST_PATH + "/resize" + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ManualResizeRedaction getResizeRedaction(@PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId);
|
||||
|
||||
|
||||
@DeleteMapping(MANUAL_REDACTION_REST_PATH + "/add" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE)
|
||||
void deleteAddRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId);
|
||||
@ -116,6 +127,11 @@ public interface ManualRedactionResource {
|
||||
void deleteComment(@PathVariable(FILE_ID) String fileId, @PathVariable(COMMENT_ID) long commentId);
|
||||
|
||||
|
||||
@DeleteMapping(MANUAL_REDACTION_REST_PATH + "/resize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE)
|
||||
void deleteResizeRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId);
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/add" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void updateAddRedactionStatus(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@ -146,6 +162,11 @@ public interface ManualRedactionResource {
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest);
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/resize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void updateResizeRedactionStatus(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest);
|
||||
|
||||
|
||||
@GetMapping(value = MANUAL_REDACTION_REST_PATH + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ManualRedactions getManualRedactions(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.resources;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.notification.NotificationPreferences;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
public interface NotificationPreferencesResource {
|
||||
|
||||
String REST_PATH = "/notification-preferences";
|
||||
|
||||
String USER_ID_PARAM = "userId";
|
||||
String USER_ID_PATH_PARAM = "/{" + USER_ID_PARAM + "}";
|
||||
|
||||
|
||||
@PostMapping(value = REST_PATH + USER_ID_PATH_PARAM, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void setNotificationPreferences(@PathVariable(USER_ID_PARAM) String userId, @RequestBody NotificationPreferences notificationRequest);
|
||||
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@GetMapping(value = REST_PATH + USER_ID_PATH_PARAM, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
NotificationPreferences getNotificationPreferences(@PathVariable(USER_ID_PARAM) String userId);
|
||||
|
||||
@DeleteMapping(value = REST_PATH + USER_ID_PATH_PARAM, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void deleteNotificationPreferences(@PathVariable(USER_ID_PARAM) String userId);
|
||||
}
|
||||
@ -1,11 +1,13 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.resources;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.audit.AddNotificationRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.common.JSONPrimitive;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.notification.Notification;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@ -14,6 +16,7 @@ public interface NotificationResource {
|
||||
String NOTIFICATION_PATH = "/notification";
|
||||
String TOGGLE_SEEN_PATH = "/toggle-seen";
|
||||
String TOGGLE_READ_PATH = "/toggle-read";
|
||||
String CHANGES_PATH = "/has-changes";
|
||||
|
||||
String USER_ID_PARAM = "userId";
|
||||
String USER_ID_PATH_PARAM = "/{" + USER_ID_PARAM + "}";
|
||||
@ -21,7 +24,13 @@ public interface NotificationResource {
|
||||
String INCLUDE_SEEN_PARAM = "includeSeen";
|
||||
String SET_SEEN_PARAM = "setSeen";
|
||||
String SET_READ_PARAM = "setRead";
|
||||
String SINCE_REQUEST_PARAM = "since";
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@GetMapping(value = NOTIFICATION_PATH + CHANGES_PATH + USER_ID_PATH_PARAM, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
JSONPrimitive<Boolean> hasNewNotificationsSince(@PathVariable(USER_ID_PARAM) String userId,
|
||||
@RequestParam(SINCE_REQUEST_PARAM) OffsetDateTime since);
|
||||
|
||||
@PostMapping(value = NOTIFICATION_PATH, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void addNotification(@RequestBody AddNotificationRequest addNotificationRequest);
|
||||
|
||||
@ -6,6 +6,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -19,15 +20,26 @@ public interface StatusResource {
|
||||
String FILE_ID = "fileId";
|
||||
String FILE_ID_PATH_VARIABLE = "/{" + FILE_ID + "}";
|
||||
|
||||
String CHANGES_PATH = "/has-changes";
|
||||
|
||||
String EXCLUDED_STATUS_PARAM = "excluded";
|
||||
|
||||
String APPROVER_ID_REQUEST_PARAM = "approverId";
|
||||
String REVIEWER_ID_REQUEST_PARAM = "reviewerId";
|
||||
String SINCE_REQUEST_PARAM="since";
|
||||
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@GetMapping(value = STATUS_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
List<FileModel> getAllStatuses();
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@GetMapping(value = STATUS_PATH+DOSSIER_ID_PATH_PARAM+CHANGES_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
JSONPrimitive<Boolean> hasChangesSince(@PathVariable(DOSSIER_ID_PARAM) String dossierId, @RequestParam(SINCE_REQUEST_PARAM) OffsetDateTime since);
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@GetMapping(value = STATUS_PATH + DOSSIER_ID_PATH_PARAM, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ -47,7 +59,7 @@ public interface StatusResource {
|
||||
|
||||
@PostMapping(value = STATUS_PATH + "/reviewer" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void setCurrentFileReviewer(@PathVariable(DOSSIER_ID_PARAM) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody JSONPrimitive<String> currentReviewer);
|
||||
@RequestParam(value = REVIEWER_ID_REQUEST_PARAM, required =false) String reviewerId);
|
||||
|
||||
|
||||
@PostMapping(value = STATUS_PATH + "/underreview" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE)
|
||||
|
||||
@ -98,7 +98,6 @@
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>29.0-jre</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ public class CommentEntity {
|
||||
|
||||
@Column
|
||||
private OffsetDateTime date;
|
||||
@Column
|
||||
@Column(length = 4000)
|
||||
private String text;
|
||||
@Column(name = "user_id")
|
||||
private String user;
|
||||
|
||||
@ -23,6 +23,7 @@ public class IdRemovalEntity {
|
||||
@Column(name = "user_id")
|
||||
private String user;
|
||||
@Column
|
||||
@Enumerated(EnumType.STRING)
|
||||
private AnnotationStatus status;
|
||||
@Column
|
||||
private boolean removeFromDictionary;
|
||||
@ -32,6 +33,8 @@ public class IdRemovalEntity {
|
||||
private OffsetDateTime processedDate;
|
||||
@Column
|
||||
private OffsetDateTime softDeletedTime;
|
||||
@Column
|
||||
private int page;
|
||||
|
||||
@ManyToOne
|
||||
private FileEntity fileStatus;
|
||||
|
||||
@ -23,8 +23,9 @@ public class ManualForceRedactionEntity {
|
||||
@Column(name = "user_id")
|
||||
private String user;
|
||||
@Column
|
||||
@Enumerated(EnumType.STRING)
|
||||
private AnnotationStatus status;
|
||||
@Column
|
||||
@Column(length = 4000)
|
||||
private String legalBasis;
|
||||
@Column
|
||||
private OffsetDateTime requestDate;
|
||||
@ -32,6 +33,8 @@ public class ManualForceRedactionEntity {
|
||||
private OffsetDateTime processedDate;
|
||||
@Column
|
||||
private OffsetDateTime softDeletedTime;
|
||||
@Column
|
||||
private int page;
|
||||
|
||||
@ManyToOne
|
||||
private FileEntity fileStatus;
|
||||
|
||||
@ -23,6 +23,7 @@ public class ManualImageRecategorizationEntity {
|
||||
@Column(name = "user_id")
|
||||
private String user;
|
||||
@Column
|
||||
@Enumerated(EnumType.STRING)
|
||||
private AnnotationStatus status;
|
||||
@Column
|
||||
private String typeId;
|
||||
@ -32,6 +33,8 @@ public class ManualImageRecategorizationEntity {
|
||||
private OffsetDateTime processedDate;
|
||||
@Column
|
||||
private OffsetDateTime softDeletedTime;
|
||||
@Column
|
||||
private int page;
|
||||
|
||||
@ManyToOne
|
||||
private FileEntity fileStatus;
|
||||
|
||||
@ -24,6 +24,7 @@ public class ManualLegalBasisChangeEntity {
|
||||
@Column(name = "user_id")
|
||||
private String user;
|
||||
@Column
|
||||
@Enumerated(EnumType.STRING)
|
||||
private AnnotationStatus status;
|
||||
@Column
|
||||
private String legalBasis;
|
||||
@ -33,6 +34,8 @@ public class ManualLegalBasisChangeEntity {
|
||||
private OffsetDateTime processedDate;
|
||||
@Column
|
||||
private OffsetDateTime softDeletedTime;
|
||||
@Column
|
||||
private int page;
|
||||
|
||||
@ManyToOne
|
||||
private FileEntity fileStatus;
|
||||
|
||||
@ -24,15 +24,16 @@ public class ManualRedactionEntryEntity {
|
||||
private AnnotationEntityId id;
|
||||
@Column(name = "user_id")
|
||||
private String user;
|
||||
@Column
|
||||
@Column(length = 4000)
|
||||
private String typeId;
|
||||
@Column
|
||||
@Column(length = 4000)
|
||||
private String value;
|
||||
@Column
|
||||
@Column(length = 4000)
|
||||
private String reason;
|
||||
@Column
|
||||
private String legalBasis;
|
||||
@Column
|
||||
@Enumerated(EnumType.STRING)
|
||||
private AnnotationStatus status;
|
||||
@Column
|
||||
private boolean addToDictionary;
|
||||
@ -45,8 +46,7 @@ public class ManualRedactionEntryEntity {
|
||||
@Column
|
||||
private OffsetDateTime softDeletedTime;
|
||||
|
||||
|
||||
@OneToMany(mappedBy = "manualRedaction", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@ElementCollection
|
||||
private List<RectangleEntity> positions = new ArrayList<>();
|
||||
|
||||
@ManyToOne
|
||||
|
||||
@ -0,0 +1,56 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.entity.annotations;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "manual_resize_redaction")
|
||||
public class ManualResizeRedactionEntity {
|
||||
|
||||
@EmbeddedId
|
||||
private AnnotationEntityId id;
|
||||
@Column(name = "user_id")
|
||||
private String user;
|
||||
@Column
|
||||
@Enumerated(EnumType.STRING)
|
||||
private AnnotationStatus status;
|
||||
@Column
|
||||
private OffsetDateTime requestDate;
|
||||
@Column
|
||||
private OffsetDateTime processedDate;
|
||||
@Column
|
||||
private OffsetDateTime softDeletedTime;
|
||||
@Column
|
||||
private int page;
|
||||
@Column
|
||||
private String value;
|
||||
|
||||
@ManyToOne
|
||||
private FileEntity fileStatus;
|
||||
|
||||
@ElementCollection
|
||||
private List<RectangleEntity> positions = new ArrayList<>();
|
||||
|
||||
}
|
||||
@ -5,31 +5,19 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Embeddable
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "rectangle")
|
||||
public class RectangleEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private long id;
|
||||
|
||||
@Column
|
||||
private float topLeftX;
|
||||
@Column
|
||||
private float topLeftY;
|
||||
@Column
|
||||
private float width;
|
||||
@Column
|
||||
private float height;
|
||||
@Column
|
||||
private int page;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private ManualRedactionEntryEntity manualRedaction;
|
||||
}
|
||||
|
||||
@ -26,6 +26,10 @@ public class ViewedPageEntity {
|
||||
@MapsId("fileId")
|
||||
private FileEntity file;
|
||||
|
||||
public int getPage() {
|
||||
return this.id.page;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Embeddable
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.entity.audit;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.utils.JSONConverter;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.utils.JSONConverter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -32,7 +32,7 @@ public class AuditEntity {
|
||||
private String category;
|
||||
@Column
|
||||
private String userId;
|
||||
@Column
|
||||
@Column(length = 4000)
|
||||
private String message;
|
||||
|
||||
@Basic(fetch = FetchType.EAGER)
|
||||
|
||||
@ -19,7 +19,7 @@ public class DictionaryEntryEntity {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private long entryId;
|
||||
@Column
|
||||
@Column(length = 4000)
|
||||
private String value;
|
||||
@Column
|
||||
private long version;
|
||||
|
||||
@ -8,21 +8,16 @@ import lombok.NoArgsConstructor;
|
||||
import javax.persistence.*;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Table(name = "legal_basis")
|
||||
@Embeddable
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LegalBasisEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private long id;
|
||||
@Column
|
||||
private String name;
|
||||
@Column(columnDefinition = "text")
|
||||
@Column(length = 4000)
|
||||
private String description;
|
||||
@Column(columnDefinition = "text")
|
||||
@Column(length = 4000)
|
||||
private String reason;
|
||||
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ public class LegalBasisMappingEntity {
|
||||
@Column
|
||||
private long version;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@ElementCollection
|
||||
private List<LegalBasisEntity> legalBasis = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ public class TypeEntity {
|
||||
private boolean isCaseInsensitive;
|
||||
@Column
|
||||
private boolean isRecommendation;
|
||||
@Column
|
||||
@Column(length = 4000)
|
||||
private String description;
|
||||
@Column
|
||||
private long version;
|
||||
|
||||
@ -21,7 +21,7 @@ public class WatermarkEntity {
|
||||
@Id
|
||||
@Column
|
||||
private String dossierTemplateId;
|
||||
@Column(columnDefinition = "text")
|
||||
@Column(length = 4000)
|
||||
private String text;
|
||||
@Column
|
||||
private String hexColor;
|
||||
@ -32,6 +32,7 @@ public class WatermarkEntity {
|
||||
@Column
|
||||
private String fontType;
|
||||
@Column
|
||||
@Enumerated(EnumType.STRING)
|
||||
private WatermarkOrientation orientation;
|
||||
|
||||
@JsonIgnore
|
||||
|
||||
@ -27,6 +27,7 @@ public class DossierAttributeConfigEntity {
|
||||
private String placeholder;
|
||||
|
||||
@Column
|
||||
@Enumerated(EnumType.STRING)
|
||||
private DossierAttributeType type = DossierAttributeType.TEXT;
|
||||
|
||||
|
||||
|
||||
@ -21,7 +21,8 @@ public class DossierAttributeEntity {
|
||||
@EmbeddedId
|
||||
private DossierAttributeEntityId id;
|
||||
|
||||
@Column
|
||||
// TODO Maybe @Lob, for larger images
|
||||
@Column(columnDefinition = "TEXT")
|
||||
private String value;
|
||||
|
||||
@JsonIgnore
|
||||
|
||||
@ -34,6 +34,9 @@ public class DossierEntity {
|
||||
private OffsetDateTime date;
|
||||
|
||||
@Column
|
||||
private OffsetDateTime lastUpdated;
|
||||
|
||||
@Column(length = 4000)
|
||||
private String description;
|
||||
|
||||
@Column
|
||||
@ -52,6 +55,7 @@ public class DossierEntity {
|
||||
|
||||
@Builder.Default
|
||||
@ElementCollection
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Set<DownloadFileType> downloadFileTypes = new HashSet<>();
|
||||
|
||||
@Column
|
||||
|
||||
@ -27,10 +27,10 @@ public class DossierTemplateEntity {
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
@Column
|
||||
@Column(unique = true)
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
@Column(length = 4000)
|
||||
private String description;
|
||||
|
||||
@Column
|
||||
@ -55,6 +55,7 @@ public class DossierTemplateEntity {
|
||||
private boolean deleted;
|
||||
|
||||
@ElementCollection
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Set<DownloadFileType> downloadFileTypes = new HashSet<>();
|
||||
|
||||
@JsonIgnore
|
||||
|
||||
@ -34,6 +34,7 @@ public class FileAttributeConfigEntity {
|
||||
@Column
|
||||
private String placeholder;
|
||||
@Column
|
||||
@Enumerated(EnumType.STRING)
|
||||
private FileAttributeType type = FileAttributeType.TEXT;
|
||||
|
||||
@ManyToOne
|
||||
|
||||
@ -14,7 +14,7 @@ public class FileAttributeEntity {
|
||||
@EmbeddedId
|
||||
private FileAttributeEntityId fileAttributeId;
|
||||
|
||||
@Column
|
||||
@Column(length = 4000)
|
||||
private String value;
|
||||
|
||||
@JsonIgnore
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.entity.dossier;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.ProcessingStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.WorkflowStatus;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -29,10 +31,12 @@ public class FileEntity {
|
||||
private String filename;
|
||||
|
||||
@Column
|
||||
private FileStatus status;
|
||||
@Enumerated(EnumType.STRING)
|
||||
private ProcessingStatus processingStatus;
|
||||
|
||||
@Column
|
||||
private FileStatus lastSuccessfulStatus;
|
||||
@Enumerated(EnumType.STRING)
|
||||
private WorkflowStatus workflowStatus;
|
||||
|
||||
@Column
|
||||
private int numberOfPages;
|
||||
|
||||
@ -31,6 +31,7 @@ public class DownloadStatusEntity {
|
||||
@Column
|
||||
private String mimeType;
|
||||
@Column
|
||||
@Enumerated(EnumType.STRING)
|
||||
private DownloadStatusValue status;
|
||||
@Column
|
||||
private OffsetDateTime creationDate;
|
||||
@ -46,6 +47,7 @@ public class DownloadStatusEntity {
|
||||
private List<FileEntity> files = new ArrayList<>();
|
||||
|
||||
@ElementCollection
|
||||
@Enumerated(EnumType.STRING)
|
||||
private List<DownloadFileType> downloadFileTypes = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.entity.notification;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.utils.JSONConverter;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.utils.JSONConverter;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.entity.notification;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.notification.EmailNotificationType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "notification_preference")
|
||||
public class NotificationPreferencesEntity {
|
||||
|
||||
@Id
|
||||
private String userId;
|
||||
|
||||
@Column
|
||||
private boolean inAppNotificationsEnabled;
|
||||
|
||||
@Column
|
||||
private boolean emailNotificationsEnabled;
|
||||
|
||||
@Column
|
||||
private EmailNotificationType emailNotificationType;
|
||||
|
||||
@ElementCollection
|
||||
private List<String> emailNotifications = new ArrayList<>();
|
||||
|
||||
@ElementCollection
|
||||
private List<String> inAppNotifications = new ArrayList<>();
|
||||
}
|
||||
@ -1,7 +1,6 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.ColorsEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.ColorsRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -15,12 +14,25 @@ public class ColorsService {
|
||||
private final ColorsRepository colorsRepository;
|
||||
|
||||
public void deleteColors(String dossierTemplateId) {
|
||||
|
||||
colorsRepository.deleteById(dossierTemplateId);
|
||||
}
|
||||
|
||||
public ColorsEntity getColors(String dossierTemplateId) {
|
||||
return colorsRepository.findById(dossierTemplateId).orElseThrow(() -> new NotFoundException("Colors Configuration not found"));
|
||||
return colorsRepository.findById(dossierTemplateId).orElseGet(() -> {
|
||||
var entity = new ColorsEntity();
|
||||
entity.setDossierTemplateId(dossierTemplateId);
|
||||
entity.setAnalysisColor("#aaaaaa");
|
||||
entity.setDefaultColor("#aaaaaa");
|
||||
entity.setDictionaryRequestColor("#aaaaaa");
|
||||
entity.setPreviewColor("#aaaaaa");
|
||||
entity.setNotRedacted("#aaaaaa");
|
||||
entity.setManualRedactionColor("#aaaaaa");
|
||||
entity.setRequestAdd("#aaaaaa");
|
||||
entity.setRequestRemove("#aaaaaa");
|
||||
entity.setUpdatedColor("#aaaaaa");
|
||||
return colorsRepository.save(entity);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public ColorsEntity saveColors(ColorsEntity colors) {
|
||||
|
||||
@ -56,14 +56,15 @@ public class DigitalSignatureService {
|
||||
@Transactional
|
||||
public void updateDigitalSignature(DigitalSignatureEntity digitalSignatureModel) {
|
||||
|
||||
digitalSignatureRepository.findById(DigitalSignatureEntity.ID).ifPresentOrElse(digitalSignature -> {
|
||||
digitalSignature.setCertificateName(digitalSignatureModel.getCertificateName());
|
||||
digitalSignature.setLocation(digitalSignatureModel.getLocation());
|
||||
digitalSignature.setContactInfo(digitalSignatureModel.getContactInfo());
|
||||
digitalSignature.setReason(digitalSignatureModel.getReason());
|
||||
}, () -> {
|
||||
int updateCount = digitalSignatureRepository.updateDigitalSignature(DigitalSignatureEntity.ID,
|
||||
digitalSignatureModel.getReason(),
|
||||
digitalSignatureModel.getLocation(),
|
||||
digitalSignatureModel.getContactInfo(),
|
||||
digitalSignatureModel.getCertificateName());
|
||||
if (updateCount == 0) {
|
||||
throw new NotFoundException("Digital Signature Not found");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,61 +1,107 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.GCMParameterSpec;
|
||||
import javax.crypto.spec.PBEKeySpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.spec.KeySpec;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
|
||||
@Service
|
||||
public class EncryptionDecryptionService {
|
||||
|
||||
@Value("${configuration-service.crypto.key:redaction}")
|
||||
@Value("${persistence-service.crypto.key:redaction}")
|
||||
private String key;
|
||||
private SecretKeySpec secretKey;
|
||||
|
||||
private SecretKey secretKey;
|
||||
private byte[] iv;
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@PostConstruct
|
||||
protected void postConstruct() {
|
||||
byte[] keyBytes = key.getBytes(StandardCharsets.UTF_8);
|
||||
var sha = MessageDigest.getInstance("SHA-1");
|
||||
keyBytes = sha.digest(keyBytes);
|
||||
keyBytes = Arrays.copyOf(keyBytes, 16);
|
||||
secretKey = new SecretKeySpec(keyBytes, "AES");
|
||||
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
iv = new byte[12];
|
||||
secureRandom.nextBytes(iv);
|
||||
secretKey = generateSecretKey(key, iv);
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
public String encrypt(String strToEncrypt) {
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||
return Base64.getEncoder().encodeToString(cipher.doFinal(strToEncrypt.getBytes(StandardCharsets.UTF_8)));
|
||||
|
||||
return Base64.getEncoder().encodeToString(encrypt(strToEncrypt.getBytes()));
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public byte[] encrypt(byte[] bytes) {
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||
return cipher.doFinal(bytes);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public byte[] decrypt(byte[] bytes) {
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||
return cipher.doFinal(bytes);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public String decrypt(String strToDecrypt) {
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey);
|
||||
return new String(cipher.doFinal(Base64.getDecoder().decode(strToDecrypt)), StandardCharsets.UTF_8);
|
||||
|
||||
byte[] bytes = Base64.getDecoder().decode(strToDecrypt);
|
||||
return new String(decrypt(bytes), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
public byte[] encrypt(byte[] data) {
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
||||
GCMParameterSpec parameterSpec = new GCMParameterSpec(128, iv);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey, parameterSpec);
|
||||
byte[] encryptedData = cipher.doFinal(data);
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocate(4 + iv.length + encryptedData.length);
|
||||
byteBuffer.putInt(iv.length);
|
||||
byteBuffer.put(iv);
|
||||
byteBuffer.put(encryptedData);
|
||||
return byteBuffer.array();
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
public byte[] decrypt(byte[] encryptedData) {
|
||||
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(encryptedData);
|
||||
int noonceSize = byteBuffer.getInt();
|
||||
if (noonceSize < 12 || noonceSize >= 16) {
|
||||
throw new IllegalArgumentException("Nonce size is incorrect. Make sure that the incoming data is an AES encrypted file.");
|
||||
}
|
||||
byte[] iv = new byte[noonceSize];
|
||||
byteBuffer.get(iv);
|
||||
|
||||
SecretKey secretKey = generateSecretKey(key, iv);
|
||||
|
||||
byte[] cipherBytes = new byte[byteBuffer.remaining()];
|
||||
byteBuffer.get(cipherBytes);
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
||||
GCMParameterSpec parameterSpec = new GCMParameterSpec(128, iv);
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey, parameterSpec);
|
||||
return cipher.doFinal(cipherBytes);
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
public SecretKey generateSecretKey(String password, byte[] iv) {
|
||||
|
||||
KeySpec spec = new PBEKeySpec(password.toCharArray(), iv, 65536, 128); // AES-128
|
||||
SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
|
||||
byte[] key = secretKeyFactory.generateSecret(spec).getEncoded();
|
||||
return new SecretKeySpec(key, "AES");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -32,7 +33,7 @@ public class AddRedactionPersistenceService {
|
||||
ManualRedactionEntryEntity manualRedactionEntry = new ManualRedactionEntryEntity();
|
||||
manualRedactionEntry.setId(new AnnotationEntityId(annotationId, fileId));
|
||||
BeanUtils.copyProperties(addRedactionRequest, manualRedactionEntry);
|
||||
manualRedactionEntry.setRequestDate(OffsetDateTime.now());
|
||||
manualRedactionEntry.setRequestDate(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
manualRedactionEntry.setPositions(convert(addRedactionRequest.getPositions()));
|
||||
manualRedactionEntry.setTypeId(addRedactionRequest.getTypeId());
|
||||
|
||||
@ -76,36 +77,30 @@ public class AddRedactionPersistenceService {
|
||||
|
||||
@Transactional
|
||||
public void softDelete(String fileId, String annotationId, OffsetDateTime softDeleteTime) {
|
||||
manualRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> mre.setSoftDeletedTime(softDeleteTime));
|
||||
manualRedactionRepository.updateSoftDelete(new AnnotationEntityId(annotationId, fileId), softDeleteTime);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void undelete(String fileId, String annotationId) {
|
||||
manualRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> mre.setSoftDeletedTime(null));
|
||||
manualRedactionRepository.updateSoftDelete(new AnnotationEntityId(annotationId, fileId), null);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateStatus(String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
|
||||
manualRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> {
|
||||
mre.setProcessedDate(OffsetDateTime.now());
|
||||
mre.setStatus(annotationStatus);
|
||||
});
|
||||
|
||||
|
||||
manualRedactionRepository.updateStatus(new AnnotationEntityId(annotationId, fileId),
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS),
|
||||
annotationStatus);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateStatus(String fileId, String annotationId, AnnotationStatus annotationStatus, boolean isAddOrRemoveFromDictionary) {
|
||||
|
||||
manualRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> {
|
||||
mre.setProcessedDate(OffsetDateTime.now());
|
||||
mre.setStatus(annotationStatus);
|
||||
mre.setAddToDictionary(isAddOrRemoveFromDictionary);
|
||||
});
|
||||
|
||||
manualRedactionRepository.updateStatus(new AnnotationEntityId(annotationId, fileId),
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS),
|
||||
annotationStatus,
|
||||
isAddOrRemoveFromDictionary);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -8,23 +8,22 @@ import com.iqser.red.service.persistence.service.v1.api.model.audit.CategoryMode
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.ExampleMatcher;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.AuditRepository.*;
|
||||
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AuditPersistenceService {
|
||||
|
||||
private final static String AUDIT_LOG_CATEGORY = "AUDIT_LOG";
|
||||
|
||||
private final AuditRepository auditRepository;
|
||||
|
||||
@ -34,7 +33,7 @@ public class AuditPersistenceService {
|
||||
|
||||
var auditModel = new AuditEntity();
|
||||
BeanUtils.copyProperties(auditRequest, auditModel);
|
||||
auditModel.setRecordDate(OffsetDateTime.now());
|
||||
auditModel.setRecordDate(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
|
||||
auditRepository.save(auditModel);
|
||||
|
||||
@ -47,40 +46,29 @@ public class AuditPersistenceService {
|
||||
|
||||
public Page<AuditEntity> search(AuditSearchRequest auditRequest) {
|
||||
|
||||
if (auditRequest.getPageSize() == 0) {
|
||||
auditRequest.setPageSize(50);
|
||||
}
|
||||
|
||||
AuditEntity example = new AuditEntity();
|
||||
example.setCategory(auditRequest.getCategory());
|
||||
example.setUserId(auditRequest.getUserId());
|
||||
example.setObjectId(auditRequest.getObjectId());
|
||||
if (auditRequest.getFrom() == null) {
|
||||
auditRequest.setFrom(OffsetDateTime.now().minusYears(30).truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
if (auditRequest.getTo() == null) {
|
||||
auditRequest.setTo(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
var result = auditRepository.findAll(Example.of(example, ExampleMatcher.matchingAny().withIgnorePaths("recordId")),
|
||||
PageRequest.of(auditRequest.getPage(), auditRequest.getPageSize()));
|
||||
|
||||
// after search, insert a record logging the search
|
||||
this.insertRecord(AuditRequest.builder()
|
||||
.category(AUDIT_LOG_CATEGORY)
|
||||
.message("Audit Log Accessed")
|
||||
.userId(auditRequest.getRequestingUserId())
|
||||
.details(searchRequestToMap(auditRequest))
|
||||
.build());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, Object> searchRequestToMap(AuditSearchRequest auditSearchRequest) {
|
||||
|
||||
var map = new HashMap<String, Object>();
|
||||
|
||||
map.put("userId", auditSearchRequest.getUserId());
|
||||
map.put("category", auditSearchRequest.getCategory());
|
||||
map.put("objectId", auditSearchRequest.getObjectId());
|
||||
map.put("from", auditSearchRequest.getFrom());
|
||||
map.put("to", auditSearchRequest.getTo());
|
||||
map.put("page", auditSearchRequest.getPage());
|
||||
map.put("pageSize", auditSearchRequest.getPageSize());
|
||||
|
||||
return map;
|
||||
var spec = Specification.where(dateBetween(auditRequest.getFrom(), auditRequest.getTo()));
|
||||
if (auditRequest.getCategory() != null) {
|
||||
spec = spec.and(categoryMatches(auditRequest.getCategory()));
|
||||
}
|
||||
if (auditRequest.getUserId() != null) {
|
||||
spec = spec.and(userMatches(auditRequest.getUserId()));
|
||||
}
|
||||
if (auditRequest.getObjectId() != null) {
|
||||
spec = spec.and(objectIdMatches(auditRequest.getObjectId()));
|
||||
}
|
||||
|
||||
return auditRepository.findAll(spec, PageRequest.of(auditRequest.getPage(), auditRequest.getPageSize()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -55,16 +55,12 @@ public class CommentPersistenceService {
|
||||
@Transactional
|
||||
public void softDelete(long commentId, OffsetDateTime softDeletedTime) {
|
||||
|
||||
commentRepository.findById(commentId).ifPresent(mre -> {
|
||||
mre.setSoftDeletedTime(softDeletedTime);
|
||||
});
|
||||
commentRepository.updateSoftDelete(commentId, softDeletedTime);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void undelete(long commentId) {
|
||||
commentRepository.findById(commentId).ifPresent(mre -> {
|
||||
mre.setSoftDeletedTime(null);
|
||||
});
|
||||
commentRepository.updateSoftDelete(commentId, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ import com.iqser.red.service.persistence.management.v1.processor.service.persist
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.DossierTemplateRepository;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.TypeRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -36,7 +35,7 @@ public class DictionaryPersistenceService {
|
||||
checkRankAlreadyExists(type, dossierTemplateId, rank, dossierId);
|
||||
|
||||
TypeEntity t = new TypeEntity();
|
||||
t.setId(toTypeId(type,dossierTemplateId,dossierId));
|
||||
t.setId(toTypeId(type, dossierTemplateId, dossierId));
|
||||
t.setType(type);
|
||||
t.setDossier(dossierId == null ? null : dossierRepository.getOne(dossierId));
|
||||
t.setDossierTemplate(dossierTemplateRepository.getOne(dossierTemplateId));
|
||||
@ -55,7 +54,6 @@ public class DictionaryPersistenceService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateType(String typeId, TypeEntity typeValueRequest) {
|
||||
|
||||
@ -84,7 +82,7 @@ public class DictionaryPersistenceService {
|
||||
|
||||
|
||||
public List<TypeEntity> getAllTypesForDossierTemplate(String dossierTemplateId) {
|
||||
return typeRepository.findByDossierTemplateId(dossierTemplateId).stream().filter( d -> d.getDossierId() == null).collect(Collectors.toList());
|
||||
return typeRepository.findByDossierTemplateId(dossierTemplateId).stream().filter(d -> d.getDossierId() == null).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<TypeEntity> getAllTypesForDossier(String dossierId) {
|
||||
@ -118,5 +116,13 @@ public class DictionaryPersistenceService {
|
||||
typeRepository.updateByIdSetIncrementVersionByOne(typeId);
|
||||
}
|
||||
|
||||
public long getVersion(String dossierTemplateId) {
|
||||
return getAllTypesForDossierTemplate(dossierTemplateId).stream().map(TypeEntity::getVersion).reduce(0L, Long::sum);
|
||||
}
|
||||
|
||||
public long getVersionForDossier(String dossierId) {
|
||||
return getAllTypesForDossier(dossierId).stream().map(TypeEntity::getVersion).reduce(0L, Long::sum);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ public class DossierAttributePersistenceService {
|
||||
@Transactional
|
||||
public void updateDossierAttribute(String dossierId, String dossierAttributeId, String dossierAttributeValue) {
|
||||
|
||||
dossierAttributeRepository.findById(new DossierAttributeEntity.DossierAttributeEntityId(dossierId, dossierAttributeId)).ifPresent(dossierAttribute -> dossierAttribute.setValue(dossierAttributeValue));
|
||||
dossierAttributeRepository.updateDossierAttribute(new DossierAttributeEntity.DossierAttributeEntityId(dossierId, dossierAttributeId), dossierAttributeValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -14,10 +14,9 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.exception.DossierNotFoundException.DOSSIER_NOT_FOUND_MESSAGE;
|
||||
|
||||
@ -30,15 +29,19 @@ public class DossierPersistenceService {
|
||||
private final DossierTemplateRepository dossierTemplateRepository;
|
||||
private final ReportTemplateRepository reportTemplateRepository;
|
||||
|
||||
|
||||
public DossierEntity insert(CreateOrUpdateDossierRequest createOrUpdateDossierRequest) {
|
||||
|
||||
DossierEntity dossier = new DossierEntity();
|
||||
BeanUtils.copyProperties(createOrUpdateDossierRequest, dossier);
|
||||
dossier.setId(UUID.randomUUID().toString());
|
||||
dossier.setStatus(DossierStatus.ACTIVE);
|
||||
|
||||
dossier.setDate(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
dossier.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
dossier.setDossierTemplate(dossierTemplateRepository.getOne(createOrUpdateDossierRequest.getDossierTemplateId()));
|
||||
dossier.setReportTemplates(reportTemplateRepository.findAllById(createOrUpdateDossierRequest.getReportTemplateIds()));
|
||||
var reportTemplates = reportTemplateRepository.findAllById(createOrUpdateDossierRequest.getReportTemplateIds());
|
||||
reportTemplates.forEach(r -> r.getDossiers().add(dossier));
|
||||
dossier.setReportTemplates(reportTemplates);
|
||||
|
||||
return dossierRepository.save(dossier);
|
||||
|
||||
@ -52,20 +55,15 @@ public class DossierPersistenceService {
|
||||
dossierRepository.findById(dossierId).ifPresent(dossier -> {
|
||||
BeanUtils.copyProperties(createOrUpdateDossierRequest, dossier);
|
||||
dossier.setDossierTemplate(dossierTemplateRepository.getOne(createOrUpdateDossierRequest.getDossierTemplateId()));
|
||||
dossier.setReportTemplates(reportTemplateRepository.findAllById(createOrUpdateDossierRequest.getReportTemplateIds()));
|
||||
dossier.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
var reportTemplates = reportTemplateRepository.findAllById(createOrUpdateDossierRequest.getReportTemplateIds());
|
||||
reportTemplates.forEach(r -> r.getDossiers().add(dossier));
|
||||
dossier.setReportTemplates(reportTemplates);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateReportTemplateIds(String dossierId, Set<String> reportTemplateIds) {
|
||||
dossierRepository.findById(dossierId).ifPresent(dossier -> {
|
||||
dossier.setReportTemplates(reportTemplateRepository.findAllById(reportTemplateIds));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public DossierEntity getAndValidateDossier(String dossierId) {
|
||||
// check whether the dossierId exists and is not deleted
|
||||
var dossier = findByDossierId(dossierId);
|
||||
@ -87,41 +85,27 @@ public class DossierPersistenceService {
|
||||
}
|
||||
|
||||
|
||||
public List<DossierEntity> findSoftDeletedDossiers() {
|
||||
|
||||
return findAllDossiers().stream().filter(d -> d.getSoftDeletedTime() != null).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void hardDelete(String dossierId) {
|
||||
dossierRepository.findById(dossierId).ifPresent(dossier -> {
|
||||
dossier.setHardDeletedTime(OffsetDateTime.now());
|
||||
dossier.setStatus(DossierStatus.DELETED);
|
||||
dossier.setSoftDeletedTime(dossier.getSoftDeletedTime() == null ? OffsetDateTime.now() : dossier.getSoftDeletedTime());
|
||||
});
|
||||
dossierRepository.hardDelete(dossierId, DossierStatus.DELETED, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void undelete(String dossierId) {
|
||||
dossierRepository.findById(dossierId).ifPresent(dossier -> {
|
||||
if (dossier.getHardDeletedTime() != null) {
|
||||
throw new BadRequestException("Cannot undelete a hard-dossier file!");
|
||||
}
|
||||
dossier.setStatus(DossierStatus.ACTIVE);
|
||||
dossier.setSoftDeletedTime(null);
|
||||
});
|
||||
int updateCount = dossierRepository.undelete(dossierId, DossierStatus.ACTIVE, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
if (updateCount == 0) {
|
||||
throw new BadRequestException("Cannot undelete a hard-deleted dossier!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void markDossierAsDeleted(String dossierId, OffsetDateTime softDeletedTime) {
|
||||
dossierRepository.findById(dossierId).ifPresent(dossier -> {
|
||||
dossier.setStatus(DossierStatus.DELETED);
|
||||
dossier.setSoftDeletedTime(softDeletedTime);
|
||||
});
|
||||
dossierRepository.markDossierAsDeleted(dossierId, DossierStatus.DELETED, softDeletedTime, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
public boolean hasChangesSince(OffsetDateTime since) {
|
||||
return dossierRepository.existsByLastUpdatedIsAfter(since.truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@ -30,9 +31,10 @@ public class DossierTemplatePersistenceService {
|
||||
if (createOrUpdateDossierRequest.getDossierTemplateId() != null) {
|
||||
Optional<DossierTemplateEntity> dossierTemplate = dossierTemplateRepository.findById(createOrUpdateDossierRequest.getDossierTemplateId());
|
||||
if (dossierTemplate.isPresent()) {
|
||||
dossierTemplate.get().setDateModified(OffsetDateTime.now());
|
||||
dossierTemplate.get().setModifiedBy(createOrUpdateDossierRequest.getRequestingUser());
|
||||
// order is important
|
||||
BeanUtils.copyProperties(createOrUpdateDossierRequest, dossierTemplate.get());
|
||||
dossierTemplate.get().setDateModified(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
dossierTemplate.get().setModifiedBy(createOrUpdateDossierRequest.getRequestingUser());
|
||||
return dossierTemplate.get();
|
||||
} else {
|
||||
throw new NotFoundException(String.format(DOSSIER_TEMPLATE_NOT_FOUND_MESSAGE, createOrUpdateDossierRequest.getDossierTemplateId()));
|
||||
@ -40,9 +42,10 @@ public class DossierTemplatePersistenceService {
|
||||
} else {
|
||||
DossierTemplateEntity dossierTemplate = new DossierTemplateEntity();
|
||||
dossierTemplate.setId(UUID.randomUUID().toString());
|
||||
dossierTemplate.setDateAdded(OffsetDateTime.now());
|
||||
dossierTemplate.setCreatedBy(createOrUpdateDossierRequest.getRequestingUser());
|
||||
// order is important
|
||||
BeanUtils.copyProperties(createOrUpdateDossierRequest, dossierTemplate);
|
||||
dossierTemplate.setDateAdded(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
dossierTemplate.setCreatedBy(createOrUpdateDossierRequest.getRequestingUser());
|
||||
return dossierTemplateRepository.save(dossierTemplate);
|
||||
}
|
||||
|
||||
@ -64,7 +67,7 @@ public class DossierTemplatePersistenceService {
|
||||
if (dossierTemplate.getDossiers().isEmpty()) {
|
||||
|
||||
dossierTemplate.setModifiedBy(deletingUserId);
|
||||
dossierTemplate.setDateModified(OffsetDateTime.now());
|
||||
dossierTemplate.setDateModified(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
dossierTemplate.setDeleted(true);
|
||||
} else {
|
||||
throw new BadRequestException("Cannot delete dossier template with active dossiers!");
|
||||
|
||||
@ -5,13 +5,17 @@ import com.iqser.red.service.persistence.management.v1.processor.entity.download
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.DownloadStatusRepository;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.FileRepository;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.DownloadFileType;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.download.DownloadStatusValue;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ -21,7 +25,7 @@ public class DownloadStatusPersistenceService {
|
||||
private final FileRepository fileRepository;
|
||||
|
||||
public void createStatus(String userId, String storageId, DossierEntity dossier, String filename, String mimeType,
|
||||
List<String> fileIds) {
|
||||
List<String> fileIds, Set<DownloadFileType> downloadFileTypes) {
|
||||
|
||||
|
||||
DownloadStatusEntity downloadStatus = new DownloadStatusEntity();
|
||||
@ -30,8 +34,9 @@ public class DownloadStatusPersistenceService {
|
||||
downloadStatus.setFilename(filename);
|
||||
downloadStatus.setMimeType(mimeType);
|
||||
downloadStatus.setDossier(dossier);
|
||||
downloadStatus.setCreationDate(OffsetDateTime.now());
|
||||
downloadStatus.setCreationDate(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
downloadStatus.setFiles(fileRepository.findAllById(fileIds));
|
||||
downloadStatus.setDownloadFileTypes(new ArrayList<>(downloadFileTypes));
|
||||
|
||||
downloadStatusRepository.save(downloadStatus);
|
||||
}
|
||||
@ -40,26 +45,19 @@ public class DownloadStatusPersistenceService {
|
||||
@Transactional
|
||||
public void updateStatus(String storageId, DownloadStatusValue status) {
|
||||
|
||||
downloadStatusRepository.findById(storageId).ifPresent(downloadStatus -> downloadStatus.setStatus(status));
|
||||
downloadStatusRepository.updateStatus(storageId, status);
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateStatus(String storageId, DownloadStatusValue status, long fileSize) {
|
||||
downloadStatusRepository.findById(storageId).ifPresent(downloadStatus -> {
|
||||
downloadStatus.setStatus(status);
|
||||
downloadStatus.setFileSize(fileSize);
|
||||
});
|
||||
downloadStatusRepository.updateStatus(storageId, status, fileSize);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateLastDownload(String storageId) {
|
||||
|
||||
downloadStatusRepository.findById(storageId).ifPresent(downloadStatus -> {
|
||||
downloadStatus.setLastDownload(OffsetDateTime.now());
|
||||
});
|
||||
|
||||
downloadStatusRepository.updateLastDownload(storageId, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
|
||||
@ -83,7 +81,6 @@ public class DownloadStatusPersistenceService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<DownloadStatusEntity> getStatus() {
|
||||
|
||||
return downloadStatusRepository.findAll();
|
||||
|
||||
@ -50,7 +50,6 @@ public class EntryPersistenceService {
|
||||
|
||||
|
||||
public List<DictionaryEntryEntity> getEntries(String typeId) {
|
||||
|
||||
return entryRepository.findByTypeId(typeId);
|
||||
|
||||
|
||||
|
||||
@ -1,20 +1,26 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service.persistence;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileAttributeConfigEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileAttributeEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.DossierRepository;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.FileAttributesRepository;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.FileRepository;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.ProcessingStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.WorkflowStatus;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ -22,6 +28,9 @@ public class FileStatusPersistenceService {
|
||||
|
||||
private final FileRepository fileRepository;
|
||||
private final DossierRepository dossierRepository;
|
||||
private final FileAttributesRepository fileAttributesRepository;
|
||||
private final FileAttributeConfigPersistenceService fileAttributeConfigPersistenceService;
|
||||
private final DossierPersistenceService dossierService;
|
||||
|
||||
|
||||
public void createStatus(String dossierId, String fileId, String filename, String uploader) {
|
||||
@ -30,35 +39,37 @@ public class FileStatusPersistenceService {
|
||||
file.setId(fileId);
|
||||
file.setDossier(dossierRepository.getOne(dossierId));
|
||||
file.setFilename(filename);
|
||||
file.setStatus(FileStatus.UNPROCESSED);
|
||||
file.setProcessingStatus(ProcessingStatus.UNPROCESSED);
|
||||
file.setWorkflowStatus(WorkflowStatus.UNASSIGNED);
|
||||
file.setNumberOfPages(0);
|
||||
file.setAdded(OffsetDateTime.now());
|
||||
file.setAdded(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setUploader(uploader);
|
||||
file.setLastUploaded(OffsetDateTime.now());
|
||||
|
||||
file.setLastUploaded(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
fileRepository.save(file);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateStatusSuccessful(String fileId, int numberOfPages, FileStatus status,
|
||||
boolean hasUpdates, long dictionaryVersion, long rulesVersion,
|
||||
long legalBasisVersion, long duration, long dossierDictionaryVersion,
|
||||
int analysisVersion) {
|
||||
public void updateWorkflowStatus(String fileId, int numberOfPages, long dictionaryVersion, long rulesVersion,
|
||||
long legalBasisVersion, long duration, long dossierDictionaryVersion,
|
||||
int analysisVersion) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setNumberOfPages(numberOfPages);
|
||||
file.setStatus(status);
|
||||
file.setLastSuccessfulStatus(status);
|
||||
file.setHasUpdates(hasUpdates);
|
||||
file.setProcessingStatus(ProcessingStatus.PROCESSED);
|
||||
file.setDictionaryVersion(dictionaryVersion);
|
||||
file.setRulesVersion(rulesVersion);
|
||||
file.setLegalBasisVersion(legalBasisVersion);
|
||||
file.setAnalysisDuration(duration);
|
||||
file.setDossierDictionaryVersion(dossierDictionaryVersion);
|
||||
file.setAnalysisVersion(analysisVersion);
|
||||
file.setLastUpdated(OffsetDateTime.now());
|
||||
file.setLastProcessed(OffsetDateTime.now());
|
||||
file.setNumberOfAnalyses(file.getNumberOfAnalyses() + 1);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastProcessed(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
@ -67,79 +78,73 @@ public class FileStatusPersistenceService {
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateFlags(String fileId,boolean hasRedactions,boolean hasHints,boolean hasImages,boolean hasSuggestions,boolean hasComments){
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setHasRedactions(hasRedactions);
|
||||
file.setHasHints(hasHints);
|
||||
file.setHasImages(hasImages);
|
||||
file.setHasSuggestions(hasSuggestions);
|
||||
file.setHasAnnotationComments(hasComments);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
}
|
||||
public void updateFlags(String fileId, boolean hasRedactions, boolean hasHints, boolean hasImages,
|
||||
boolean hasSuggestions, boolean hasComments, boolean hasUpdates) {
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateStatusSuccessful(String fileId, FileStatus status, boolean approval) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setStatus(status);
|
||||
file.setLastSuccessfulStatus(status);
|
||||
file.setLastUpdated(OffsetDateTime.now());
|
||||
file.setApprovalDate(approval ? OffsetDateTime.now() : null);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateStatus(String fileId, FileStatus status, String uploader) {
|
||||
|
||||
if (status.equals(FileStatus.UNASSIGNED) || status.equals(FileStatus.UNPROCESSED)) {
|
||||
throw new IllegalArgumentException("please use specific methods for these calls!");
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setStatus(status);
|
||||
file.setUploader(uploader);
|
||||
file.setLastUploaded(OffsetDateTime.now());
|
||||
file.setLastUpdated(OffsetDateTime.now());
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
fileRepository.updateFlags(fileId, OffsetDateTime.now(), hasRedactions, hasHints, hasImages, hasSuggestions, hasComments, hasUpdates);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateStatus(String fileId, FileStatus status) {
|
||||
public void updateWorkflowStatus(String fileId, WorkflowStatus workflowStatus, boolean approval) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setStatus(status);
|
||||
file.setLastUpdated(OffsetDateTime.now());
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setWorkflowStatus(workflowStatus);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setApprovalDate(approval ? OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS) : null);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void setUpdateStatusIndexingSuccessful(String fileId, FileStatus status) {
|
||||
public void updateProcessingStatus(String fileId, ProcessingStatus processingStatus) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setStatus(status);
|
||||
file.setLastIndexed(OffsetDateTime.now());
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setProcessingStatus(processingStatus);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void setUpdateStatusIndexingSuccessful(String fileId) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setProcessingStatus(ProcessingStatus.PROCESSED);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastIndexed(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateLastOCRTime(String fileId, OffsetDateTime time) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastOCRTime(time);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
@ -147,20 +152,30 @@ public class FileStatusPersistenceService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateHasComments(String fileId, boolean hasComments) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setHasAnnotationComments(hasComments);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateLastManualRedaction(String fileId, OffsetDateTime date) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastManualRedaction(date);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
@ -168,10 +183,16 @@ public class FileStatusPersistenceService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void setUpdateLastManualRedactionAndHasSuggestions(String fileId, OffsetDateTime date, boolean hasSuggestions) {
|
||||
public void setUpdateLastManualRedactionAndHasSuggestions(String fileId, OffsetDateTime date,
|
||||
boolean hasSuggestions) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastManualRedaction(date);
|
||||
file.setHasSuggestions(hasSuggestions);
|
||||
}, () -> {
|
||||
@ -180,28 +201,41 @@ public class FileStatusPersistenceService {
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void setFileAttributes(String fileId, List<FileAttributeEntity> fileAttributes) {
|
||||
|
||||
@Transactional(value = Transactional.TxType.REQUIRES_NEW)
|
||||
public void setFileAttributes(String dossierId, String fileId, Map<String, String> fileAttributes) {
|
||||
|
||||
fileAttributesRepository.deleteByFileId(fileId);
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setLastFileAttributeChange(OffsetDateTime.now());
|
||||
file.setFileAttributes(fileAttributes);
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
var fileAttributeEntities = convertFileAttributes(dossierId, file, fileAttributes);
|
||||
file.setLastFileAttributeChange(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setFileAttributes(fileAttributeEntities);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void setExcludedPages(String fileId, Set<Integer> excludedPages) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setLastManualRedaction(OffsetDateTime.now());
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setLastManualRedaction(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setExcludedPages(excludedPages);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -213,71 +247,94 @@ public class FileStatusPersistenceService {
|
||||
|
||||
|
||||
public List<FileEntity> getStatusesForDossier(String dossierId) {
|
||||
|
||||
return fileRepository.findByDossierId(dossierId);
|
||||
}
|
||||
|
||||
|
||||
public List<FileEntity> getAllStatuses() {
|
||||
|
||||
return fileRepository.findAll();
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void softDelete(String fileId, OffsetDateTime softDeletedTime) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setStatus(FileStatus.DELETED);
|
||||
file.setProcessingStatus(ProcessingStatus.DELETED);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setDeleted(softDeletedTime);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void hardDelete(String fileId) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setStatus(FileStatus.DELETED);
|
||||
file.setDeleted(file.getDeleted() == null ? OffsetDateTime.now() : file.getDeleted());
|
||||
file.setHardDeletedTime(OffsetDateTime.now());
|
||||
file.setProcessingStatus(ProcessingStatus.DELETED);
|
||||
file.setDeleted(file.getDeleted() == null ? OffsetDateTime.now()
|
||||
.truncatedTo(ChronoUnit.MILLIS) : file.getDeleted());
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setDeleted(file.getDeleted() == null ? OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS) : file.getDeleted());
|
||||
file.setHardDeletedTime(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
|
||||
fileAttributesRepository.deleteByFileId(fileId);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void undelete(String fileId, FileStatus statusBefore) {
|
||||
public void undelete(String fileId) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (file.getHardDeletedTime() != null) {
|
||||
throw new BadRequestException("Cannot undelete a hard-dossier file!");
|
||||
throw new BadRequestException("Cannot undelete a hard-deleted dossier file!");
|
||||
}
|
||||
file.setStatus(statusBefore != null ? statusBefore : FileStatus.UNASSIGNED);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setProcessingStatus(ProcessingStatus.PROCESSED);
|
||||
file.setDeleted(null);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void setCurrentReviewer(String fileId, String currentReviewer, String lastReviewer) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setCurrentReviewer(currentReviewer);
|
||||
file.setLastReviewer(lastReviewer);
|
||||
file.setStatus(FileStatus.UNDER_REVIEW);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setWorkflowStatus(currentReviewer == null ? WorkflowStatus.UNASSIGNED : WorkflowStatus.UNDER_REVIEW);
|
||||
file.setWorkflowStatus(currentReviewer == null ? WorkflowStatus.UNASSIGNED : WorkflowStatus.UNDER_REVIEW);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void toggleExclusion(String fileId, boolean excluded) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setExcluded(excluded);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastProcessed(null);
|
||||
file.setLastReviewer(null);
|
||||
file.setCurrentReviewer(null);
|
||||
@ -297,15 +354,17 @@ public class FileStatusPersistenceService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void overwriteFile(String fileId, String uploader, String filename) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setFilename(filename);
|
||||
file.setUploader(uploader);
|
||||
file.setStatus(FileStatus.FULLREPROCESS);
|
||||
file.setLastUploaded(OffsetDateTime.now());
|
||||
file.setLastUpdated(OffsetDateTime.now());
|
||||
file.setProcessingStatus(ProcessingStatus.FULLREPROCESS);
|
||||
file.setWorkflowStatus(WorkflowStatus.UNASSIGNED);
|
||||
file.setLastUploaded(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastOCRTime(null);
|
||||
file.setExcluded(false);
|
||||
file.setLastProcessed(null);
|
||||
@ -321,12 +380,56 @@ public class FileStatusPersistenceService {
|
||||
file.setHasRedactions(false);
|
||||
file.setHasSuggestions(false);
|
||||
file.setHasUpdates(false);
|
||||
file.setDeleted(null);
|
||||
file.setHardDeletedTime(null);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private List<FileAttributeEntity> convertFileAttributes(String dossierId, FileEntity file,
|
||||
Map<String, String> fileAttributesMap) {
|
||||
|
||||
var dossier = dossierService.getAndValidateDossier(dossierId);
|
||||
List<FileAttributeConfigEntity> configuration = fileAttributeConfigPersistenceService.getFileAttributes(dossier.getDossierTemplateId());
|
||||
|
||||
return fileAttributesMap.entrySet().stream().map(entry -> {
|
||||
var fa = new FileAttributeEntity();
|
||||
fa.setFileAttributeId(new FileAttributeEntity.FileAttributeEntityId());
|
||||
fa.setFile(file);
|
||||
fa.setFileAttributeConfig(configuration.stream()
|
||||
.filter(c -> c.getId().equals(entry.getKey()))
|
||||
.findAny()
|
||||
.orElseThrow(() -> new BadRequestException("Invalid File Attribute Id")));
|
||||
fa.setValue(entry.getValue());
|
||||
return fa;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
private boolean isFileDeleted(FileEntity file) {
|
||||
|
||||
if (file == null || file.getDeleted() != null || file.getHardDeletedTime() != null || ProcessingStatus.DELETED.equals(file.getProcessingStatus())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean isFileDeleted(String fileId) {
|
||||
|
||||
AtomicBoolean isFileDeleted = new AtomicBoolean(false);
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
isFileDeleted.set(isFileDeleted(file));
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
|
||||
return isFileDeleted.get();
|
||||
}
|
||||
|
||||
|
||||
public boolean hasChangesSince(String dossierId, OffsetDateTime since) {
|
||||
return fileRepository.existsByDossierIdAndLastUpdatedIsAfter(dossierId, since);
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,10 +36,8 @@ public class ForceRedactionPersistenceService {
|
||||
|
||||
@Transactional
|
||||
public void updateStatus(String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
forceRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> {
|
||||
mre.setProcessedDate(OffsetDateTime.now());
|
||||
mre.setStatus(annotationStatus);
|
||||
});
|
||||
forceRedactionRepository.updateStatus(new AnnotationEntityId(annotationId, fileId), annotationStatus,
|
||||
OffsetDateTime.now());
|
||||
}
|
||||
|
||||
|
||||
@ -50,12 +48,12 @@ public class ForceRedactionPersistenceService {
|
||||
|
||||
@Transactional
|
||||
public void softDelete(String fileId, String annotationId, OffsetDateTime softDeleteTime) {
|
||||
forceRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> mre.setSoftDeletedTime(softDeleteTime));
|
||||
forceRedactionRepository.updateSoftDelete(new AnnotationEntityId(annotationId, fileId), softDeleteTime);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void undelete(String fileId, String annotationId) {
|
||||
forceRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> mre.setSoftDeletedTime(null));
|
||||
forceRedactionRepository.updateSoftDelete(new AnnotationEntityId(annotationId, fileId), null);
|
||||
}
|
||||
|
||||
public ManualForceRedactionEntity findForceRedaction(String fileId, String annotationId) {
|
||||
|
||||
@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@ -35,11 +35,8 @@ public class ImageRecategorizationPersistenceService {
|
||||
@Transactional
|
||||
public void updateStatus(String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
|
||||
imageRecategorizationRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> {
|
||||
mre.setProcessedDate(OffsetDateTime.now());
|
||||
mre.setStatus(annotationStatus);
|
||||
});
|
||||
|
||||
imageRecategorizationRepository.updateStatus(new AnnotationEntityId(annotationId, fileId), annotationStatus,
|
||||
OffsetDateTime.now());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ -50,12 +47,12 @@ public class ImageRecategorizationPersistenceService {
|
||||
@Transactional
|
||||
public void softDelete(String fileId, String annotationId, OffsetDateTime softDeleteTime) {
|
||||
|
||||
imageRecategorizationRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> mre.setSoftDeletedTime(softDeleteTime));
|
||||
imageRecategorizationRepository.updateSoftDelete(new AnnotationEntityId(annotationId, fileId), softDeleteTime);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void undelete(String fileId, String annotationId) {
|
||||
imageRecategorizationRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> mre.setSoftDeletedTime(null));
|
||||
imageRecategorizationRepository.updateSoftDelete(new AnnotationEntityId(annotationId, fileId), null);
|
||||
}
|
||||
|
||||
public ManualImageRecategorizationEntity findRecategorization(String fileId, String annotationId) {
|
||||
@ -67,9 +64,9 @@ public class ImageRecategorizationPersistenceService {
|
||||
}
|
||||
|
||||
|
||||
public Set<ManualImageRecategorizationEntity> findRecategorizations(String fileId, boolean includeDeletions) {
|
||||
public List<ManualImageRecategorizationEntity> findRecategorizations(String fileId, boolean includeDeletions) {
|
||||
|
||||
return imageRecategorizationRepository.findByIdFileId(fileId).stream().filter(mre -> includeDeletions || mre.getSoftDeletedTime() == null).collect(Collectors.toSet());
|
||||
return imageRecategorizationRepository.findByIdFileId(fileId).stream().filter(mre -> includeDeletions || mre.getSoftDeletedTime() == null).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -41,24 +41,20 @@ public class LegalBasisChangePersistenceService {
|
||||
@Transactional
|
||||
public void softDelete(String fileId, String annotationId, OffsetDateTime softDeleteTime) {
|
||||
|
||||
legalBasisChangeRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> mre.setSoftDeletedTime(softDeleteTime));
|
||||
legalBasisChangeRepository.updateSoftDelete(new AnnotationEntityId(annotationId, fileId), softDeleteTime);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void undelete(String fileId, String annotationId) {
|
||||
legalBasisChangeRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> mre.setSoftDeletedTime(null));
|
||||
legalBasisChangeRepository.updateSoftDelete(new AnnotationEntityId(annotationId, fileId), null);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateStatus(String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
|
||||
legalBasisChangeRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> {
|
||||
mre.setProcessedDate(OffsetDateTime.now());
|
||||
mre.setStatus(annotationStatus);
|
||||
});
|
||||
|
||||
|
||||
legalBasisChangeRepository.updateStatus(new AnnotationEntityId(annotationId, fileId), annotationStatus,
|
||||
OffsetDateTime.now());
|
||||
}
|
||||
|
||||
public ManualLegalBasisChangeEntity findLegalBasisChange(String fileId, String annotationId) {
|
||||
|
||||
@ -0,0 +1,94 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service.persistence;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.LegalBasisEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.LegalBasisMappingEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.LegalBasisMappingRepository;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.legalbasis.LegalBasis;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
|
||||
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LegalBasisMappingPersistenceService {
|
||||
|
||||
|
||||
private final LegalBasisMappingRepository legalBasisMappingRepository;
|
||||
|
||||
|
||||
@Transactional
|
||||
public void deleteLegalBasis(String dossierTemplateId, List<String> legalBasisNames) {
|
||||
var mapping = getLegalBasisMappingOrCreate(dossierTemplateId);
|
||||
var filteredLegalBasis = mapping.getLegalBasis().stream().filter(l -> !legalBasisNames.contains(l.getName())).collect(Collectors.toList());
|
||||
|
||||
mapping.setLegalBasis(filteredLegalBasis);
|
||||
mapping.setVersion(mapping.getVersion() + 1);
|
||||
legalBasisMappingRepository.save(mapping);
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void addOrUpdateLegalBasis(String dossierTemplateId, LegalBasis legalBasis) {
|
||||
var mapping = getLegalBasisMappingOrCreate(dossierTemplateId);
|
||||
|
||||
mapping.getLegalBasis().stream().filter(l -> l.getName().equals(legalBasis.getName())).findAny().ifPresentOrElse(existingBasis -> {
|
||||
existingBasis.setReason(legalBasis.getReason());
|
||||
existingBasis.setDescription(legalBasis.getDescription());
|
||||
}, () -> mapping.getLegalBasis().add(LegalBasisEntity.builder()
|
||||
.name(legalBasis.getName())
|
||||
.description(legalBasis.getDescription())
|
||||
.reason(legalBasis.getReason()).build()));
|
||||
|
||||
|
||||
mapping.setVersion(mapping.getVersion() + 1);
|
||||
legalBasisMappingRepository.save(mapping);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void setLegalBasisMapping(String dossierTemplateId, List<LegalBasis> legalBasisMapping) {
|
||||
|
||||
legalBasisMappingRepository.findById(dossierTemplateId).ifPresentOrElse((lbm) -> {
|
||||
lbm.setVersion(lbm.getVersion() + 1);
|
||||
lbm.setLegalBasis(convert(legalBasisMapping, LegalBasisEntity.class));
|
||||
legalBasisMappingRepository.save(lbm);
|
||||
}, () -> {
|
||||
var lbm = new LegalBasisMappingEntity();
|
||||
lbm.setDossierTemplateId(dossierTemplateId);
|
||||
lbm.setLegalBasis(convert(legalBasisMapping, LegalBasisEntity.class));
|
||||
lbm.setVersion(1);
|
||||
legalBasisMappingRepository.save(lbm);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public List<LegalBasisEntity> getLegalBasisMapping(String dossierTemplateId) {
|
||||
return getLegalBasisMappingOrCreate(dossierTemplateId).getLegalBasis();
|
||||
}
|
||||
|
||||
private LegalBasisMappingEntity getLegalBasisMappingOrCreate(String dossierTemplateId) {
|
||||
return legalBasisMappingRepository.findById(dossierTemplateId).orElseGet(() -> {
|
||||
// create on get if not present
|
||||
var lbm = new LegalBasisMappingEntity();
|
||||
lbm.setDossierTemplateId(dossierTemplateId);
|
||||
lbm.setLegalBasis(new ArrayList<>());
|
||||
lbm.setVersion(1);
|
||||
return legalBasisMappingRepository.save(lbm);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public long getVersion(String dossierTemplateId) {
|
||||
return legalBasisMappingRepository.findById(dossierTemplateId).map(LegalBasisMappingEntity::getVersion).orElse(0L);
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@ -20,6 +21,9 @@ public class NotificationPersistenceService {
|
||||
|
||||
private final NotificationRepository notificationRepository;
|
||||
|
||||
public boolean hasNewNotificationsSince(String userId, OffsetDateTime since) {
|
||||
return notificationRepository.existsByUserIdAndCreationDateIsAfter(userId, since.truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public void insertNotification(AddNotificationRequest addNotificationRequest) {
|
||||
@ -43,16 +47,18 @@ public class NotificationPersistenceService {
|
||||
|
||||
@Transactional
|
||||
public void setReadDate(String userId, long notificationId, OffsetDateTime readDate) {
|
||||
notificationRepository.findByIdAndUserId(notificationId, userId).ifPresentOrElse(notification -> notification.setReadDate(readDate), () -> {
|
||||
int countUpdate = notificationRepository.setReadDate(userId, notificationId, readDate);
|
||||
if (countUpdate == 0) {
|
||||
throw new NotFoundException("Notification not found");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void softDelete(String userId, long notificationId) {
|
||||
notificationRepository.findByIdAndUserId(notificationId, userId).ifPresentOrElse(notification -> notification.setSoftDeleted(OffsetDateTime.now()), () -> {
|
||||
int countUpdate = notificationRepository.softDelete(userId, notificationId, OffsetDateTime.now());
|
||||
if (countUpdate == 0) {
|
||||
throw new NotFoundException("Notification not found");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service.persistence;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.notification.NotificationPreferencesEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.NotificationPreferencesRepository;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.notification.NotificationPreferences;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class NotificationPreferencesPersistenceService {
|
||||
|
||||
private final NotificationPreferencesRepository notificationPreferencesRepository;
|
||||
|
||||
@Transactional
|
||||
public void setNotificationPreference(String userId, NotificationPreferences notification) {
|
||||
notificationPreferencesRepository.findById(userId)
|
||||
.ifPresentOrElse(n -> {
|
||||
BeanUtils.copyProperties(notification, n);
|
||||
}, () -> {
|
||||
NotificationPreferencesEntity notificationPreferencesEntity = new NotificationPreferencesEntity();
|
||||
BeanUtils.copyProperties(notification, notificationPreferencesEntity);
|
||||
notificationPreferencesRepository.save(notificationPreferencesEntity);
|
||||
});
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteNotificationPreferences(String userId) {
|
||||
notificationPreferencesRepository.deleteById(userId);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public NotificationPreferencesEntity getNotificationPreferences(String userId) {
|
||||
return notificationPreferencesRepository.findById(userId).orElseThrow(() -> {
|
||||
throw new NotFoundException("Notification preferences not found for userId: " + userId);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -55,33 +55,24 @@ public class RemoveRedactionPersistenceService {
|
||||
|
||||
@Transactional
|
||||
public void softDelete(String fileId, String annotationId, OffsetDateTime softDeleteTime) {
|
||||
removeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> mre.setSoftDeletedTime(softDeleteTime));
|
||||
|
||||
removeRedactionRepository.updateSoftDelete(new AnnotationEntityId(annotationId, fileId), softDeleteTime);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void undelete(String fileId, String annotationId) {
|
||||
removeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> mre.setSoftDeletedTime(null));
|
||||
removeRedactionRepository.updateSoftDelete(new AnnotationEntityId(annotationId, fileId), null);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateStatus(String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
|
||||
removeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> {
|
||||
mre.setProcessedDate(OffsetDateTime.now());
|
||||
mre.setStatus(annotationStatus);
|
||||
});
|
||||
|
||||
removeRedactionRepository.updateStatus(new AnnotationEntityId(annotationId, fileId), annotationStatus, OffsetDateTime.now());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateStatus(String fileId, String annotationId, AnnotationStatus annotationStatus, boolean isAddOrRemoveFromDictionary) {
|
||||
|
||||
removeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> {
|
||||
mre.setProcessedDate(OffsetDateTime.now());
|
||||
mre.setStatus(annotationStatus);
|
||||
mre.setRemoveFromDictionary(isAddOrRemoveFromDictionary);
|
||||
});
|
||||
|
||||
removeRedactionRepository.updateStatusAndRemoveFromDictionary(new AnnotationEntityId(annotationId, fileId),
|
||||
annotationStatus, OffsetDateTime.now(), isAddOrRemoveFromDictionary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,94 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service.persistence;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualResizeRedactionEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.RectangleEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.ResizeRedactionRepository;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ResizeRedactionRequest;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ResizeRedactionPersistenceService {
|
||||
|
||||
private final ResizeRedactionRepository resizeRedactionRepository;
|
||||
|
||||
|
||||
@Transactional
|
||||
public void insert(String fileId, ResizeRedactionRequest resizeRedactionRequest) {
|
||||
|
||||
ManualResizeRedactionEntity manualResizeRedaction = new ManualResizeRedactionEntity();
|
||||
manualResizeRedaction.setId(new AnnotationEntityId(resizeRedactionRequest.getAnnotationId(), fileId));
|
||||
BeanUtils.copyProperties(resizeRedactionRequest, manualResizeRedaction);
|
||||
manualResizeRedaction.setPositions(convert(resizeRedactionRequest.getPositions(), RectangleEntity.class));
|
||||
manualResizeRedaction.setRequestDate(OffsetDateTime.now());
|
||||
|
||||
resizeRedactionRepository.save(manualResizeRedaction);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateStatus(String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
|
||||
resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> {
|
||||
mre.setProcessedDate(OffsetDateTime.now());
|
||||
mre.setStatus(annotationStatus);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void hardDelete(String fileId, String annotationId) {
|
||||
|
||||
resizeRedactionRepository.deleteById(new AnnotationEntityId(annotationId, fileId));
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void softDelete(String fileId, String annotationId, OffsetDateTime softDeleteTime) {
|
||||
|
||||
resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||
.ifPresent(mre -> mre.setSoftDeletedTime(softDeleteTime));
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void undelete(String fileId, String annotationId) {
|
||||
|
||||
resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||
.ifPresent(mre -> mre.setSoftDeletedTime(null));
|
||||
}
|
||||
|
||||
|
||||
public ManualResizeRedactionEntity findResizeRedaction(String fileId, String annotationId) {
|
||||
|
||||
return resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||
.filter(mre -> mre.getSoftDeletedTime() == null)
|
||||
.orElseThrow(() -> new NotFoundException("Unknown file/annotation combination: " + fileId + "/" + annotationId));
|
||||
}
|
||||
|
||||
|
||||
public Set<ManualResizeRedactionEntity> findResizeRedactions(String fileId, boolean includeDeletions) {
|
||||
|
||||
return resizeRedactionRepository.findByIdFileId(fileId)
|
||||
.stream()
|
||||
.filter(mre -> includeDeletions || mre.getSoftDeletedTime() == null)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,7 +1,6 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service.persistence;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.RuleSetEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.RuleSetRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -13,11 +12,26 @@ import javax.transaction.Transactional;
|
||||
@SuppressWarnings("PMD.TooManyStaticImports")
|
||||
public class RulesPersistenceService {
|
||||
|
||||
private static final String RULES_NOT_FOUND = "Could not find rules in database.";
|
||||
private final static String DEFAULT_RULES = "" +
|
||||
"package drools\n" +
|
||||
"\n" +
|
||||
"import com.iqser.red.service.redaction.v1.server.redaction.model.Section\n" +
|
||||
"\n" +
|
||||
"global Section section\n" +
|
||||
"\n" +
|
||||
"// --------------------------------------- Your rules below this line--------------------------------------------------";
|
||||
|
||||
private final RuleSetRepository ruleSetRepository;
|
||||
|
||||
public RuleSetEntity getRules(String dossierTemplateId) {
|
||||
return ruleSetRepository.findById(dossierTemplateId).orElseThrow(() -> new NotFoundException(RULES_NOT_FOUND));
|
||||
return ruleSetRepository.findById(dossierTemplateId).orElseGet(() -> {
|
||||
RuleSetEntity ruleSet = new RuleSetEntity();
|
||||
ruleSet.setDossierTemplateId(dossierTemplateId);
|
||||
ruleSet.setValue(DEFAULT_RULES);
|
||||
ruleSet.setVersion(1);
|
||||
|
||||
return ruleSetRepository.save(ruleSet);
|
||||
});
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
@ -49,4 +49,8 @@ public class ViewedPagesPersistenceService {
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void resetViewedPages(String fileId, String currentReviewer, List<Integer> viewedPagesToReset) {
|
||||
viewedPagesRepository.deleteSeenPages(fileId, currentReviewer, viewedPagesToReset);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,14 +2,34 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.audit.AuditEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.audit.CategoryModel;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface AuditRepository extends JpaRepository<AuditEntity, Long> {
|
||||
public interface AuditRepository extends JpaRepository<AuditEntity, Long>, JpaSpecificationExecutor<AuditEntity> {
|
||||
|
||||
static Specification<AuditEntity> categoryMatches(String category) {
|
||||
return (audit, cq, cb) -> cb.equal(audit.get("category"), category);
|
||||
}
|
||||
|
||||
static Specification<AuditEntity> userMatches(String user) {
|
||||
return (audit, cq, cb) -> cb.equal(audit.get("userId"), user);
|
||||
}
|
||||
|
||||
static Specification<AuditEntity> objectIdMatches(String objectId) {
|
||||
return (audit, cq, cb) -> cb.equal(audit.get("objectId"), objectId);
|
||||
}
|
||||
|
||||
static Specification<AuditEntity> dateBetween(OffsetDateTime start, OffsetDateTime end) {
|
||||
return (audit, cq, cb) -> cb.between(audit.get("recordDate"), start, end);
|
||||
}
|
||||
|
||||
@Query("SELECT new com.iqser.red.service.persistence.service.v1.api.model.audit.CategoryModel(a.category, count(a)) FROM AuditEntity a GROUP BY a.category")
|
||||
List<CategoryModel> findCategories();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,10 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.CommentEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface CommentRepository extends JpaRepository<CommentEntity, Long> {
|
||||
@ -12,4 +15,8 @@ public interface CommentRepository extends JpaRepository<CommentEntity, Long> {
|
||||
List<CommentEntity> findByFileId(String fileId);
|
||||
|
||||
boolean existsByFileIdAndSoftDeletedTimeIsNull(String fileId);
|
||||
|
||||
@Modifying
|
||||
@Query("update CommentEntity c set c.softDeletedTime = :softDeleteTime where c.id = :id")
|
||||
int updateSoftDelete(long id, OffsetDateTime softDeleteTime);
|
||||
}
|
||||
|
||||
@ -2,6 +2,17 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.DigitalSignatureEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
||||
public interface DigitalSignatureRepository extends JpaRepository<DigitalSignatureEntity, String> {
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query("update DigitalSignatureEntity e set e.reason = :reason, e.location = :location, e.contactInfo = :contactInfo, e.certificateName= :certificateName " +
|
||||
"where e.id = :id")
|
||||
int updateDigitalSignature(String id, String reason, String location, String contactInfo, String certificateName);
|
||||
|
||||
}
|
||||
|
||||
@ -19,4 +19,8 @@ public interface DossierAttributeRepository extends JpaRepository<DossierAttribu
|
||||
@Modifying
|
||||
@Query("DELETE FROM DossierAttributeEntity e WHERE e.dossierAttributeConfig.id = :id")
|
||||
void deleteByDossierAttributeConfigId(String id);
|
||||
|
||||
@Modifying
|
||||
@Query("update DossierAttributeEntity dae set dae.value = :dossierAttributeValue where dae.id = :dossierAttributeId")
|
||||
void updateDossierAttribute(DossierAttributeEntity.DossierAttributeEntityId dossierAttributeId, String dossierAttributeValue);
|
||||
}
|
||||
|
||||
@ -1,7 +1,34 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.DossierEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.DossierStatus;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
public interface DossierRepository extends JpaRepository<DossierEntity, String> {
|
||||
|
||||
@Modifying
|
||||
@Query("update DossierEntity d set d.status = :dossierStatus, d.hardDeletedTime = :hardDeletedTime, d.lastUpdated = :lastUpdated," +
|
||||
" d.softDeletedTime = " +
|
||||
"case " +
|
||||
"when d.softDeletedTime is null then :hardDeletedTime " +
|
||||
"when d.softDeletedTime is not null then d.softDeletedTime " +
|
||||
"end " +
|
||||
"where d.id = :dossierId")
|
||||
void hardDelete(String dossierId, DossierStatus dossierStatus, OffsetDateTime hardDeletedTime, OffsetDateTime lastUpdated);
|
||||
|
||||
@Modifying
|
||||
@Query("update DossierEntity d set d.status = :dossierStatus, d.softDeletedTime = null, d.lastUpdated = :lastUpdated where d.id = :dossierId" +
|
||||
" and d.hardDeletedTime is null")
|
||||
int undelete(String dossierId, DossierStatus dossierStatus, OffsetDateTime lastUpdated);
|
||||
|
||||
@Modifying
|
||||
@Query("update DossierEntity d set d.status = :dossierStatus, d.softDeletedTime = :softDeletedTime, d.lastUpdated = :lastUpdated where d.id = :dossierId")
|
||||
void markDossierAsDeleted(String dossierId, DossierStatus dossierStatus, OffsetDateTime softDeletedTime, OffsetDateTime lastUpdated);
|
||||
|
||||
boolean existsByLastUpdatedIsAfter(OffsetDateTime since);
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,26 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.download.DownloadStatusEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.download.DownloadStatusValue;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface DownloadStatusRepository extends JpaRepository<DownloadStatusEntity, String> {
|
||||
List<DownloadStatusEntity> findAllByUserId(String userId);
|
||||
|
||||
@Modifying
|
||||
@Query("update DownloadStatusEntity ds set ds.status = :status where ds.storageId = :storageId")
|
||||
void updateStatus(String storageId, DownloadStatusValue status);
|
||||
|
||||
@Modifying
|
||||
@Query("update DownloadStatusEntity ds set ds.status = :status, ds.fileSize = :fileSize where ds.storageId = :storageId")
|
||||
void updateStatus(String storageId, DownloadStatusValue status, long fileSize);
|
||||
|
||||
@Modifying
|
||||
@Query("update DownloadStatusEntity ds set ds.lastDownload = :lastDownload where ds.storageId = :storageId")
|
||||
void updateLastDownload(String storageId, OffsetDateTime lastDownload);
|
||||
}
|
||||
|
||||
@ -9,6 +9,8 @@ import java.util.List;
|
||||
|
||||
public interface EntryRepository extends JpaRepository<DictionaryEntryEntity, Long> {
|
||||
|
||||
@Modifying
|
||||
@Query("update DictionaryEntryEntity e set e.deleted = true , e.version = :version where e.type.id =:typeId and e.value in :values")
|
||||
void deleteAllByTypeIdAndVersionAndValueIn(String typeId, long version, List<String> values);
|
||||
|
||||
@Modifying
|
||||
|
||||
@ -11,4 +11,7 @@ public interface FileAttributesRepository extends JpaRepository<FileAttributeEnt
|
||||
@Query("DELETE FROM FileAttributeEntity f where f.fileAttributeId.fileAttributeConfigId = :fileAttributeConfigId")
|
||||
void deleteByFileAttributeConfigId(String fileAttributeConfigId);
|
||||
|
||||
@Modifying
|
||||
@Query("DELETE FROM FileAttributeEntity f where f.fileAttributeId.fileId = :fileId")
|
||||
void deleteByFileId(String fileId);
|
||||
}
|
||||
|
||||
@ -3,9 +3,34 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
||||
public interface FileRepository extends JpaRepository<FileEntity, String> {
|
||||
|
||||
boolean existsByDossierIdAndLastUpdatedIsAfter(String dossierId, OffsetDateTime since);
|
||||
|
||||
List<FileEntity> findByDossierId(String dossierId);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity e set e.hasRedactions = :hasRedactions ," +
|
||||
" e.hasHints = :hasHints, e.hasSuggestions = :hasSuggestions," +
|
||||
" e.hasImages = :hasImages, e.hasUpdates = :hasUpdates, e.hasAnnotationComments = :hasComments, " +
|
||||
" e.lastUpdated = :lastUpdated " +
|
||||
" where e.id =:fileId")
|
||||
void updateFlags(String fileId,
|
||||
OffsetDateTime lastUpdated,
|
||||
boolean hasRedactions,
|
||||
boolean hasHints,
|
||||
boolean hasImages,
|
||||
boolean hasSuggestions,
|
||||
boolean hasComments,
|
||||
boolean hasUpdates);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,11 +2,26 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualForceRedactionEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface ForceRedactionRepository extends JpaRepository<ManualForceRedactionEntity, AnnotationEntityId> {
|
||||
|
||||
List<ManualForceRedactionEntity> findByIdFileId(String fileId);
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualForceRedactionEntity mfr set mfr.status = :annotationStatus, mfr.processedDate = :processedDate " +
|
||||
"where mfr.id = :annotationEntityId")
|
||||
void updateStatus(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus, OffsetDateTime processedDate);
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualForceRedactionEntity mfr set mfr.softDeletedTime = :softDeletedTime " +
|
||||
"where mfr.id = :annotationEntityId")
|
||||
void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime);
|
||||
|
||||
}
|
||||
|
||||
@ -2,10 +2,25 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualImageRecategorizationEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface ImageRecategorizationRepository extends JpaRepository<ManualImageRecategorizationEntity, AnnotationEntityId> {
|
||||
List<ManualImageRecategorizationEntity> findByIdFileId(String fileId);
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualImageRecategorizationEntity mir set mir.status = :annotationStatus, mir.processedDate = :processedDate " +
|
||||
"where mir.id = :annotationEntityId")
|
||||
void updateStatus(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus, OffsetDateTime processedDate);
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualImageRecategorizationEntity mir set mir.softDeletedTime = :softDeletedTime " +
|
||||
"where mir.id = :annotationEntityId")
|
||||
void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime);
|
||||
|
||||
}
|
||||
|
||||
@ -2,11 +2,25 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualLegalBasisChangeEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface LegalBasisChangeRepository extends JpaRepository<ManualLegalBasisChangeEntity, AnnotationEntityId> {
|
||||
|
||||
List<ManualLegalBasisChangeEntity> findByIdFileId(String fileId);
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualLegalBasisChangeEntity mlbc set mlbc.status = :annotationStatus, mlbc.processedDate = :processedDate " +
|
||||
"where mlbc.id = :annotationEntityId")
|
||||
void updateStatus(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus, OffsetDateTime processedDate);
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualLegalBasisChangeEntity mlbc set mlbc.softDeletedTime = :softDeletedTime " +
|
||||
"where mlbc.id = :annotationEntityId")
|
||||
void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime);
|
||||
}
|
||||
|
||||
@ -2,11 +2,29 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualRedactionEntryEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface ManualRedactionRepository extends JpaRepository<ManualRedactionEntryEntity, AnnotationEntityId> {
|
||||
|
||||
List<ManualRedactionEntryEntity> findByIdFileId(String fileId);
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualRedactionEntryEntity m set m.softDeletedTime = :softDeleteTime where m.id = :id")
|
||||
void updateSoftDelete(AnnotationEntityId id, OffsetDateTime softDeleteTime);
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualRedactionEntryEntity m set m.processedDate = :processedDate, m.status = :annotationStatus" +
|
||||
" where m.id = :id")
|
||||
void updateStatus(AnnotationEntityId id, OffsetDateTime processedDate, AnnotationStatus annotationStatus);
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualRedactionEntryEntity m set m.processedDate = :processedDate, m.status = :annotationStatus," +
|
||||
" m.addToDictionary = :isAddOrRemoveFromDictionary where m.id = :id")
|
||||
void updateStatus(AnnotationEntityId id, OffsetDateTime processedDate, AnnotationStatus annotationStatus, boolean isAddOrRemoveFromDictionary);
|
||||
}
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.notification.NotificationPreferencesEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface NotificationPreferencesRepository extends JpaRepository<NotificationPreferencesEntity, String> {
|
||||
}
|
||||
@ -2,13 +2,17 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.notification.NotificationEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface NotificationRepository extends JpaRepository<NotificationEntity, Long> {
|
||||
|
||||
boolean existsByUserIdAndCreationDateIsAfter(String userId, OffsetDateTime since);
|
||||
|
||||
List<NotificationEntity> findByUserIdOrderByCreationDateDesc(String userId);
|
||||
|
||||
@Query("Select n from NotificationEntity n where n.softDeleted is null and n.userId = :userId order by n.creationDate desc")
|
||||
@ -18,4 +22,16 @@ public interface NotificationRepository extends JpaRepository<NotificationEntity
|
||||
List<NotificationEntity> findNotSeenForUser(String userId);
|
||||
|
||||
Optional<NotificationEntity> findByIdAndUserId(long notificationId, String userId);
|
||||
|
||||
@Modifying
|
||||
@Query("update NotificationEntity n set n.seenDate = :seenDate where n.id = :notificationId and n.userId = :userId")
|
||||
int setSeenDate(String userId, long notificationId, OffsetDateTime seenDate);
|
||||
|
||||
@Modifying
|
||||
@Query("update NotificationEntity n set n.readDate = :readDate where n.id = :notificationId and n.userId = :userId")
|
||||
int setReadDate(String userId, long notificationId, OffsetDateTime readDate);
|
||||
|
||||
@Modifying
|
||||
@Query("update NotificationEntity n set n.softDeleted = :softDeleted where n.id = :notificationId and n.userId = :userId")
|
||||
int softDelete(String userId, long notificationId, OffsetDateTime softDeleted);
|
||||
}
|
||||
|
||||
@ -2,11 +2,32 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.IdRemovalEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface RemoveRedactionRepository extends JpaRepository<IdRemovalEntity, AnnotationEntityId> {
|
||||
|
||||
List<IdRemovalEntity> findByIdFileId(String fileId);
|
||||
|
||||
@Modifying
|
||||
@Query("update IdRemovalEntity idr set idr.softDeletedTime = :softDeletedTime " +
|
||||
"where idr.id = :annotationEntityId")
|
||||
void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime);
|
||||
|
||||
@Modifying
|
||||
@Query("update IdRemovalEntity idr set idr.status = :annotationStatus, idr.processedDate = :processedDate " +
|
||||
"where idr.id = :annotationEntityId")
|
||||
void updateStatus(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus, OffsetDateTime processedDate);
|
||||
|
||||
@Modifying
|
||||
@Query("update IdRemovalEntity idr set idr.status = :annotationStatus, idr.processedDate = :processedDate, " +
|
||||
"idr.removeFromDictionary = :removeFromDictionary where idr.id = :annotationEntityId")
|
||||
void updateStatusAndRemoveFromDictionary(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus, OffsetDateTime processedDate,
|
||||
boolean removeFromDictionary);
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user