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

Gp 4415.detailed case format #55

Merged
merged 9 commits into from
Oct 11, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
package ca.on.oicr.gsi.cardea.data;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

import java.time.*;
import java.util.Optional;
import java.util.Set;

import static java.util.Collections.unmodifiableSet;
import static java.util.Objects.requireNonNull;

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

private final String assayName;
private final String assayVersion;
private final String caseIdentifier;
private final CaseStatus caseStatus;
private final boolean stopped;
private final boolean paused;
private final Optional<Instant> completedDate;
private final long requisitionId;
private final String requisitionName;
private final Set<ShesmuSequencing> sequencing;

private ShesmuDetailedCase(Builder builder) {
this.assayName = requireNonNull(builder.assayName);
this.assayVersion = requireNonNull(builder.assayVersion);
this.caseIdentifier = requireNonNull(builder.caseIdentifier);
this.caseStatus = requireNonNull(builder.caseStatus);
this.completedDate = builder.completedDate;
this.stopped = builder.stopped;
this.paused = builder.paused;
this.requisitionId = requireNonNull(builder.requisitionId);
this.requisitionName = requireNonNull(builder.requisitionName);
this.sequencing = unmodifiableSet(requireNonNull(builder.sequencing));
}

public String getAssayName() {
return assayName;
}

public String getAssayVersion() {
return assayVersion;
}

public String getCaseIdentifier() {
return caseIdentifier;
}

public CaseStatus getCaseStatus() {
return caseStatus;
}

public boolean isStopped() {
return stopped;
}

public boolean isPaused() {
return paused;
}

public Optional<Instant> getCompletedDate() {
return completedDate;
}

public long getRequisitionId() {
return requisitionId;
}

public String getRequisitionName() {
return requisitionName;
}

public Set<ShesmuSequencing> getSequencing() {
return sequencing;
}

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

private String assayName;
private String assayVersion;
private String caseIdentifier;
private CaseStatus caseStatus;
private boolean paused;
private boolean stopped;
private Optional<Instant> completedDate;
private long requisitionId;
private String requisitionName;
private Set<ShesmuSequencing> sequencing;

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

public Builder assayName(String assayName) {
this.assayName = assayName;
return this;
}

public Builder assayVersion(String assayVersion) {
this.assayVersion = assayVersion;
return this;
}

public Builder caseStatus(CaseStatus caseStatus) {
this.caseStatus = caseStatus;
return this;
}

public Builder paused(boolean paused) {
this.paused = paused;
return this;
}

public Builder stopped(boolean stopped) {
this.stopped = stopped;
return this;
}

public Builder caseIdentifier(String caseIdentifier) {
this.caseIdentifier = caseIdentifier;
return this;
}

public Builder completedDate(Instant completedDate) {
this.completedDate = completedDate == null ? Optional.empty() : Optional.of(completedDate);
return this;
}

public Builder completedDateLocal(LocalDate completedDate) {
this.completedDate = convertCompletedDate(completedDate);
return this;
}

public Builder requisitionId(long requisitionId) {
this.requisitionId = requisitionId;
return this;
}

public Builder requisitionName(String requisitionName) {
this.requisitionName = requisitionName;
return this;
}

public Builder sequencing(Set<ShesmuSequencing> sequencing){
this.sequencing = sequencing;
return this;
}

private Optional<Instant> convertCompletedDate(LocalDate completedDate) {
if (completedDate == null) {
return Optional.empty();
}
return Optional.of(
ZonedDateTime.of(
completedDate,
LocalTime.MIDNIGHT,
ZoneId.of("UTC")).toInstant());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package ca.on.oicr.gsi.cardea.data;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

import java.util.Set;

import static java.util.Collections.unmodifiableSet;
import static java.util.Objects.requireNonNull;

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

private final String id;
private final boolean supplemental;


private ShesmuSample(Builder builder) {
this.id = requireNonNull(builder.id);
this.supplemental = requireNonNull(builder.supplemental);
}


public String getId() {
return id;
}

public Boolean isSupplemental() {
return supplemental;
}



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

private String id;
private boolean supplemental;

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


public Builder id(String id) {
this.id = id;
return this;
}

public Builder supplemental(boolean supplemental) {
this.supplemental = supplemental;
return this;
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package ca.on.oicr.gsi.cardea.data;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

import java.util.Set;

import static java.util.Collections.*;
import static java.util.Objects.requireNonNull;

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

private final String test;
private final MetricCategory type;
private final Set<ShesmuSample> limsIds;
private final boolean complete;


private ShesmuSequencing(Builder builder) {
this.test = requireNonNull(builder.test);
this.type = requireNonNull(builder.type);
this.limsIds = unmodifiableSet(requireNonNull(builder.limsIds));
this.complete = requireNonNull(builder.complete);
}


public String getTest() {
return test;
}

public MetricCategory getType() {
return type;
}

public Set<ShesmuSample> getLimsIds() {
return limsIds;
}

public Boolean isComplete() {
return complete;
}



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

private String test;
private Set<ShesmuSample> limsIds;
private MetricCategory type;
private boolean complete;

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

public Builder test(String test) {
this.test = test;
return this;
}

public Builder type(MetricCategory type) {
this.type = type;
return this;
}

public Builder limsIds(Set<ShesmuSample> limsIds) {
this.limsIds = limsIds;
return this;
}

public Builder complete(boolean complete) {
this.complete = complete;
return this;
}

}
}
Loading
Loading