diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Assay.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Assay.java index 5d92cd0..bbccb25 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Assay.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Assay.java @@ -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; @@ -22,9 +25,10 @@ public Assay(Builder builder) { this.name = requireNonNull(builder.name); this.description = builder.description; this.version = requireNonNull(builder.version); - Map> tempMap = builder.metricCategories.entrySet().stream() - .collect(Collectors.toMap(entry -> entry.getKey(), - entry -> Collections.unmodifiableList(entry.getValue()))); + Map> tempMap = + builder.metricCategories.entrySet().stream() + .collect(Collectors.toMap(entry -> entry.getKey(), + entry -> Collections.unmodifiableList(entry.getValue()))); this.metricCategories = Collections.unmodifiableMap(tempMap); } @@ -48,6 +52,7 @@ public String getVersion() { return version; } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private String description; diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Case.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Case.java index 7207a7a..074bb7b 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Case.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Case.java @@ -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; @@ -36,8 +39,12 @@ 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; @@ -45,7 +52,8 @@ private Case(Builder builder) { 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 @@ -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 projects; @@ -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) { diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Donor.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Donor.java index dc38b84..8d2de08 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Donor.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Donor.java @@ -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; @@ -29,6 +32,7 @@ public String getName() { return name; } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private String externalName; diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Lane.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Lane.java index de4bb7f..1cc8b04 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Lane.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Lane.java @@ -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; @@ -48,6 +51,7 @@ public BigDecimal getPercentPfixRead2() { return percentPfixRead2; } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private Long clustersPf; diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Metric.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Metric.java index f4aedd3..e71582e 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Metric.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Metric.java @@ -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; @@ -97,6 +100,7 @@ public boolean isNegateTissueType() { return negateTissueType; } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private String containerModel; diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/MetricSubcategory.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/MetricSubcategory.java index cecc8b5..e6c068e 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/MetricSubcategory.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/MetricSubcategory.java @@ -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; @@ -36,6 +39,7 @@ public Integer getSortPriority() { return sortPriority; } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private String libraryDesignCode; diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/OmittedSample.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/OmittedSample.java index d3aabeb..c963536 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/OmittedSample.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/OmittedSample.java @@ -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; @@ -61,6 +64,7 @@ public String getRequisitionName() { return requisitionName; } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private LocalDate createdDate; diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Project.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Project.java index f1ab3e6..f46ba05 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Project.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Project.java @@ -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; @@ -23,6 +26,7 @@ public String getPipeline() { return pipeline; } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private String name; diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Requisition.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Requisition.java index 7a884e2..3ea93ef 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Requisition.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Requisition.java @@ -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; @@ -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 @@ -99,6 +105,7 @@ public boolean isStopped() { return stopped; } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private Long assayId; diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/RequisitionQc.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/RequisitionQc.java index e8b09f6..64c5e98 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/RequisitionQc.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/RequisitionQc.java @@ -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; @@ -31,6 +34,7 @@ public boolean isQcPassed() { return qcPassed; } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private LocalDate qcDate; diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/RequisitionQcGroup.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/RequisitionQcGroup.java index 1349e72..c8bbf0d 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/RequisitionQcGroup.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/RequisitionQcGroup.java @@ -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; @@ -61,6 +64,7 @@ public String getTissueType() { return tissueType; } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private BigDecimal callability; diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Run.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Run.java index 02b0cda..914e58e 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Run.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Run.java @@ -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; @@ -138,6 +141,7 @@ public int hashCode() { return Objects.hash(id); } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private Long clustersPf; diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/RunAndLibraries.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/RunAndLibraries.java index a922f78..f2bba52 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/RunAndLibraries.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/RunAndLibraries.java @@ -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 fullDepthSequencings; @@ -33,6 +36,7 @@ public Run getRun() { return run; } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private Set fullDepthSequencings = new HashSet<>(); diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Sample.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Sample.java index 94bcc5b..7950a4e 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Sample.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Sample.java @@ -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; @@ -317,6 +320,7 @@ public int hashCode() { return Objects.hash(id, run, sequencingLane); } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private Integer clustersPerSample; diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Test.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Test.java index 8661e65..8cc818e 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Test.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Test.java @@ -8,10 +8,13 @@ import java.util.List; 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 Test */ +@JsonDeserialize(builder = Test.Builder.class) public class Test { private final boolean extractionSkipped; @@ -110,6 +113,7 @@ public boolean isLibraryPreparationSkipped() { return libraryPreparationSkipped; } + @JsonPOJOBuilder(withPrefix = "") public static class Builder { private boolean extractionSkipped; diff --git a/changes/add_GLT-3978.md b/changes/add_GLT-3978.md new file mode 100644 index 0000000..fb54132 --- /dev/null +++ b/changes/add_GLT-3978.md @@ -0,0 +1 @@ +capability for Jackson parsing for data models using Builder notation \ No newline at end of file diff --git a/changes/add_GLT-3983.md b/changes/add_GLT-3983.md new file mode 100644 index 0000000..860c46b --- /dev/null +++ b/changes/add_GLT-3983.md @@ -0,0 +1 @@ +Case data model to match Dimsum \ No newline at end of file