Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GLT-3983] model changes for dimsum #31

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Assay.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
* Immutable Assay
*/
@JsonDeserialize(builder = Assay.Builder.class)
public class Assay {

private final String description;
Expand All @@ -22,9 +25,10 @@ public Assay(Builder builder) {
this.name = requireNonNull(builder.name);
this.description = builder.description;
this.version = requireNonNull(builder.version);
Map<MetricCategory, List<MetricSubcategory>> tempMap = builder.metricCategories.entrySet().stream()
.collect(Collectors.toMap(entry -> entry.getKey(),
entry -> Collections.unmodifiableList(entry.getValue())));
Map<MetricCategory, List<MetricSubcategory>> tempMap =
builder.metricCategories.entrySet().stream()
.collect(Collectors.toMap(entry -> entry.getKey(),
entry -> Collections.unmodifiableList(entry.getValue())));
this.metricCategories = Collections.unmodifiableMap(tempMap);
}

Expand All @@ -48,6 +52,7 @@ public String getVersion() {
return version;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private String description;
Expand Down
25 changes: 20 additions & 5 deletions cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Case.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
import java.util.stream.Stream;

import com.fasterxml.jackson.annotation.JsonIgnore;
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 Assay assay;
Expand All @@ -36,16 +39,21 @@ private Case(Builder builder) {
this.id = requireNonNull(builder.id);
this.donor = requireNonNull(builder.donor);
this.projects = unmodifiableSet(builder.projects);
this.assay = requireNonNull(builder.assay);
this.assayId = this.assay.getId();
this.assay = builder.assay;
if (this.assay != null) {
this.assayId = this.assay.getId();
} else {
this.assayId = builder.assayId;
}
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.requisition = builder.requisition;
this.startDate = builder.receipts.stream()
.filter(sample -> sample.getRequisitionId().longValue() == builder.requisition.getId())
.filter(sample -> sample.getRequisitionId() != null
&& sample.getRequisitionId().longValue() == builder.requisition.getId())
.map(Sample::getCreatedDate)
.min(LocalDate::compareTo).orElse(null);
this.latestActivityDate = Stream
Expand Down Expand Up @@ -114,9 +122,11 @@ public boolean isStopped() {
return requisition.isStopped();
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private Assay assay;
private long assayId;
private Donor donor;
private String id;
private Set<Project> projects;
Expand All @@ -127,13 +137,18 @@ public static class Builder {
private String tissueOrigin;
private String tissueType;

public Case build() {
return new Case(this);
}

public Builder assay(Assay assay) {
this.assay = assay;
return this;
}

public Case build() {
return new Case(this);
public Builder assayId(long assayId) {
this.assayId = assayId;
return this;
}

public Builder donor(Donor donor) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package ca.on.oicr.gsi.cardea.data;

import static java.util.Objects.requireNonNull;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
* Immutable Donor
*/
@JsonDeserialize(builder = Donor.Builder.class)
public class Donor {

private final String externalName;
Expand All @@ -29,6 +32,7 @@ public String getName() {
return name;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private String externalName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import java.math.BigDecimal;
import java.util.Objects;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
* Immutable Lane
*/
@JsonDeserialize(builder = Lane.Builder.class)
public class Lane {

private final Long clustersPf;
Expand Down Expand Up @@ -48,6 +51,7 @@ public BigDecimal getPercentPfixRead2() {
return percentPfixRead2;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private Long clustersPf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import static java.util.Objects.requireNonNull;

import java.math.BigDecimal;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
* Immutable Metric
*/
@JsonDeserialize(builder = Metric.Builder.class)
public class Metric {

private final String containerModel;
Expand Down Expand Up @@ -97,6 +100,7 @@ public boolean isNegateTissueType() {
return negateTissueType;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private String containerModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import java.util.Collections;
import java.util.List;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
* Immutable MetricSubcategory
*/
@JsonDeserialize(builder = MetricSubcategory.Builder.class)
public class MetricSubcategory {

private final String libraryDesignCode;
Expand Down Expand Up @@ -36,6 +39,7 @@ public Integer getSortPriority() {
return sortPriority;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private String libraryDesignCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import static java.util.Objects.requireNonNull;

import java.time.LocalDate;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
* Immutable OmittedSample
*/
@JsonDeserialize(builder = OmittedSample.Builder.class)
public class OmittedSample {

private final Long assayId;
Expand Down Expand Up @@ -61,6 +64,7 @@ public String getRequisitionName() {
return requisitionName;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private LocalDate createdDate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package ca.on.oicr.gsi.cardea.data;

import static java.util.Objects.requireNonNull;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
* Immutable Project
*/
@JsonDeserialize(builder = Project.Builder.class)
public class Project {

private final String name;
Expand All @@ -23,6 +26,7 @@ public String getPipeline() {
return pipeline;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
import java.util.Objects;
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 Requisition
*/
@JsonDeserialize(builder = Requisition.Builder.class)
public class Requisition {

private final Long assayId;
Expand All @@ -35,11 +38,14 @@ private Requisition(Builder builder) {
this.qcGroups = builder.qcGroups == null ? emptyList() : unmodifiableList(builder.qcGroups);
this.informaticsReviews = builder.informaticsReviews == null ? emptyList()
: unmodifiableList(builder.informaticsReviews);
this.draftReports = builder.draftReports == null ? emptyList() : unmodifiableList(builder.draftReports);
this.finalReports = builder.finalReports == null ? emptyList() : unmodifiableList(builder.finalReports);
this.latestActivityDate = Stream.of(informaticsReviews.stream(), draftReports.stream(), finalReports.stream())
.flatMap(Function.identity()).map(RequisitionQc::getQcDate).max(LocalDate::compareTo)
.orElse(null);
this.draftReports =
builder.draftReports == null ? emptyList() : unmodifiableList(builder.draftReports);
this.finalReports =
builder.finalReports == null ? emptyList() : unmodifiableList(builder.finalReports);
this.latestActivityDate =
Stream.of(informaticsReviews.stream(), draftReports.stream(), finalReports.stream())
.flatMap(Function.identity()).map(RequisitionQc::getQcDate).max(LocalDate::compareTo)
.orElse(null);
}

@Override
Expand Down Expand Up @@ -99,6 +105,7 @@ public boolean isStopped() {
return stopped;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private Long assayId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import static java.util.Objects.requireNonNull;

import java.time.LocalDate;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
* Immutable RequisitionQc
*/
@JsonDeserialize(builder = RequisitionQc.Builder.class)
public class RequisitionQc {

private final LocalDate qcDate;
Expand All @@ -31,6 +34,7 @@ public boolean isQcPassed() {
return qcPassed;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private LocalDate qcDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import static java.util.Objects.requireNonNull;

import java.math.BigDecimal;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
* Immutable RequisitionQcGroup
*/
@JsonDeserialize(builder = RequisitionQcGroup.Builder.class)
public class RequisitionQcGroup {

private final BigDecimal callability;
Expand Down Expand Up @@ -61,6 +64,7 @@ public String getTissueType() {
return tissueType;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private BigDecimal callability;
Expand Down
4 changes: 4 additions & 0 deletions cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
* Immutable Run
*/
@JsonDeserialize(builder = Run.Builder.class)
public class Run {

private final Long clustersPf;
Expand Down Expand Up @@ -138,6 +141,7 @@ public int hashCode() {
return Objects.hash(id);
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private Long clustersPf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
* Immutable RunAndLibraries
*/
@JsonDeserialize(builder = RunAndLibraries.Builder.class)
public class RunAndLibraries {

private Set<Sample> fullDepthSequencings;
Expand All @@ -33,6 +36,7 @@ public Run getRun() {
return run;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private Set<Sample> fullDepthSequencings = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import java.time.LocalDate;
import java.util.Objects;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

/**
* Immutable Sample
*/
@JsonDeserialize(builder = Sample.Builder.class)
public class Sample {

private final Long assayId;
Expand Down Expand Up @@ -317,6 +320,7 @@ public int hashCode() {
return Objects.hash(id, run, sequencingLane);
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private Integer clustersPerSample;
Expand Down
Loading