From c1137701dfa8936210052e2e87eba9f105c2ca0a Mon Sep 17 00:00:00 2001 From: ala <63405719+ala-ebi@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:42:29 +0100 Subject: [PATCH] add cohorts to studies apis --- .../java/uk/ac/ebi/spot/goci/model/Study.java | 19 ++++++++++++ .../ebi/spot/goci/model/StudyExtension.java | 31 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 goci-core/goci-model/src/main/java/uk/ac/ebi/spot/goci/model/StudyExtension.java diff --git a/goci-core/goci-model/src/main/java/uk/ac/ebi/spot/goci/model/Study.java b/goci-core/goci-model/src/main/java/uk/ac/ebi/spot/goci/model/Study.java index 5286dd6..b1ac483 100644 --- a/goci-core/goci-model/src/main/java/uk/ac/ebi/spot/goci/model/Study.java +++ b/goci-core/goci-model/src/main/java/uk/ac/ebi/spot/goci/model/Study.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonProperty; import org.hibernate.annotations.Where; @@ -19,6 +20,20 @@ public class Study implements Trackable { @JsonIgnore private Long id; + @Transient + @JsonInclude(JsonInclude.Include.NON_NULL) + private String cohort; + + @OneToOne(mappedBy = "study") + @JsonIgnore + private StudyExtension studyExtension; + + @PostLoad + private void onLoad() { + if (this.studyExtension != null) + this.cohort = studyExtension.getCohort(); + } + private String initialSampleSize; @JsonProperty("replicationSampleSize") @@ -189,6 +204,10 @@ public void setId(Long id) { this.id = id; } + public String getCohort() { + return cohort; + } + public String getInitialSampleSize() { return initialSampleSize; } diff --git a/goci-core/goci-model/src/main/java/uk/ac/ebi/spot/goci/model/StudyExtension.java b/goci-core/goci-model/src/main/java/uk/ac/ebi/spot/goci/model/StudyExtension.java new file mode 100644 index 0000000..c35a7e8 --- /dev/null +++ b/goci-core/goci-model/src/main/java/uk/ac/ebi/spot/goci/model/StudyExtension.java @@ -0,0 +1,31 @@ +package uk.ac.ebi.spot.goci.model; + +import lombok.Data; + +import javax.persistence.*; +import java.util.Collection; + +@Entity +@Data +public class StudyExtension { + + @Id + @GeneratedValue + private Long id; + + @OneToOne + @JoinColumn(name = "study_id", unique = true) + private Study study; + + private String statisticalModel; + + private String cohort; + + private String cohortSpecificReference; + + private String summaryStatisticsFile; + + private String summaryStatisticsAssembly; + + private String studyDescription; +}