From a7b657e37a5c8961999d2beabebae8407557a5ae Mon Sep 17 00:00:00 2001 From: Olin Blodgett Date: Sat, 14 Sep 2024 23:00:22 -0600 Subject: [PATCH] Initial code for mapped super class for associations --- .../model/entities/AGMDiseaseAnnotation.java | 37 +- .../model/entities/Annotation.java | 17 +- .../model/entities/Association.java | 19 +- .../model/entities/DiseaseAnnotation.java | 28 +- .../model/entities/EvidenceAssociation.java | 4 +- .../model/entities/ExpressionAnnotation.java | 8 +- .../model/entities/PhenotypeAnnotation.java | 4 +- .../entities/SingleReferenceAssociation.java | 4 +- .../AlleleGenomicEntityAssociation.java | 4 +- .../ConstructGenomicEntityAssociation.java | 3 +- .../geneAssociations/GeneGeneAssociation.java | 4 +- .../bulkloads/BulkLoadFileHistory.java | 2 +- .../db/v0.37.0.50__flatten_assocations.sql | 691 ++++++++++++++++++ 13 files changed, 744 insertions(+), 81 deletions(-) create mode 100644 src/main/resources/db/v0.37.0.50__flatten_assocations.sql diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/AGMDiseaseAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/AGMDiseaseAnnotation.java index eb0d67d60..e50dca715 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/AGMDiseaseAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/AGMDiseaseAnnotation.java @@ -6,8 +6,8 @@ import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; -import org.hibernate.annotations.Fetch; -import org.hibernate.annotations.FetchMode; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; @@ -22,6 +22,7 @@ import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import jakarta.persistence.Transient; import lombok.Data; import lombok.EqualsAndHashCode; @@ -33,13 +34,33 @@ @Schema(name = "AGM_Disease_Annotation", description = "Annotation class representing a agm disease annotation") @JsonTypeName("AGMDiseaseAnnotation") @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { DiseaseAnnotation.class }) + +@Table(indexes = { + @Index(name = "AGMDiseaseAnnotation_curie_index", columnList = "curie"), + @Index(name = "AGMDiseaseAnnotation_uniqueId_index", columnList = "uniqueId"), + @Index(name = "AGMDiseaseAnnotation_modEntityId_index", columnList = "modEntityId"), + @Index(name = "AGMDiseaseAnnotation_modInternalId_index", columnList = "modInternalId"), + @Index(name = "AGMDiseaseAnnotation_createdBy_index", columnList = "createdBy_id"), + @Index(name = "AGMDiseaseAnnotation_updatedBy_index", columnList = "updatedBy_id"), + @Index(name = "AGMDiseaseAnnotation_singleReference_index", columnList = "singleReference_id"), + @Index(name = "AGMDiseaseAnnotation_dataProvider_index", columnList = "dataProvider_id"), + @Index(name = "AGMDiseaseAnnotation_annotationType_index", columnList = "annotationType_id"), + @Index(name = "AGMDiseaseAnnotation_diseaseAnnotationObject_index", columnList = "diseaseAnnotationObject_id"), + @Index(name = "AGMDiseaseAnnotation_diseaseGeneticModifierRelation_index", columnList = "diseaseGeneticModifierRelation_id"), + @Index(name = "AGMDiseaseAnnotation_geneticSex_index", columnList = "geneticSex_id"), + @Index(name = "AGMDiseaseAnnotation_relation_index", columnList = "relation_id"), + @Index(name = "AGMDiseaseAnnotation_secondaryDataProvider_index", columnList = "secondaryDataProvider_id"), + @Index(name = "AGMDiseaseAnnotation_assertedAllele_index", columnList = "assertedAllele_id"), + @Index(name = "AGMDiseaseAnnotation_diseaseAnnotationSubject_index", columnList = "diseaseAnnotationSubject_id"), + @Index(name = "AGMDiseaseAnnotation_inferredAllele_index", columnList = "inferredAllele_id"), + @Index(name = "AGMDiseaseAnnotation_inferredGene_index", columnList = "inferredGene_id") +}) public class AGMDiseaseAnnotation extends DiseaseAnnotation { @IndexedEmbedded(includePaths = {"name", "name_keyword", "curie", "curie_keyword", "modEntityId", "modEntityId_keyword", "modInternalId", "modInternalId_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) - @org.hibernate.annotations.OnDelete(action = org.hibernate.annotations.OnDeleteAction.CASCADE) + @OnDelete(action = OnDeleteAction.CASCADE) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private AffectedGenomicModel diseaseAnnotationSubject; @@ -53,7 +74,6 @@ public class AGMDiseaseAnnotation extends DiseaseAnnotation { }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private Gene inferredGene; @@ -66,7 +86,6 @@ public class AGMDiseaseAnnotation extends DiseaseAnnotation { }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private Allele inferredAllele; @@ -80,10 +99,9 @@ public class AGMDiseaseAnnotation extends DiseaseAnnotation { }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany - @Fetch(FetchMode.SELECT) @JoinTable(indexes = { - @Index(name = "association_agmdiseaseannotation_index", columnList = "agmdiseaseannotation_id"), - @Index(name = "association_assertedgenes_index", columnList = "assertedgenes_id") + @Index(columnList = "agmdiseaseannotation_id"), + @Index(columnList = "assertedgenes_id") }) @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) private List assertedGenes; @@ -97,7 +115,6 @@ public class AGMDiseaseAnnotation extends DiseaseAnnotation { }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private Allele assertedAllele; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Annotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Annotation.java index 9117376b3..09834e01f 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Annotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Annotation.java @@ -7,8 +7,6 @@ import org.alliancegenome.curation_api.model.entities.base.AuditedObject; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; -import org.hibernate.annotations.Fetch; -import org.hibernate.annotations.FetchMode; import org.hibernate.search.engine.backend.types.Aggregable; import org.hibernate.search.engine.backend.types.Searchable; import org.hibernate.search.engine.backend.types.Sortable; @@ -22,17 +20,15 @@ import jakarta.persistence.CascadeType; import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.Index; -import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; import jakarta.persistence.OneToMany; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @ToString(callSuper = true) @@ -72,10 +68,6 @@ public class Annotation extends SingleReferenceAssociation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.PhenotypeAnnotationView.class, View.ForPublic.class }) - @JoinTable(indexes = { - @Index(name = "association_annotation_conditionrelation_index", columnList = "annotation_id"), - @Index(name = "association_annotation_conditionrelations_index", columnList = "conditionrelations_id") - }) private List conditionRelations; @IndexedEmbedded(includePaths = {"freeText", "noteType.name", "references.curie", @@ -85,17 +77,12 @@ public class Annotation extends SingleReferenceAssociation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) - @JoinTable(indexes = { - @Index(name = "association_annotation_annotation_index", columnList = "annotation_id"), - @Index(name = "association_relatednotes_index", columnList = "relatednotes_id") - }) private List relatedNotes; @IndexedEmbedded(includePaths = {"sourceOrganization.abbreviation", "sourceOrganization.fullName", "sourceOrganization.shortName", "crossReference.displayName", "crossReference.referencedCurie", "sourceOrganization.abbreviation_keyword", "sourceOrganization.fullName_keyword", "sourceOrganization.shortName_keyword", "crossReference.displayName_keyword", "crossReference.referencedCurie_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) protected DataProvider dataProvider; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Association.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Association.java index 2f3c01825..2efa81eb2 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Association.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Association.java @@ -5,24 +5,20 @@ import org.alliancegenome.curation_api.model.entities.base.AuditedObject; import org.eclipse.microprofile.openapi.annotations.media.Schema; -import jakarta.persistence.DiscriminatorColumn; -import jakarta.persistence.Entity; -import jakarta.persistence.Index; -import jakarta.persistence.Inheritance; -import jakarta.persistence.InheritanceType; -import jakarta.persistence.Table; +import jakarta.persistence.MappedSuperclass; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Inheritance(strategy = InheritanceType.SINGLE_TABLE) -@DiscriminatorColumn(name = "AssociationType", length = 96) -@Entity +//@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +//@DiscriminatorColumn(name = "AssociationType", length = 96) +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @ToString(callSuper = true) @Schema(name = "association", description = "POJO that represents an association") -@Table(indexes = { +//@Table(indexes = { + /* @Index(name = "association_curie_index", columnList = "curie"), @Index(name = "association_modEntityId_index", columnList = "modEntityId"), @Index(name = "association_modInternalId_index", columnList = "modInternalId"), @@ -82,7 +78,8 @@ @Index(name = "association_createdby_index", columnList = "createdBy_id"), @Index(name = "association_updatedby_index", columnList = "updatedBy_id") -}) +*/ +//}) @AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObject.class }) public class Association extends AuditedObject { diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/DiseaseAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/DiseaseAnnotation.java index e4e3e4abb..c804fd667 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/DiseaseAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/DiseaseAnnotation.java @@ -9,8 +9,6 @@ import org.alliancegenome.curation_api.model.entities.ontology.ECOTerm; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; -import org.hibernate.annotations.Fetch; -import org.hibernate.annotations.FetchMode; import org.hibernate.search.engine.backend.types.Aggregable; import org.hibernate.search.engine.backend.types.Searchable; import org.hibernate.search.engine.backend.types.Sortable; @@ -28,11 +26,9 @@ import com.fasterxml.jackson.annotation.JsonView; import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.Index; -import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; import jakarta.persistence.Transient; import lombok.Data; import lombok.EqualsAndHashCode; @@ -40,7 +36,7 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @JsonSubTypes({ @Type(value = AGMDiseaseAnnotation.class, name = "AGMDiseaseAnnotation"), @Type(value = AlleleDiseaseAnnotation.class, name = "AlleleDiseaseAnnotation"), @Type(value = GeneDiseaseAnnotation.class, name = "GeneDiseaseAnnotation") }) -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { Annotation.class }) @@ -51,7 +47,6 @@ public abstract class DiseaseAnnotation extends Annotation { "curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "namespace_keyword" }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private DOTerm diseaseAnnotationObject; @@ -72,10 +67,6 @@ public abstract class DiseaseAnnotation extends Annotation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) - @JoinTable(indexes = { - @Index(name = "association_diseaseannotation_diseaseannotation_index", columnList = "diseaseannotation_id"), - @Index(name = "association_diseaseannotation_evidencecodes_index", columnList = "evidencecodes_id") - }) private List evidenceCodes; @IndexedEmbedded(includePaths = { @@ -88,11 +79,6 @@ public abstract class DiseaseAnnotation extends Annotation { }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany - @Fetch(FetchMode.SELECT) - @JoinTable(indexes = { - @Index(name = "association_diseaseannotation_gene_index", columnList = "diseaseannotation_id"), - @Index(name = "association_diseaseannotation_with_index", columnList = "with_id") - }) @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) private List with; @@ -106,10 +92,6 @@ public abstract class DiseaseAnnotation extends Annotation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) - @JoinTable(indexes = { - @Index(name = "association_diseaseannotation_vt_diseaseannotation_index", columnList = "diseaseannotation_id"), - @Index(name = "association_diseaseannotation_diseasequalifiers_index", columnList = "diseasequalifiers_id") - }) private List diseaseQualifiers; @IndexedEmbedded(includePaths = {"name", "name_keyword"}) @@ -122,19 +104,13 @@ public abstract class DiseaseAnnotation extends Annotation { "sourceOrganization.abbreviation_keyword", "sourceOrganization.fullName_keyword", "sourceOrganization.shortName_keyword", "crossReference.displayName_keyword", "crossReference.referencedCurie_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private DataProvider secondaryDataProvider; @IndexedEmbedded(includeDepth = 1) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) - @JoinTable(indexes = { - @Index(name = "association_diseaseannotation_BiologicalEntity_index", columnList = "diseaseannotation_id"), - @Index(name = "association_diseaseannotation_dgms_index", columnList = "diseasegeneticmodifiers_id") - }) private List diseaseGeneticModifiers; @IndexedEmbedded(includePaths = {"name", "name_keyword"}) diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/EvidenceAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/EvidenceAssociation.java index 63a71cc3f..b950aade4 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/EvidenceAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/EvidenceAssociation.java @@ -12,14 +12,14 @@ import com.fasterxml.jackson.annotation.JsonView; -import jakarta.persistence.Entity; import jakarta.persistence.Index; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; +import jakarta.persistence.MappedSuperclass; import lombok.Data; import lombok.EqualsAndHashCode; -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @Schema(name = "evidenceAssociation", description = "POJO that represents an association supported by any number of information content entities") diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/ExpressionAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/ExpressionAnnotation.java index dc8f910eb..4c436e0fb 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/ExpressionAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/ExpressionAnnotation.java @@ -14,24 +14,20 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonView; import jakarta.persistence.CascadeType; import jakarta.persistence.Column; -import jakarta.persistence.Entity; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; import jakarta.persistence.OneToOne; import jakarta.persistence.Transient; import lombok.Data; import lombok.EqualsAndHashCode; -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") -@JsonSubTypes({ @JsonSubTypes.Type(value = GeneExpressionAnnotation.class, name = "GeneExpressionAnnotation") }) -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @AGRCurationSchemaVersion(min = "2.2.3", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { Annotation.class }) diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/PhenotypeAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/PhenotypeAnnotation.java index 44be871a0..499c4b53c 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/PhenotypeAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/PhenotypeAnnotation.java @@ -23,11 +23,11 @@ import com.fasterxml.jackson.annotation.JsonView; import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; import jakarta.persistence.Index; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; import jakarta.persistence.OneToOne; import jakarta.persistence.Transient; import lombok.Data; @@ -36,7 +36,7 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @JsonSubTypes({ @Type(value = AGMPhenotypeAnnotation.class, name = "AGMPhenotypeAnnotation"), @Type(value = AllelePhenotypeAnnotation.class, name = "AllelePhenotypeAnnotation"), @Type(value = GenePhenotypeAnnotation.class, name = "GenePhenotypeAnnotation") }) -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @AGRCurationSchemaVersion(min = "2.2.3", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { Annotation.class }) diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/SingleReferenceAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/SingleReferenceAssociation.java index 77af76ef1..eb5b122e2 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/SingleReferenceAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/SingleReferenceAssociation.java @@ -10,12 +10,12 @@ import com.fasterxml.jackson.annotation.JsonView; -import jakarta.persistence.Entity; import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; import lombok.Data; import lombok.EqualsAndHashCode; -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @Schema(name = "singleReferenceAssociation", description = "POJO that represents an association supported by a single reference") diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java index ec6cef974..8b546b8ea 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java @@ -15,14 +15,14 @@ import com.fasterxml.jackson.annotation.JsonView; import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; import jakarta.persistence.OneToOne; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @ToString(callSuper = true) diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java index 865a69c0a..29bf4e804 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java @@ -26,7 +26,6 @@ import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; -import jakarta.persistence.OneToOne; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -58,7 +57,7 @@ public class ConstructGenomicEntityAssociation extends EvidenceAssociation { @IndexedEmbedded(includeDepth = 1) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) - @OneToOne + @ManyToOne @JsonView({ View.FieldsOnly.class }) @JsonIgnoreProperties({ "alleleGeneAssociations", "constructGenomicEntityAssociations", "sequenceTargetingReagentGeneAssociations", diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/geneAssociations/GeneGeneAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/geneAssociations/GeneGeneAssociation.java index 7d224d958..ed50f135f 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/geneAssociations/GeneGeneAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/geneAssociations/GeneGeneAssociation.java @@ -13,13 +13,13 @@ import com.fasterxml.jackson.annotation.JsonView; -import jakarta.persistence.Entity; import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @ToString(callSuper = true) diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileHistory.java b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileHistory.java index f925eeae5..efcba3ade 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileHistory.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileHistory.java @@ -49,7 +49,7 @@ public class BulkLoadFileHistory extends AuditedObject { @JsonView({ View.FieldsOnly.class }) @JdbcTypeCode(SqlTypes.JSON) - private Map counts = new HashMap(); + private Map counts = new HashMap<>(); @JsonView({ View.FieldsOnly.class }) @Enumerated(EnumType.STRING) diff --git a/src/main/resources/db/v0.37.0.50__flatten_assocations.sql b/src/main/resources/db/v0.37.0.50__flatten_assocations.sql new file mode 100644 index 000000000..aa9160a29 --- /dev/null +++ b/src/main/resources/db/v0.37.0.50__flatten_assocations.sql @@ -0,0 +1,691 @@ +CREATE SEQUENCE agmdiseaseannotation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +SELECT setval( 'agmdiseaseannotation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); + +CREATE TABLE agmdiseaseannotation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + curie character varying(255), + modentityid character varying(255), + modinternalid character varying(255), + uniqueid character varying(3500), + negated boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + singlereference_id bigint, + dataprovider_id bigint, + annotationtype_id bigint, + diseaseannotationobject_id bigint, + diseasegeneticmodifierrelation_id bigint, + geneticsex_id bigint, + relation_id bigint, + secondarydataprovider_id bigint, + assertedallele_id bigint, + diseaseannotationsubject_id bigint, + inferredallele_id bigint, + inferredgene_id bigint +); + +INSERT INTO agmdiseaseannotation + SELECT id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + curie, + modentityid, + modinternalid, + uniqueid, + negated, + createdby_id, + updatedby_id, + singlereference_id, + dataprovider_id, + annotationtype_id, + diseaseannotationobject_id, + diseasegeneticmodifierrelation_id, + geneticsex_id, + relation_id, + secondarydataprovider_id, + assertedallele_id, + diseaseannotationsubject_id, + inferredallele_id, + inferredgene_id FROM Association WHERE AssociationType = 'AGMDiseaseAnnotation'; + + +CREATE SEQUENCE agmphenotypeannotation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +SELECT setval( 'AGMPhenotypeAnnotation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); + +CREATE TABLE agmphenotypeannotation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + curie character varying(255), + modentityid character varying(255), + modinternalid character varying(255), + uniqueid character varying(3500), + phenotypeannotationobject character varying(255), + createdby_id bigint, + updatedby_id bigint, + singlereference_id bigint, + dataprovider_id bigint, + crossreference_id bigint, + relation_id bigint, + assertedallele_id bigint, + inferredallele_id bigint, + inferredgene_id bigint, + phenotypeannotationsubject_id bigint +); + +INSERT INTO agmphenotypeannotation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + curie, + modentityid, + modinternalid, + uniqueid, + phenotypeannotationobject, + createdby_id, + updatedby_id, + singlereference_id, + dataprovider_id, + crossreference_id, + relation_id, + assertedallele_id, + inferredallele_id, + inferredgene_id, + phenotypeannotationsubject_id FROM Association WHERE AssociationType = 'AGMPhenotypeAnnotation'; + +CREATE SEQUENCE allelediseaseannotation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +SELECT setval( 'AlleleDiseaseAnnotation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); + +CREATE TABLE allelediseaseannotation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + curie character varying(255), + modentityid character varying(255), + modinternalid character varying(255), + uniqueid character varying(3500), + negated boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + singlereference_id bigint, + dataprovider_id bigint, + annotationtype_id bigint, + diseaseannotationobject_id bigint, + diseasegeneticmodifierrelation_id bigint, + geneticsex_id bigint, + relation_id bigint, + secondarydataprovider_id bigint, + diseaseannotationsubject_id bigint, + inferredgene_id bigint +); + +INSERT INTO allelediseaseannotation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + curie, + modentityid, + modinternalid, + uniqueid, + negated, + createdby_id, + updatedby_id, + singlereference_id, + dataprovider_id, + annotationtype_id, + diseaseannotationobject_id, + diseasegeneticmodifierrelation_id, + geneticsex_id, + relation_id, + secondarydataprovider_id, + diseaseannotationsubject_id, + inferredgene_id FROM Association WHERE AssociationType = 'AlleleDiseaseAnnotation'; + + +CREATE SEQUENCE allelegeneassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +SELECT setval( 'AlleleGeneAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); + +CREATE TABLE allelegeneassociation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + evidencecode_id bigint, + relatednote_id bigint, + relation_id bigint, + alleleassociationsubject_id bigint, + allelegeneassociationobject_id bigint +); + +INSERT INTO allelegeneassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + createdby_id, + updatedby_id, + evidencecode_id, + relatednote_id, + relation_id, + alleleassociationsubject_id, + allelegeneassociationobject_id FROM Association WHERE AssociationType = 'AlleleGeneAssociation'; + + +CREATE SEQUENCE allelephenotypeannotation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +SELECT setval( 'AllelePhenotypeAnnotation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); + +CREATE TABLE allelephenotypeannotation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + curie character varying(255), + modentityid character varying(255), + modinternalid character varying(255), + uniqueid character varying(3500), + phenotypeannotationobject character varying(255), + createdby_id bigint, + updatedby_id bigint, + singlereference_id bigint, + dataprovider_id bigint, + crossreference_id bigint, + relation_id bigint, + inferredgene_id bigint, + phenotypeannotationsubject_id bigint +); + +INSERT INTO allelephenotypeannotation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + curie, + modentityid, + modinternalid, + uniqueid, + phenotypeannotationobject, + createdby_id, + updatedby_id, + singlereference_id, + dataprovider_id, + crossreference_id, + relation_id, + inferredgene_id, + phenotypeannotationsubject_id FROM Association WHERE AssociationType = 'AllelePhenotypeAnnotation'; + + +CREATE SEQUENCE codingsequencegenomiclocationassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +SELECT setval( 'CodingSequenceGenomicLocationAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); + +CREATE TABLE codingsequencegenomiclocationassociation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + "end" integer, + start integer, + phase integer, + strand character varying(1), + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + codingsequenceassociationsubject_id bigint, + codingsequencegenomiclocationassociationobject_id bigint +); + +INSERT INTO codingsequencegenomiclocationassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + "end", + start, + phase, + strand, + createdby_id, + updatedby_id, + relation_id, + codingsequenceassociationsubject_id, + codingsequencegenomiclocationassociationobject_id FROM Association WHERE AssociationType = 'CodingSequenceGenomicLocationAssociation'; + +CREATE SEQUENCE constructgenomicentityassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +SELECT setval( 'ConstructGenomicEntityAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); + +CREATE TABLE constructgenomicentityassociation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + constructassociationsubject_id bigint, + constructgenomicentityassociationobject_id bigint, + relation_id bigint +); + +INSERT INTO constructgenomicentityassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + createdby_id, + updatedby_id, + constructassociationsubject_id, + constructgenomicentityassociationobject_id, + relation_id FROM Association WHERE AssociationType = 'ConstructGenomicEntityAssociation'; + + +CREATE SEQUENCE exongenomiclocationassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +SELECT setval( 'ExonGenomicLocationAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); + +CREATE TABLE exongenomiclocationassociation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + "end" integer, + start integer, + strand character varying(1), + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + exonassociationsubject_id bigint, + exongenomiclocationassociationobject_id bigint +); + +INSERT INTO exongenomiclocationassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + "end", + start, + strand, + createdby_id, + updatedby_id, + relation_id, + exonassociationsubject_id, + exongenomiclocationassociationobject_id FROM Association WHERE AssociationType = 'ExonGenomicLocationAssociation'; + +CREATE SEQUENCE genediseaseannotation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +SELECT setval( 'GeneExpressionAnnotation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); + +CREATE TABLE genediseaseannotation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + curie character varying(255), + modentityid character varying(255), + modinternalid character varying(255), + uniqueid character varying(3500), + negated boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + singlereference_id bigint, + dataprovider_id bigint, + annotationtype_id bigint, + diseaseannotationobject_id bigint, + diseasegeneticmodifierrelation_id bigint, + geneticsex_id bigint, + relation_id bigint, + secondarydataprovider_id bigint, + diseaseannotationsubject_id bigint, + sgdstrainbackground_id bigint +); + +INSERT INTO genediseaseannotation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + curie, + modentityid, + modinternalid, + uniqueid, + negated, + createdby_id, + updatedby_id, + singlereference_id, + dataprovider_id, + annotationtype_id, + diseaseannotationobject_id, + diseasegeneticmodifierrelation_id, + geneticsex_id, + relation_id, + secondarydataprovider_id, + diseaseannotationsubject_id, + sgdstrainbackground_id FROM Association WHERE AssociationType = 'GeneExpressionAnnotation'; + +CREATE SEQUENCE genephenotypeannotation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +SELECT setval( 'GenePhenotypeAnnotation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); + +CREATE TABLE genephenotypeannotation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + curie character varying(255), + modentityid character varying(255), + modinternalid character varying(255), + uniqueid character varying(3500), + phenotypeannotationobject character varying(255), + createdby_id bigint, + updatedby_id bigint, + singlereference_id bigint, + dataprovider_id bigint, + crossreference_id bigint, + relation_id bigint, + phenotypeannotationsubject_id bigint, + sgdstrainbackground_id bigint +); + +INSERT INTO genephenotypeannotation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + curie, + modentityid, + modinternalid, + uniqueid, + phenotypeannotationobject, + createdby_id, + updatedby_id, + singlereference_id, + dataprovider_id, + crossreference_id, + relation_id, + phenotypeannotationsubject_id, + sgdstrainbackground_id FROM Association WHERE AssociationType = 'GenePhenotypeAnnotation'; + +CREATE SEQUENCE public.sequencetargetingreagentgeneassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +SELECT setval( 'SequenceTargetingReagentGeneAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); + +CREATE TABLE public.sequencetargetingreagentgeneassociation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + sequencetargetingreagentassociationsubject_id bigint, + sequencetargetingreagentgeneassociationobject_id bigint +); + +INSERT INTO public.sequencetargetingreagentgeneassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + createdby_id, + updatedby_id, + relation_id, + sequencetargetingreagentassociationsubject_id, + sequencetargetingreagentgeneassociationobject_id FROM Association WHERE AssociationType = 'SequenceTargetingReagentGeneAssociation'; + + +CREATE SEQUENCE public.transcriptcodingsequenceassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE public.transcriptcodingsequenceassociation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + transcriptassociationsubject_id bigint, + transcriptcodingsequenceassociationobject_id bigint +); + +CREATE SEQUENCE public.transcriptexonassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE public.transcriptexonassociation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + transcriptassociationsubject_id bigint, + transcriptexonassociationobject_id bigint +); + +CREATE SEQUENCE public.transcriptgeneassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE public.transcriptgeneassociation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + transcriptassociationsubject_id bigint, + transcriptgeneassociationobject_id bigint +); + +CREATE SEQUENCE public.transcriptgenomiclocationassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE public.transcriptgenomiclocationassociation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + "end" integer, + start integer, + phase integer, + strand character varying(1), + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + transcriptassociationsubject_id bigint, + transcriptgenomiclocationassociationobject_id bigint +); + + + + + + + + + + + + + + + + + + + +