Skip to content

Commit

Permalink
Johanna/6723 add destination disease columns upload table (#6857)
Browse files Browse the repository at this point in the history
* Added two new columns to upload table

* Added cascade to rollback

* Removed not null constraint so the schema changes are backwards compatible

* added manual rollback for the disease_id column

* Implemented insert of new information in table and unit testing partially updated

* Fixed some more test cases

* Updated models and fixed some test suites

* save to DB logic moved back to main thread

* Added mocks for repo_save

* Fixed sonar cloud smells

* Fixed more code smells

* addresses feedback
  • Loading branch information
johanna-skylight authored Nov 3, 2023
1 parent a685331 commit 5eb9973
Show file tree
Hide file tree
Showing 18 changed files with 448 additions and 193 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import gov.cdc.usds.simplereport.service.TestResultUploadService;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
Expand Down Expand Up @@ -76,7 +77,7 @@ public TestResultUpload handleConditionAgnosticResultsUpload(
}

@PostMapping(RESULT_UPLOAD)
public TestResultUpload handleResultsUpload(@RequestParam("file") MultipartFile file) {
public List<TestResultUpload> handleResultsUpload(@RequestParam("file") MultipartFile file) {
assertCsvFileType(file);

try (InputStream resultsUpload = file.getInputStream()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package gov.cdc.usds.simplereport.db.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import gov.cdc.usds.simplereport.db.model.auxiliary.Pipeline;
import gov.cdc.usds.simplereport.db.model.auxiliary.UploadStatus;
import gov.cdc.usds.simplereport.service.model.reportstream.FeedbackMessage;
import java.util.List;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
Expand All @@ -11,16 +13,23 @@
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.annotations.Type;

@Getter
@Setter
@Entity
@Slf4j
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Setter
@Getter
@Table(name = "upload")
public class TestResultUpload extends AuditedEntity {

Expand All @@ -47,24 +56,13 @@ public class TestResultUpload extends AuditedEntity {
@Type(type = "jsonb")
private FeedbackMessage[] errors;

protected TestResultUpload() {}
@Column()
@Type(type = "pg_enum")
@Enumerated(EnumType.STRING)
private Pipeline destination;

public TestResultUpload(
UUID reportId,
UUID submissionId,
UploadStatus status,
int recordsCount,
Organization organization,
FeedbackMessage[] warnings,
FeedbackMessage[] errors) {
this.reportId = reportId;
this.submissionId = submissionId;
this.status = status;
this.recordsCount = recordsCount;
this.organization = organization;
this.warnings = warnings;
this.errors = errors;
}
@OneToMany(mappedBy = "upload")
List<UploadDiseaseDetails> uploadDiseaseDetails;

public TestResultUpload(UploadStatus status) {
this.status = status;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package gov.cdc.usds.simplereport.db.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Entity
@Builder
public class UploadDiseaseDetails extends AuditedEntity {

@ManyToOne
@JoinColumn(name = "supported_disease_id", nullable = false)
private SupportedDisease disease;

@ManyToOne
@JoinColumn(name = "upload_id", nullable = false)
private TestResultUpload upload;

@Column(nullable = false)
private int recordsCount;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package gov.cdc.usds.simplereport.db.model.auxiliary;

import gov.cdc.usds.simplereport.db.model.Organization;
import gov.cdc.usds.simplereport.service.model.reportstream.UploadResponse;
import java.util.HashMap;
import java.util.UUID;

public record CovidSubmissionSummary(
UUID submissionId,
Organization org,
UploadResponse submissionResponse,
Exception processingException,
HashMap<String, Integer> reportedDiseases) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package gov.cdc.usds.simplereport.db.model.auxiliary;

import java.util.HashMap;
import java.util.List;

public record FHIRBundleRecord(List<String> serializedBundle, HashMap<String, Integer> metadata) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package gov.cdc.usds.simplereport.db.model.auxiliary;

public enum Pipeline {
COVID,
UNIVERSAL;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package gov.cdc.usds.simplereport.db.model.auxiliary;

import gov.cdc.usds.simplereport.db.model.Organization;
import gov.cdc.usds.simplereport.service.model.reportstream.UploadResponse;
import java.util.HashMap;
import java.util.UUID;

public record UniversalSubmissionSummary(
UUID submissionId,
Organization org,
UploadResponse submissionResponse,
HashMap<String, Integer> reportedDiseases) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package gov.cdc.usds.simplereport.db.repository;

import gov.cdc.usds.simplereport.db.model.UploadDiseaseDetails;

public interface UploadDiseaseDetailsRepository
extends AuditedEntityRepository<UploadDiseaseDetails> {}
Loading

0 comments on commit 5eb9973

Please sign in to comment.