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

SCRUM-4603 add convenience method for relation plus negation #1738

Merged
merged 3 commits into from
Nov 22, 2024
Merged
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
@@ -1,7 +1,13 @@
package org.alliancegenome.curation_api.model.entities;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonView;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants;
import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion;
import org.alliancegenome.curation_api.model.bridges.BooleanValueBridge;
Expand All @@ -19,25 +25,7 @@
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency;
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.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonView;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Index;
import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.JoinColumn;
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;
import java.util.List;

@Inheritance(strategy = InheritanceType.JOINED)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
Expand All @@ -49,7 +37,7 @@
@Entity
@Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true)
@AGRCurationSchemaVersion(min = "2.8.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { Annotation.class })
@AGRCurationSchemaVersion(min = "2.8.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = {Annotation.class})
@Schema(name = "Disease_Annotation", description = "Annotation class representing a disease annotation")
@Table(indexes = {
@Index(name = "DiseaseAnnotation_internal_index", columnList = "internal"),
Expand All @@ -73,29 +61,29 @@
public abstract class DiseaseAnnotation extends Annotation {

@IndexedEmbedded(includePaths = {"curie", "name", "secondaryIdentifiers", "synonyms.name", "namespace",
"curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "namespace_keyword" })
"curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "namespace_keyword"})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToOne
@JsonView({ View.FieldsOnly.class, View.ForPublic.class })
@JsonView({View.FieldsOnly.class, View.ForPublic.class})
private DOTerm diseaseAnnotationObject;

@FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer", valueBridge = @ValueBridgeRef(type = BooleanValueBridge.class))
@KeywordField(name = "negated_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, valueBridge = @ValueBridgeRef(type = BooleanValueBridge.class))
@JsonView({ View.FieldsOnly.class, View.ForPublic.class })
@JsonView({View.FieldsOnly.class, View.ForPublic.class})
@Column(columnDefinition = "boolean default false", nullable = false)
private Boolean negated = false;

@IndexedEmbedded(includePaths = {"name", "name_keyword"})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToOne
@JsonView({ View.FieldsOnly.class, View.ForPublic.class })
@JsonView({View.FieldsOnly.class, View.ForPublic.class})
private VocabularyTerm relation;

@IndexedEmbedded(includePaths = {"curie", "name", "secondaryIdentifiers", "synonyms.name", "abbreviation",
"curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "abbreviation_keyword" })
"curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "abbreviation_keyword"})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToMany
@JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class })
@JsonView({View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class})
@JoinTable(
joinColumns = @JoinColumn(name = "diseaseannotation_id"),
inverseJoinColumns = @JoinColumn(name = "evidencecodes_id"),
Expand All @@ -107,16 +95,16 @@ public abstract class DiseaseAnnotation extends Annotation {
private List<ECOTerm> evidenceCodes;

@IndexedEmbedded(includePaths = {
"curie", "modEntityId", "modInternalId", "curie_keyword", "modEntityId_keyword", "modInternalId_keyword",
"geneSymbol.formatText", "geneSymbol.displayText", "geneSymbol.formatText_keyword", "geneSymbol.displayText_keyword",
"geneFullName.formatText", "geneFullName.displayText", "geneFullName.formatText_keyword", "geneFullName.displayText_keyword",
"geneSystematicName.formatText", "geneSystematicName.displayText", "geneSystematicName.formatText_keyword", "geneSystematicName.displayText_keyword",
"geneSynonyms.formatText", "geneSynonyms.displayText", "geneSynonyms.formatText_keyword", "geneSynonyms.displayText_keyword",
"geneSecondaryIds.secondaryId", "geneSecondaryIds.secondaryId_keyword", "name", "name_keyword", "symbol", "symbol_keyword"
"curie", "modEntityId", "modInternalId", "curie_keyword", "modEntityId_keyword", "modInternalId_keyword",
"geneSymbol.formatText", "geneSymbol.displayText", "geneSymbol.formatText_keyword", "geneSymbol.displayText_keyword",
"geneFullName.formatText", "geneFullName.displayText", "geneFullName.formatText_keyword", "geneFullName.displayText_keyword",
"geneSystematicName.formatText", "geneSystematicName.displayText", "geneSystematicName.formatText_keyword", "geneSystematicName.displayText_keyword",
"geneSynonyms.formatText", "geneSynonyms.displayText", "geneSynonyms.formatText_keyword", "geneSynonyms.displayText_keyword",
"geneSecondaryIds.secondaryId", "geneSecondaryIds.secondaryId_keyword", "name", "name_keyword", "symbol", "symbol_keyword"
})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToMany
@JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class })
@JsonView({View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class})
@JoinTable(
joinColumns = @JoinColumn(name = "diseaseannotation_id"),
inverseJoinColumns = @JoinColumn(name = "with_id"),
Expand All @@ -130,13 +118,13 @@ public abstract class DiseaseAnnotation extends Annotation {
@IndexedEmbedded(includePaths = {"name", "name_keyword"})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToOne
@JsonView({ View.FieldsOnly.class, View.ForPublic.class })
@JsonView({View.FieldsOnly.class, View.ForPublic.class})
private VocabularyTerm annotationType;

@IndexedEmbedded(includePaths = {"name", "name_keyword"})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToMany
@JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class })
@JsonView({View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class})
@JoinTable(
joinColumns = @JoinColumn(name = "diseaseannotation_id"),
inverseJoinColumns = @JoinColumn(name = "diseasequalifiers_id"),
Expand All @@ -150,27 +138,27 @@ public abstract class DiseaseAnnotation extends Annotation {
@IndexedEmbedded(includePaths = {"name", "name_keyword"})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToOne
@JsonView({ View.FieldsOnly.class, View.ForPublic.class })
@JsonView({View.FieldsOnly.class, View.ForPublic.class})
private VocabularyTerm geneticSex;

@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"})
"sourceOrganization.abbreviation_keyword", "sourceOrganization.fullName_keyword", "sourceOrganization.shortName_keyword", "crossReference.displayName_keyword", "crossReference.referencedCurie_keyword"})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToOne
@JsonView({ View.FieldsOnly.class, View.ForPublic.class })
@JsonView({View.FieldsOnly.class, View.ForPublic.class})
private DataProvider secondaryDataProvider;

@IndexedEmbedded(includePaths = {
"curie", "modEntityId", "modInternalId", "curie_keyword", "modEntityId_keyword", "modInternalId_keyword",
"geneSymbol.formatText", "geneSymbol.displayText", "geneSymbol.formatText_keyword", "geneSymbol.displayText_keyword",
"geneFullName.formatText", "geneFullName.displayText", "geneFullName.formatText_keyword", "geneFullName.displayText_keyword",
"geneSystematicName.formatText", "geneSystematicName.displayText", "geneSystematicName.formatText_keyword", "geneSystematicName.displayText_keyword",
"geneSynonyms.formatText", "geneSynonyms.displayText", "geneSynonyms.formatText_keyword", "geneSynonyms.displayText_keyword",
"geneSecondaryIds.secondaryId", "geneSecondaryIds.secondaryId_keyword", "name", "name_keyword", "symbol", "symbol_keyword"
"curie", "modEntityId", "modInternalId", "curie_keyword", "modEntityId_keyword", "modInternalId_keyword",
"geneSymbol.formatText", "geneSymbol.displayText", "geneSymbol.formatText_keyword", "geneSymbol.displayText_keyword",
"geneFullName.formatText", "geneFullName.displayText", "geneFullName.formatText_keyword", "geneFullName.displayText_keyword",
"geneSystematicName.formatText", "geneSystematicName.displayText", "geneSystematicName.formatText_keyword", "geneSystematicName.displayText_keyword",
"geneSynonyms.formatText", "geneSynonyms.displayText", "geneSynonyms.formatText_keyword", "geneSynonyms.displayText_keyword",
"geneSecondaryIds.secondaryId", "geneSecondaryIds.secondaryId_keyword", "name", "name_keyword", "symbol", "symbol_keyword"
})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToMany
@JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class })
@JsonView({View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class})
@JoinTable(
name = "diseaseannotation_modifiergene",
joinColumns = @JoinColumn(name = "diseaseannotation_id"),
Expand All @@ -183,15 +171,15 @@ public abstract class DiseaseAnnotation extends Annotation {
private List<Gene> diseaseGeneticModifierGenes;

@IndexedEmbedded(includePaths = {
"curie", "modEntityId", "modInternalId", "curie_keyword", "modEntityId_keyword", "modInternalId_keyword",
"alleleSymbol.formatText", "alleleSymbol.displayText", "alleleSymbol.formatText_keyword", "alleleSymbol.displayText_keyword",
"alleleFullName.formatText", "alleleFullName.displayText", "alleleFullName.formatText_keyword", "alleleFullName.displayText_keyword",
"alleleSynonyms.formatText", "alleleSynonyms.displayText", "alleleSynonyms.formatText_keyword", "alleleSynonyms.displayText_keyword",
"alleleSecondaryIds.secondaryId", "alleleSecondaryIds.secondaryId_keyword"
"curie", "modEntityId", "modInternalId", "curie_keyword", "modEntityId_keyword", "modInternalId_keyword",
"alleleSymbol.formatText", "alleleSymbol.displayText", "alleleSymbol.formatText_keyword", "alleleSymbol.displayText_keyword",
"alleleFullName.formatText", "alleleFullName.displayText", "alleleFullName.formatText_keyword", "alleleFullName.displayText_keyword",
"alleleSynonyms.formatText", "alleleSynonyms.displayText", "alleleSynonyms.formatText_keyword", "alleleSynonyms.displayText_keyword",
"alleleSecondaryIds.secondaryId", "alleleSecondaryIds.secondaryId_keyword"
})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToMany
@JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class })
@JsonView({View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class})
@JoinTable(
name = "diseaseannotation_modifierallele",
joinColumns = @JoinColumn(name = "diseaseannotation_id"),
Expand All @@ -206,7 +194,7 @@ public abstract class DiseaseAnnotation extends Annotation {
@IndexedEmbedded(includePaths = {"name", "name_keyword", "curie", "curie_keyword", "modEntityId", "modEntityId_keyword", "modInternalId", "modInternalId_keyword"})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToMany
@JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class })
@JsonView({View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class})
@JoinTable(
name = "diseaseannotation_modifieragm",
joinColumns = @JoinColumn(name = "diseaseannotation_id"),
Expand All @@ -221,7 +209,7 @@ public abstract class DiseaseAnnotation extends Annotation {
@IndexedEmbedded(includePaths = {"name", "name_keyword"})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToOne
@JsonView({ View.FieldsOnly.class, View.ForPublic.class })
@JsonView({View.FieldsOnly.class, View.ForPublic.class})
private VocabularyTerm diseaseGeneticModifierRelation;

@Transient
Expand All @@ -232,7 +220,7 @@ public abstract class DiseaseAnnotation extends Annotation {

@Transient
public abstract String getSubjectSpeciesName();

@Transient
public abstract String getSubjectIdentifier();

Expand All @@ -246,4 +234,21 @@ public String getDataProviderString() {
}
return builder.toString();
}

@Transient
public String getFullRelationString() {
if (relation == null) {
return null;
}
if (!negated) {
return relation.getName();
}

if (relation.getName().equals("is_model_of")) {
return "does_not_model";
}
return relation.getName().replaceFirst("_", "_not_");
}


}
Loading