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

Initial code for mapped super class for associations #1674

Open
wants to merge 1 commit into
base: alpha
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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<Gene> assertedGenes;
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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<ConditionRelation> conditionRelations;

@IndexedEmbedded(includePaths = {"freeText", "noteType.name", "references.curie",
Expand All @@ -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<Note> 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,19 +26,17 @@
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;

@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 })
Expand All @@ -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;

Expand All @@ -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<ECOTerm> evidenceCodes;

@IndexedEmbedded(includePaths = {
Expand All @@ -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<Gene> with;

Expand All @@ -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<VocabularyTerm> diseaseQualifiers;

@IndexedEmbedded(includePaths = {"name", "name_keyword"})
Expand All @@ -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<BiologicalEntity> diseaseGeneticModifiers;

@IndexedEmbedded(includePaths = {"name", "name_keyword"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down
Loading
Loading