-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GLT-4053] extracted interfaces from Case and related classes (#43)
- Loading branch information
Showing
9 changed files
with
652 additions
and
503 deletions.
There are no files selected for viewing
302 changes: 25 additions & 277 deletions
302
cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Case.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,309 +1,57 @@ | ||
package ca.on.oicr.gsi.cardea.data; | ||
|
||
import static java.util.Collections.emptyList; | ||
import static java.util.Collections.unmodifiableList; | ||
import static java.util.Collections.unmodifiableSet; | ||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
import java.util.stream.Stream; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; | ||
|
||
/** | ||
* Immutable case | ||
*/ | ||
@JsonDeserialize(builder = Case.Builder.class) | ||
public class Case { | ||
|
||
private final long assayId; | ||
private final String assayName; | ||
private final String assayDescription; | ||
private final Donor donor; | ||
private final String id; | ||
private final LocalDate latestActivityDate; | ||
private final Set<Project> projects; | ||
private final List<Sample> receipts; | ||
private final Requisition requisition; | ||
private final LocalDate startDate; | ||
private final List<Test> tests; | ||
private final List<AnalysisQcGroup> qcGroups; | ||
private final List<CaseDeliverable> deliverables; | ||
private final String timepoint; | ||
private final String tissueOrigin; | ||
private final String tissueType; | ||
private final int receiptDaysSpent; | ||
private final int analysisReviewDaysSpent; | ||
private final int releaseApprovalDaysSpent; | ||
private final int releaseDaysSpent; | ||
private final int caseDaysSpent; | ||
private final int pauseDays; | ||
|
||
private Case(Builder builder) { | ||
this.id = requireNonNull(builder.id); | ||
this.donor = requireNonNull(builder.donor); | ||
this.projects = unmodifiableSet(builder.projects); | ||
this.assayId = builder.assayId; | ||
// fields needed for Dimsum sorting/filtering | ||
this.assayName = builder.assayName; | ||
this.assayDescription = builder.assayDescription; | ||
|
||
this.tissueOrigin = requireNonNull(builder.tissueOrigin); | ||
this.tissueType = requireNonNull(builder.tissueType); | ||
this.timepoint = builder.timepoint; | ||
this.receipts = unmodifiableList(builder.receipts); | ||
this.tests = unmodifiableList(builder.tests); | ||
this.qcGroups = builder.qcGroups == null ? emptyList() : unmodifiableList(builder.qcGroups); | ||
this.deliverables = | ||
builder.deliverables == null ? emptyList() : unmodifiableList(builder.deliverables); | ||
this.requisition = requireNonNull(builder.requisition); | ||
this.startDate = requireNonNull(builder.startDate); | ||
|
||
this.latestActivityDate = Stream | ||
.concat(Stream.of(receipts.stream().map(Sample::getLatestActivityDate), | ||
tests.stream().map(Test::getLatestActivityDate)) | ||
.flatMap(Function.identity()), | ||
deliverables == null ? Stream.empty() | ||
: deliverables.stream().map(CaseDeliverable::getLatestActivityDate)) | ||
.filter(Objects::nonNull).max(LocalDate::compareTo) | ||
.orElse(null); | ||
this.receiptDaysSpent = builder.receiptDaysSpent; | ||
this.analysisReviewDaysSpent = builder.analysisReviewDaysSpent; | ||
this.releaseApprovalDaysSpent = builder.releaseApprovalDaysSpent; | ||
this.releaseDaysSpent = builder.releaseDaysSpent; | ||
this.caseDaysSpent = builder.caseDaysSpent; | ||
this.pauseDays = builder.pauseDays; | ||
} | ||
|
||
public long getAssayId() { | ||
return assayId; | ||
} | ||
|
||
public String getAssayName() { | ||
return assayName; | ||
} | ||
|
||
public String getAssayDescription() { | ||
return assayDescription; | ||
} | ||
|
||
public Donor getDonor() { | ||
return donor; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public LocalDate getLatestActivityDate() { | ||
return latestActivityDate; | ||
} | ||
|
||
public Set<Project> getProjects() { | ||
return projects; | ||
} | ||
|
||
public List<Sample> getReceipts() { | ||
return receipts; | ||
} | ||
|
||
public Requisition getRequisition() { | ||
return requisition; | ||
} | ||
|
||
public LocalDate getStartDate() { | ||
return startDate; | ||
} | ||
|
||
public List<Test> getTests() { | ||
return tests; | ||
} | ||
|
||
public List<AnalysisQcGroup> getQcGroups() { | ||
return qcGroups; | ||
} | ||
|
||
public List<CaseDeliverable> getDeliverables() { | ||
return deliverables; | ||
} | ||
|
||
public String getTimepoint() { | ||
return timepoint; | ||
} | ||
|
||
public String getTissueOrigin() { | ||
return tissueOrigin; | ||
} | ||
|
||
public String getTissueType() { | ||
return tissueType; | ||
} | ||
|
||
public int getReceiptDaysSpent() { | ||
return receiptDaysSpent; | ||
} | ||
|
||
public int getAnalysisReviewDaysSpent() { | ||
return analysisReviewDaysSpent; | ||
} | ||
|
||
public int getReleaseApprovalDaysSpent() { | ||
return releaseApprovalDaysSpent; | ||
} | ||
|
||
public int getReleaseDaysSpent() { | ||
return releaseDaysSpent; | ||
} | ||
|
||
public int getCaseDaysSpent() { | ||
return caseDaysSpent; | ||
} | ||
|
||
public int getPauseDays() { | ||
return pauseDays; | ||
} | ||
|
||
public boolean isStopped() { | ||
return requisition.isStopped(); | ||
} | ||
@JsonDeserialize(as = CaseImpl.class) | ||
public interface Case { | ||
|
||
@JsonPOJOBuilder(withPrefix = "") | ||
public static class Builder { | ||
long getAssayId(); | ||
|
||
private long assayId; | ||
private String assayName; | ||
private String assayDescription; | ||
private Donor donor; | ||
private String id; | ||
private Set<Project> projects; | ||
private List<Sample> receipts; | ||
private Requisition requisition; | ||
private List<Test> tests; | ||
private List<AnalysisQcGroup> qcGroups; | ||
private List<CaseDeliverable> deliverables; | ||
private String timepoint; | ||
private String tissueOrigin; | ||
private String tissueType; | ||
private LocalDate startDate; | ||
private int receiptDaysSpent; | ||
private int analysisReviewDaysSpent; | ||
private int releaseApprovalDaysSpent; | ||
private int releaseDaysSpent; | ||
private int caseDaysSpent; | ||
private int pauseDays; | ||
String getAssayName(); | ||
|
||
public Case build() { | ||
return new Case(this); | ||
} | ||
String getAssayDescription(); | ||
|
||
public Builder assayId(long assayId) { | ||
this.assayId = assayId; | ||
return this; | ||
} | ||
Donor getDonor(); | ||
|
||
public Builder assayName(String assayName) { | ||
this.assayName = assayName; | ||
return this; | ||
} | ||
String getId(); | ||
|
||
public Builder assayDescription(String assayDescription) { | ||
this.assayDescription = assayDescription; | ||
return this; | ||
} | ||
LocalDate getLatestActivityDate(); | ||
|
||
public Builder donor(Donor donor) { | ||
this.donor = donor; | ||
return this; | ||
} | ||
Set<Project> getProjects(); | ||
|
||
public Builder startDate(LocalDate starDate) { | ||
this.startDate = starDate; | ||
return this; | ||
} | ||
List<Sample> getReceipts(); | ||
|
||
public Builder id(String id) { | ||
this.id = id; | ||
return this; | ||
} | ||
Requisition getRequisition(); | ||
|
||
public Builder projects(Set<Project> projects) { | ||
this.projects = projects; | ||
return this; | ||
} | ||
LocalDate getStartDate(); | ||
|
||
public Builder receipts(List<Sample> receipts) { | ||
this.receipts = receipts; | ||
return this; | ||
} | ||
List<Test> getTests(); | ||
|
||
public Builder requisition(Requisition requisition) { | ||
this.requisition = requisition; | ||
return this; | ||
} | ||
List<AnalysisQcGroup> getQcGroups(); | ||
|
||
public Builder qcGroups(List<AnalysisQcGroup> qcGroups) { | ||
this.qcGroups = qcGroups; | ||
return this; | ||
} | ||
List<CaseDeliverable> getDeliverables(); | ||
|
||
public Builder deliverables(List<CaseDeliverable> deliverables) { | ||
this.deliverables = deliverables; | ||
return this; | ||
} | ||
String getTimepoint(); | ||
|
||
public Builder tests(List<Test> tests) { | ||
this.tests = tests; | ||
return this; | ||
} | ||
String getTissueOrigin(); | ||
|
||
public Builder timepoint(String timepoint) { | ||
this.timepoint = timepoint; | ||
return this; | ||
} | ||
String getTissueType(); | ||
|
||
public Builder tissueOrigin(String tissueOrigin) { | ||
this.tissueOrigin = tissueOrigin; | ||
return this; | ||
} | ||
int getReceiptDaysSpent(); | ||
|
||
public Builder tissueType(String tissueType) { | ||
this.tissueType = tissueType; | ||
return this; | ||
} | ||
int getAnalysisReviewDaysSpent(); | ||
|
||
public Builder receiptDaysSpent(int days) { | ||
this.receiptDaysSpent = days; | ||
return this; | ||
} | ||
int getReleaseApprovalDaysSpent(); | ||
|
||
public Builder analysisReviewDaysSpent(int days) { | ||
this.analysisReviewDaysSpent = days; | ||
return this; | ||
} | ||
int getReleaseDaysSpent(); | ||
|
||
public Builder releaseApprovalDaysSpent(int days) { | ||
this.releaseApprovalDaysSpent = days; | ||
return this; | ||
} | ||
int getCaseDaysSpent(); | ||
|
||
public Builder releaseDaysSpent(int days) { | ||
this.releaseDaysSpent = days; | ||
return this; | ||
} | ||
int getPauseDays(); | ||
|
||
public Builder caseDaysSpent(int days) { | ||
this.caseDaysSpent = days; | ||
return this; | ||
} | ||
boolean isStopped(); | ||
|
||
public Builder pauseDays(int days) { | ||
this.pauseDays = days; | ||
return this; | ||
} | ||
} | ||
} |
Oops, something went wrong.