From 7c5253c3503bf6e5ab64df4eeff7171af2783429 Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Wed, 27 Sep 2023 00:34:46 +0100 Subject: [PATCH 01/76] Initial commit of allele to gene association code --- .../constants/VocabularyConstants.java | 3 + .../AlleleGeneAssociationDAO.java | 15 ++++ .../curation_api/model/entities/Allele.java | 8 ++ .../AlleleGeneAssociation.java | 40 ++++++++++ .../AlleleGenomicEntityAssociation.java | 66 ++++++++++++++++ .../associations/EvidenceAssociationDTO.java | 24 ++++++ .../AlleleGeneAssociationDTO.java | 22 ++++++ .../AlleleGenomicEntityAssociationDTO.java | 36 +++++++++ .../EvidenceAssociationDTOValidator.java | 39 ++++++++++ .../AlleleGeneAssociationDTOValidator.java | 54 +++++++++++++ ...eGenomicEntityAssociationDTOValidator.java | 76 +++++++++++++++++++ .../curation_api/view/View.java | 3 + 12 files changed, 386 insertions(+) create mode 100644 src/main/java/org/alliancegenome/curation_api/dao/associations/alleleAssociations/AlleleGeneAssociationDAO.java create mode 100644 src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGeneAssociation.java create mode 100644 src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java create mode 100644 src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/EvidenceAssociationDTO.java create mode 100644 src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/alleleAssociations/AlleleGeneAssociationDTO.java create mode 100644 src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/alleleAssociations/AlleleGenomicEntityAssociationDTO.java create mode 100644 src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/EvidenceAssociationDTOValidator.java create mode 100644 src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java create mode 100644 src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGenomicEntityAssociationDTOValidator.java diff --git a/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java index bbbe01b05..1c433f23d 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java @@ -22,6 +22,8 @@ public final class VocabularyConstants { public static final String GERMLINE_TRANSMISSION_STATUS_VOCABULARY = "allele_germline_transmission_status"; public static final String ALLELE_NOMENCLATURE_EVENT_VOCABULARY = "allele_nomenclature_event"; public static final String ALLELE_NOTE_TYPES_VOCABULARY = "allele_note_type"; + public static final String ALLELE_RELATION_VOCABULARY = "allele_relation"; + public static final String ALLELE_GENOMIC_ENTITY_NOTE_TYPE_VOCABULARY = "allele_genomic_entity_note_type"; public static final String FULL_NAME_TYPE_TERM_SET = "full_name_type"; public static final String SYSTEMATIC_NAME_TYPE_TERM_SET = "systematic_name_type"; @@ -38,5 +40,6 @@ public final class VocabularyConstants { public static final String ORTHOLOGY_PREDICTION_METHOD_VOCABULARY = "ortho_prediction_method"; public static final String CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY = "construct_component_note_type"; + } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/dao/associations/alleleAssociations/AlleleGeneAssociationDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/associations/alleleAssociations/AlleleGeneAssociationDAO.java new file mode 100644 index 000000000..523c3a54a --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/dao/associations/alleleAssociations/AlleleGeneAssociationDAO.java @@ -0,0 +1,15 @@ +package org.alliancegenome.curation_api.dao.associations.alleleAssociations; + +import javax.enterprise.context.ApplicationScoped; + +import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGeneAssociation; + +@ApplicationScoped +public class AlleleGeneAssociationDAO extends BaseSQLDAO { + + protected AlleleGeneAssociationDAO() { + super(AlleleGeneAssociation.class); + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Allele.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Allele.java index 0d78f7f1f..8eda787cf 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Allele.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Allele.java @@ -15,6 +15,7 @@ import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.bridges.BooleanAndNullValueBridge; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGeneAssociation; import org.alliancegenome.curation_api.model.entities.slotAnnotations.alleleSlotAnnotations.AlleleDatabaseStatusSlotAnnotation; import org.alliancegenome.curation_api.model.entities.slotAnnotations.alleleSlotAnnotations.AlleleFullNameSlotAnnotation; import org.alliancegenome.curation_api.model.entities.slotAnnotations.alleleSlotAnnotations.AlleleFunctionalImpactSlotAnnotation; @@ -142,6 +143,13 @@ public class Allele extends GenomicEntity { @JsonView({ View.FieldsAndLists.class, View.AlleleView.class }) private List alleleNomenclatureEvents; + @IndexedEmbedded(includePaths = {"object.curie", "object.geneSymbol.displayText", "object.geneSymbol.formatText", "object.geneFullName.displayText", "object.geneFullName.formatText", + "object.curie", "object.geneSymbol.displayText_keyword", "object.geneSymbol.formatText_keyword", "object.geneFullName.displayText_keyword", "object.geneFullName.formatText_keyword"}) + @OneToMany(mappedBy = "subject", cascade = CascadeType.ALL) + @JsonManagedReference + @JsonView({ View.FieldsAndLists.class, View.AlleleDetailView.class }) + private List alleleGeneAssociations; + @IndexedEmbedded(includePaths = {"freeText", "freeText_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @OneToMany diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGeneAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGeneAssociation.java new file mode 100644 index 000000000..e7ff5b2bc --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGeneAssociation.java @@ -0,0 +1,40 @@ +package org.alliancegenome.curation_api.model.entities.associations.alleleAssociations; + +import javax.persistence.Entity; +import javax.persistence.Index; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.Gene; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.envers.Audited; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; + +import com.fasterxml.jackson.annotation.JsonView; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Audited +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AlleleGenomicEntityAssociation.class }) +@Schema(name = "AlleleGeneAssociation", description = "POJO representing an association between an allele and a gene") +@Table(indexes = { @Index(name = "allelegeneassociation_singleallele_curie_index", columnList = "singleallele_curie")}) +public class AlleleGeneAssociation extends AlleleGenomicEntityAssociation { + + @IndexedEmbedded(includePaths = {"curie", "geneSymbol.displayText", "geneSymbol.formatText", "geneFullName.displayText", "geneFullName.formatText", + "curie", "geneSymbol.displayText_keyword", "geneSymbol.formatText_keyword", "geneFullName.displayText_keyword", "geneFullName.formatText_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @OneToOne + @JsonView({ View.FieldsAndLists.class, View.AlleleDetailView.class }) + private Gene object; +} 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 new file mode 100644 index 000000000..cc1b08588 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java @@ -0,0 +1,66 @@ +package org.alliancegenome.curation_api.model.entities.associations.alleleAssociations; + +import javax.persistence.Entity; +import javax.persistence.Index; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.Allele; +import org.alliancegenome.curation_api.model.entities.EvidenceAssociation; +import org.alliancegenome.curation_api.model.entities.Note; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +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.envers.Audited; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; + +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonView; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Audited +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociation.class }) +@Schema(name = "AlleleGenomicEntityAssociation", description = "POJO representing an association between an allele and a genomic entity") +@Table(indexes = { + @Index(name = "allelegenomicentity_singleallele_curie_index", columnList = "singleallele_curie") +}) +public class AlleleGenomicEntityAssociation extends EvidenceAssociation { + + @ManyToOne + @JsonBackReference + @Fetch(FetchMode.JOIN) + private Allele subject; + + @IndexedEmbedded(includeDepth = 1) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private VocabularyTerm relation; + + @IndexedEmbedded(includeDepth = 1) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private ECOTerm evidenceCode; + + @IndexedEmbedded(includeDepth = 1) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToMany + @JsonView({ View.FieldsOnly.class }) + private Note relatedNote; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/EvidenceAssociationDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/EvidenceAssociationDTO.java new file mode 100644 index 000000000..776ea6252 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/EvidenceAssociationDTO.java @@ -0,0 +1,24 @@ +package org.alliancegenome.curation_api.model.ingest.dto.associations; + +import java.util.List; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.ingest.dto.base.AuditedObjectDTO; +import org.alliancegenome.curation_api.view.View; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonView; + +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +@AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObjectDTO.class }) +public class EvidenceAssociationDTO extends AuditedObjectDTO { + + @JsonView({ View.FieldsAndLists.class }) + @JsonProperty("evidence_curies") + private List evidenceCuries; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/alleleAssociations/AlleleGeneAssociationDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/alleleAssociations/AlleleGeneAssociationDTO.java new file mode 100644 index 000000000..1fc4b00cf --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/alleleAssociations/AlleleGeneAssociationDTO.java @@ -0,0 +1,22 @@ +package org.alliancegenome.curation_api.model.ingest.dto.associations.alleleAssociations; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.view.View; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonView; + +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +@AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AlleleGenomicEntityAssociationDTO.class }) +public class AlleleGeneAssociationDTO extends AlleleGenomicEntityAssociationDTO { + + @JsonView({ View.FieldsOnly.class }) + @JsonProperty("gene_curie") + private String geneCurie; + +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/alleleAssociations/AlleleGenomicEntityAssociationDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/alleleAssociations/AlleleGenomicEntityAssociationDTO.java new file mode 100644 index 000000000..7778d2ff9 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/alleleAssociations/AlleleGenomicEntityAssociationDTO.java @@ -0,0 +1,36 @@ +package org.alliancegenome.curation_api.model.ingest.dto.associations.alleleAssociations; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.ingest.dto.NoteDTO; +import org.alliancegenome.curation_api.model.ingest.dto.associations.EvidenceAssociationDTO; +import org.alliancegenome.curation_api.view.View; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonView; + +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +@AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociationDTO.class, NoteDTO.class }) +public class AlleleGenomicEntityAssociationDTO extends EvidenceAssociationDTO { + + @JsonView({ View.FieldsOnly.class }) + @JsonProperty("allele_curie") + private String alleleCurie; + + @JsonView({ View.FieldsOnly.class }) + @JsonProperty("relation_name") + private String relationName; + + @JsonView({ View.FieldsOnly.class }) + @JsonProperty("evidence_code_curie") + private String evidenceCodeCurie; + + @JsonView({ View.FieldsOnly.class }) + @JsonProperty("note_dto") + private NoteDTO noteDto; + +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/EvidenceAssociationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/EvidenceAssociationDTOValidator.java new file mode 100644 index 000000000..464fecd48 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/EvidenceAssociationDTOValidator.java @@ -0,0 +1,39 @@ +package org.alliancegenome.curation_api.services.validation.dto.associations; + +import java.util.ArrayList; +import java.util.List; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; + +import org.alliancegenome.curation_api.dao.NoteDAO; +import org.alliancegenome.curation_api.model.entities.EvidenceAssociation; +import org.alliancegenome.curation_api.model.entities.InformationContentEntity; +import org.alliancegenome.curation_api.model.ingest.dto.associations.EvidenceAssociationDTO; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.validation.dto.base.BaseDTOValidator; +import org.apache.commons.collections.CollectionUtils; + +@RequestScoped +public class EvidenceAssociationDTOValidator extends BaseDTOValidator { + + @Inject + NoteDAO noteDAO; + + + public ObjectResponse validateEvidenceAssociationDTO(E association, D dto) { + ObjectResponse assocResponse = validateAuditedObjectDTO(association, dto); + association = assocResponse.getEntity(); + + if (CollectionUtils.isNotEmpty(dto.getEvidenceCuries())) { + List evidence = new ArrayList<>(); + // TODO: validate InformationContentEntity stuff here + } else { + association.setEvidence(null); + } + + assocResponse.setEntity(association); + + return assocResponse; + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java new file mode 100644 index 000000000..e8c5913fb --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java @@ -0,0 +1,54 @@ +package org.alliancegenome.curation_api.services.validation.dto.associations.alleleAssociations; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; + +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.dao.GeneDAO; +import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.model.entities.Gene; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGeneAssociation; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGenomicEntityAssociation; +import org.alliancegenome.curation_api.model.ingest.dto.associations.alleleAssociations.AlleleGeneAssociationDTO; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.VocabularyTermService; +import org.apache.commons.lang3.StringUtils; + +@RequestScoped +public class AlleleGeneAssociationDTOValidator extends AlleleGenomicEntityAssociationDTOValidator { + + @Inject + GeneDAO geneDAO; + @Inject + VocabularyTermService vocabularyTermService; + + public AlleleGenomicEntityAssociation validateAlleleGeneAssociationDTO(AlleleGeneAssociation association, AlleleGeneAssociationDTO dto) throws ObjectValidationException { + ObjectResponse assocResponse = validateAlleleGenomicEntityAssociationDTO(association, dto); + association = (AlleleGeneAssociation) assocResponse.getEntity(); + + if (StringUtils.isBlank(dto.getGeneCurie())) { + assocResponse.addErrorMessage("gene_curie", ValidationConstants.REQUIRED_MESSAGE); + } else { + Gene gene = geneDAO.find(dto.getGeneCurie()); + if (gene == null) { + assocResponse.addErrorMessage("gene_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getGeneCurie() + ")"); + } + } + + if (StringUtils.isNotEmpty(dto.getRelationName())) { + VocabularyTerm relation = vocabularyTermService.getTermInVocabulary(VocabularyConstants.ALLELE_RELATION_VOCABULARY, dto.getRelationName()).getEntity(); + if (relation == null) + assocResponse.addErrorMessage("relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getRelationName() + ")"); + association.setRelation(relation); + } else { + assocResponse.addErrorMessage("relation_name", ValidationConstants.REQUIRED_MESSAGE); + } + + if (assocResponse.hasErrors()) + throw new ObjectValidationException(dto, assocResponse.errorMessagesString()); + + return assocResponse.getEntity(); + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGenomicEntityAssociationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGenomicEntityAssociationDTOValidator.java new file mode 100644 index 000000000..b9e64285b --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGenomicEntityAssociationDTOValidator.java @@ -0,0 +1,76 @@ +package org.alliancegenome.curation_api.services.validation.dto.associations.alleleAssociations; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; + +import org.alliancegenome.curation_api.constants.OntologyConstants; +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.dao.AlleleDAO; +import org.alliancegenome.curation_api.dao.NoteDAO; +import org.alliancegenome.curation_api.model.entities.Allele; +import org.alliancegenome.curation_api.model.entities.Note; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGenomicEntityAssociation; +import org.alliancegenome.curation_api.model.entities.ontology.ECOTerm; +import org.alliancegenome.curation_api.model.ingest.dto.associations.alleleAssociations.AlleleGenomicEntityAssociationDTO; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.ontology.EcoTermService; +import org.alliancegenome.curation_api.services.validation.dto.NoteDTOValidator; +import org.alliancegenome.curation_api.services.validation.dto.associations.EvidenceAssociationDTOValidator; +import org.apache.commons.lang3.StringUtils; + +@RequestScoped +public class AlleleGenomicEntityAssociationDTOValidator extends EvidenceAssociationDTOValidator { + + @Inject + AlleleDAO alleleDAO; + @Inject + NoteDAO noteDAO; + @Inject + NoteDTOValidator noteDtoValidator; + @Inject + EcoTermService ecoTermService; + + public ObjectResponse validateAlleleGenomicEntityAssociationDTO(E association, D dto) { + ObjectResponse assocResponse = validateEvidenceAssociationDTO(association, dto); + association = assocResponse.getEntity(); + + if (StringUtils.isBlank(dto.getAlleleCurie())) { + assocResponse.addErrorMessage("allele_curie", ValidationConstants.REQUIRED_MESSAGE); + } else { + Allele allele = alleleDAO.find(dto.getAlleleCurie()); + if (allele == null) { + assocResponse.addErrorMessage("allele_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getAlleleCurie() + ")"); + } + } + + if (StringUtils.isNotBlank(dto.getEvidenceCodeCurie())) { + ECOTerm ecoTerm = ecoTermService.findByCurieOrSecondaryId(dto.getEvidenceCodeCurie()); + if (ecoTerm == null) { + assocResponse.addErrorMessage("evidence_code_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getEvidenceCodeCurie() + ")"); + } else if (!ecoTerm.getSubsets().contains(OntologyConstants.AGR_ECO_TERM_SUBSET)) { + assocResponse.addErrorMessage("evidence_code_curie", ValidationConstants.UNSUPPORTED_MESSAGE + " (" + dto.getEvidenceCodeCurie() + ")"); + } else { + association.setEvidenceCode(ecoTerm); + } + } else { + association.setEvidenceCode(null); + } + + if (association.getRelatedNote() != null) { + Long noteIdToDelete = association.getRelatedNote().getId(); + association.setRelatedNote(null); + noteDAO.remove(noteIdToDelete); + } + if (dto.getNoteDto() != null) { + ObjectResponse noteResponse = noteDtoValidator.validateNoteDTO(dto.getNoteDto(), VocabularyConstants.ALLELE_GENOMIC_ENTITY_NOTE_TYPE_VOCABULARY); + if (noteResponse.hasErrors()) { + assocResponse.addErrorMessage("note_dto", noteResponse.errorMessagesString()); + } else { + association.setRelatedNote(noteDAO.persist(noteResponse.getEntity())); + } + } + + return assocResponse; + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/view/View.java b/src/main/java/org/alliancegenome/curation_api/view/View.java index 37d23461a..122e00592 100644 --- a/src/main/java/org/alliancegenome/curation_api/view/View.java +++ b/src/main/java/org/alliancegenome/curation_api/view/View.java @@ -55,6 +55,9 @@ public static class DiseaseAnnotationCreate extends DiseaseAnnotation { public static class AlleleView extends FieldsOnly { } + + public static class AlleleDetailView extends AlleleView { + } public static class AlleleUpdate extends AlleleView { } From 30a09f8611a42667e37f3a9a139f6a0a2791ca5e Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Wed, 27 Sep 2023 13:29:41 +0100 Subject: [PATCH 02/76] Start of validation code --- .../AlleleGeneAssociationService.java | 42 ++++++ .../EvidenceAssociationValidator.java | 60 +++++++++ .../AlleleGeneAssociationValidator.java | 108 ++++++++++++++++ ...leleGenomicEntityAssociationValidator.java | 121 ++++++++++++++++++ .../AlleleGeneAssociationDTOValidator.java | 43 +++++-- 5 files changed, 364 insertions(+), 10 deletions(-) create mode 100644 src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java create mode 100644 src/main/java/org/alliancegenome/curation_api/services/validation/associations/EvidenceAssociationValidator.java create mode 100644 src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGeneAssociationValidator.java create mode 100644 src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGenomicEntityAssociationValidator.java diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java new file mode 100644 index 000000000..f105ef686 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java @@ -0,0 +1,42 @@ +package org.alliancegenome.curation_api.services.associations.alleleAssociations; + +import javax.annotation.PostConstruct; +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.transaction.Transactional; + +import org.alliancegenome.curation_api.dao.associations.alleleAssociations.AlleleGeneAssociationDAO; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGeneAssociation; +import org.alliancegenome.curation_api.model.entities.slotAnnotations.alleleSlotAnnotations.AlleleDatabaseStatusSlotAnnotation; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; +import org.alliancegenome.curation_api.services.validation.associations.alleleAssociations.AlleleGeneAssociationValidator; + +@RequestScoped +public class AlleleGeneAssociationService extends BaseEntityCrudService { + + @Inject + AlleleGeneAssociationDAO alleleGeneAssociationDAO; + @Inject + AlleleGeneAssociationValidator alleleGeneAssociationValidator; + + @Override + @PostConstruct + protected void init() { + setSQLDao(alleleGeneAssociationDAO); + } + + @Transactional + public ObjectResponse upsert(AlleleGeneAssociation uiEntity) { + AlleleGeneAssociation dbEntity = alleleGeneAssociationValidator.validateAlleleGeneAssociation(uiEntity, true, true); + if (dbEntity == null) + return null; + return new ObjectResponse(alleleGeneAssociationDAO.persist(dbEntity)); + } + + public ObjectResponse validate(AlleleGeneAssociation uiEntity) { + AlleleGeneAssociation aga = alleleGeneAssociationValidator.validateAlleleGeneAssociation(uiEntity, true, false); + return new ObjectResponse(aga); + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/associations/EvidenceAssociationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/EvidenceAssociationValidator.java new file mode 100644 index 000000000..9eb71ab98 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/EvidenceAssociationValidator.java @@ -0,0 +1,60 @@ +package org.alliancegenome.curation_api.services.validation.associations; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.inject.Inject; + +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.dao.AnnotationDAO; +import org.alliancegenome.curation_api.dao.ConditionRelationDAO; +import org.alliancegenome.curation_api.dao.NoteDAO; +import org.alliancegenome.curation_api.model.entities.Annotation; +import org.alliancegenome.curation_api.model.entities.ConditionRelation; +import org.alliancegenome.curation_api.model.entities.DataProvider; +import org.alliancegenome.curation_api.model.entities.EvidenceAssociation; +import org.alliancegenome.curation_api.model.entities.InformationContentEntity; +import org.alliancegenome.curation_api.model.entities.Note; +import org.alliancegenome.curation_api.model.entities.Reference; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.response.SearchResponse; +import org.alliancegenome.curation_api.services.DataProviderService; +import org.alliancegenome.curation_api.services.helpers.notes.NoteIdentityHelper; +import org.alliancegenome.curation_api.services.validation.AuditedObjectValidator; +import org.alliancegenome.curation_api.services.validation.ConditionRelationValidator; +import org.alliancegenome.curation_api.services.validation.DataProviderValidator; +import org.alliancegenome.curation_api.services.validation.NoteValidator; +import org.alliancegenome.curation_api.services.validation.ReferenceValidator; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.ListUtils; +import org.apache.commons.lang3.StringUtils; + +public class EvidenceAssociationValidator extends AuditedObjectValidator { + + public List validateEvidence(EvidenceAssociation uiEntity, EvidenceAssociation dbEntity) { + String field = "evidence"; + if (CollectionUtils.isEmpty(uiEntity.getEvidence())) + return null; + + List evidence = new ArrayList<>(); + // TODO: do information content entity validation here + + return evidence; + } + + public EvidenceAssociation validateEvidenceAssociationFields(EvidenceAssociation uiEntity, EvidenceAssociation dbEntity) { + Boolean newEntity = false; + if (dbEntity.getId() == null) + newEntity = true; + dbEntity = validateAuditedObjectFields(uiEntity, dbEntity, newEntity); + + List evidence = validateEvidence(uiEntity, dbEntity); + dbEntity.setEvidence(evidence); + + return dbEntity; + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGeneAssociationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGeneAssociationValidator.java new file mode 100644 index 000000000..080e16651 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGeneAssociationValidator.java @@ -0,0 +1,108 @@ +package org.alliancegenome.curation_api.services.validation.associations.alleleAssociations; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; + +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.dao.GeneDAO; +import org.alliancegenome.curation_api.dao.associations.alleleAssociations.AlleleGeneAssociationDAO; +import org.alliancegenome.curation_api.exceptions.ApiErrorException; +import org.alliancegenome.curation_api.model.entities.AffectedGenomicModel; +import org.alliancegenome.curation_api.model.entities.Gene; +import org.alliancegenome.curation_api.model.entities.GeneDiseaseAnnotation; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGeneAssociation; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.VocabularyTermService; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; + +@RequestScoped +public class AlleleGeneAssociationValidator extends AlleleGenomicEntityAssociationValidator { + + @Inject + GeneDAO geneDAO; + @Inject + AlleleGeneAssociationDAO alleleGeneAssociationDAO; + @Inject + VocabularyTermService vocabularyTermService; + + private String errorMessage; + + public AlleleGeneAssociation validateAlleleGeneAssociation(AlleleGeneAssociation uiEntity, Boolean throwError, Boolean validateAllele) { + response = new ObjectResponse<>(uiEntity); + errorMessage = "Could not create/update Allele Gene Association: [" + uiEntity.getId() + "]"; + + Long id = uiEntity.getId(); + AlleleGeneAssociation dbEntity = null; + if (id != null) { + dbEntity = alleleGeneAssociationDAO.find(id); + if (dbEntity == null) { + addMessageResponse("Could not find Allele Gene Association with ID: [" + id + "]"); + throw new ApiErrorException(response); + } + } else { + dbEntity = new AlleleGeneAssociation(); + } + + dbEntity = (AlleleGeneAssociation) validateAlleleGenomicEntityAssociationFields(uiEntity, dbEntity, validateAllele); + + Gene object = validateObject(uiEntity, dbEntity); + dbEntity.setObject(object); + + VocabularyTerm relation = validateRelation(uiEntity, dbEntity); + dbEntity.setRelation(relation); + + + if (response.hasErrors()) { + response.setErrorMessage(errorMessage); + throw new ApiErrorException(response); + } + + return dbEntity; + } + + private Gene validateObject(AlleleGeneAssociation uiEntity, AlleleGeneAssociation dbEntity) { + if (ObjectUtils.isEmpty(uiEntity.getObject()) || StringUtils.isBlank(uiEntity.getObject().getCurie())) { + addMessageResponse("object", ValidationConstants.REQUIRED_MESSAGE); + return null; + } + + Gene objectEntity = geneDAO.find(uiEntity.getObject().getCurie()); + if (objectEntity == null) { + addMessageResponse("object", ValidationConstants.INVALID_MESSAGE); + return null; + } + + if (objectEntity.getObsolete() && (dbEntity.getObject() == null || !objectEntity.getCurie().equals(dbEntity.getObject().getCurie()))) { + addMessageResponse("object", ValidationConstants.OBSOLETE_MESSAGE); + return null; + } + + return objectEntity; + + } + + private VocabularyTerm validateRelation(AlleleGeneAssociation uiEntity, AlleleGeneAssociation dbEntity) { + String field = "relation"; + if (uiEntity.getRelation() == null) { + addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); + return null; + } + + VocabularyTerm relation = vocabularyTermService.getTermInVocabulary(VocabularyConstants.ALLELE_RELATION_VOCABULARY, uiEntity.getRelation().getName()).getEntity(); + + if (relation == null) { + addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); + return null; + } + + if (relation.getObsolete() && (dbEntity.getRelation() == null || !relation.getName().equals(dbEntity.getRelation().getName()))) { + addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); + return null; + } + + return relation; + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGenomicEntityAssociationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGenomicEntityAssociationValidator.java new file mode 100644 index 000000000..8d7710cc8 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleGenomicEntityAssociationValidator.java @@ -0,0 +1,121 @@ +package org.alliancegenome.curation_api.services.validation.associations.alleleAssociations; + +import java.util.Objects; + +import javax.inject.Inject; + +import org.alliancegenome.curation_api.constants.OntologyConstants; +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.dao.AlleleDAO; +import org.alliancegenome.curation_api.dao.NoteDAO; +import org.alliancegenome.curation_api.dao.ontology.EcoTermDAO; +import org.alliancegenome.curation_api.model.entities.Allele; +import org.alliancegenome.curation_api.model.entities.Note; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGenomicEntityAssociation; +import org.alliancegenome.curation_api.model.entities.ontology.ECOTerm; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.validation.NoteValidator; +import org.alliancegenome.curation_api.services.validation.associations.EvidenceAssociationValidator; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; + +public class AlleleGenomicEntityAssociationValidator extends EvidenceAssociationValidator { + + @Inject + NoteValidator noteValidator; + @Inject + NoteDAO noteDAO; + @Inject + EcoTermDAO ecoTermDAO; + @Inject + AlleleDAO alleleDAO; + + public ECOTerm validateEvidenceCode(AlleleGenomicEntityAssociation uiEntity, AlleleGenomicEntityAssociation dbEntity) { + String field = "evidenceCode"; + if (uiEntity.getEvidenceCode() == null) + return null; + + ECOTerm evidenceCode = ecoTermDAO.find(uiEntity.getEvidenceCode().getCurie()); + if (evidenceCode == null) { + addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); + return null; + } + if (evidenceCode.getObsolete() && (dbEntity.getEvidenceCode() == null || !dbEntity.getEvidenceCode().getCurie().equals(evidenceCode.getCurie()))) { + addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); + return null; + } + if (!evidenceCode.getSubsets().contains(OntologyConstants.AGR_ECO_TERM_SUBSET)) { + addMessageResponse(field, ValidationConstants.UNSUPPORTED_MESSAGE); + return null; + } + + return evidenceCode; + } + + public Note validateRelatedNote(AlleleGenomicEntityAssociation uiEntity, AlleleGenomicEntityAssociation dbEntity) { + String field = "relatedNote"; + + Note note = null; + if (uiEntity.getRelatedNote() != null) { + ObjectResponse noteResponse = noteValidator.validateNote(uiEntity.getRelatedNote(), VocabularyConstants.ALLELE_GENOMIC_ENTITY_NOTE_TYPE_VOCABULARY); + if (noteResponse.getEntity() == null) { + addMessageResponse(field, noteResponse.errorMessagesString()); + return null; + } + note = noteResponse.getEntity(); + if (note.getId() == null) + note = noteDAO.persist(note); + } + + Long previousNoteId = null; + if (dbEntity.getRelatedNote() != null) + previousNoteId = dbEntity.getRelatedNote().getId(); + + dbEntity.setRelatedNote(null); + if (previousNoteId != null && !Objects.equals(note.getId(), previousNoteId)) + noteDAO.remove(previousNoteId); + + return note; + } + + private Allele validateSubject(AlleleGenomicEntityAssociation uiEntity, AlleleGenomicEntityAssociation dbEntity) { + String field = "subject"; + if (ObjectUtils.isEmpty(uiEntity.getSubject()) || StringUtils.isBlank(uiEntity.getSubject().getCurie())) { + addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); + return null; + } + + Allele subjectEntity = alleleDAO.find(uiEntity.getSubject().getCurie()); + if (subjectEntity == null) { + addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); + return null; + } + + if (subjectEntity.getObsolete() && (dbEntity.getSubject() == null || !subjectEntity.getCurie().equals(dbEntity.getSubject().getCurie()))) { + addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); + return null; + } + + return subjectEntity; + + } + + public AlleleGenomicEntityAssociation validateAlleleGenomicEntityAssociationFields(AlleleGenomicEntityAssociation uiEntity, AlleleGenomicEntityAssociation dbEntity, Boolean validateAllele) { + + dbEntity = (AlleleGenomicEntityAssociation) validateEvidenceAssociationFields(uiEntity, dbEntity); + + if (validateAllele) { + Allele subject = validateSubject(uiEntity, dbEntity); + dbEntity.setSubject(subject); + } + + ECOTerm evidenceCode = validateEvidenceCode(uiEntity, dbEntity); + dbEntity.setEvidenceCode(evidenceCode); + + Note relatedNote = validateRelatedNote(uiEntity, dbEntity); + dbEntity.setRelatedNote(relatedNote); + + return dbEntity; + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java index e8c5913fb..7e7e988b6 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java @@ -1,11 +1,14 @@ package org.alliancegenome.curation_api.services.validation.dto.associations.alleleAssociations; +import java.util.HashMap; + import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import org.alliancegenome.curation_api.constants.ValidationConstants; import org.alliancegenome.curation_api.constants.VocabularyConstants; import org.alliancegenome.curation_api.dao.GeneDAO; +import org.alliancegenome.curation_api.dao.associations.alleleAssociations.AlleleGeneAssociationDAO; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.VocabularyTerm; @@ -13,42 +16,62 @@ import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGenomicEntityAssociation; import org.alliancegenome.curation_api.model.ingest.dto.associations.alleleAssociations.AlleleGeneAssociationDTO; import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.response.SearchResponse; import org.alliancegenome.curation_api.services.VocabularyTermService; import org.apache.commons.lang3.StringUtils; @RequestScoped public class AlleleGeneAssociationDTOValidator extends AlleleGenomicEntityAssociationDTOValidator { + @Inject + AlleleGeneAssociationDAO alleleGeneAssociationDAO; @Inject GeneDAO geneDAO; @Inject VocabularyTermService vocabularyTermService; - public AlleleGenomicEntityAssociation validateAlleleGeneAssociationDTO(AlleleGeneAssociation association, AlleleGeneAssociationDTO dto) throws ObjectValidationException { - ObjectResponse assocResponse = validateAlleleGenomicEntityAssociationDTO(association, dto); - association = (AlleleGeneAssociation) assocResponse.getEntity(); + public AlleleGenomicEntityAssociation validateAlleleGeneAssociationDTO(AlleleGeneAssociationDTO dto) throws ObjectValidationException { + ObjectResponse agaResponse = new ObjectResponse(); + + AlleleGeneAssociation association = null; + if (StringUtils.isNotBlank(dto.getAlleleCurie()) && StringUtils.isNotBlank(dto.getGeneCurie()) && StringUtils.isNotBlank(dto.getRelationName())) { + HashMap params = new HashMap<>(); + params.put("subject.curie", dto.getAlleleCurie()); + params.put("relation.name", dto.getRelationName()); + params.put("object.curie", dto.getGeneCurie()); + + SearchResponse searchResponse = alleleGeneAssociationDAO.findByParams(params); + if (searchResponse != null && searchResponse.getResults().size() == 1) + association = searchResponse.getSingleResult(); + } + if (association == null) + association = new AlleleGeneAssociation(); + + ObjectResponse ageaResponse = validateAlleleGenomicEntityAssociationDTO(association, dto); + agaResponse.addErrorMessages(ageaResponse.getErrorMessages()); + association = (AlleleGeneAssociation) ageaResponse.getEntity(); if (StringUtils.isBlank(dto.getGeneCurie())) { - assocResponse.addErrorMessage("gene_curie", ValidationConstants.REQUIRED_MESSAGE); + agaResponse.addErrorMessage("gene_curie", ValidationConstants.REQUIRED_MESSAGE); } else { Gene gene = geneDAO.find(dto.getGeneCurie()); if (gene == null) { - assocResponse.addErrorMessage("gene_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getGeneCurie() + ")"); + agaResponse.addErrorMessage("gene_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getGeneCurie() + ")"); } } if (StringUtils.isNotEmpty(dto.getRelationName())) { VocabularyTerm relation = vocabularyTermService.getTermInVocabulary(VocabularyConstants.ALLELE_RELATION_VOCABULARY, dto.getRelationName()).getEntity(); if (relation == null) - assocResponse.addErrorMessage("relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getRelationName() + ")"); + agaResponse.addErrorMessage("relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getRelationName() + ")"); association.setRelation(relation); } else { - assocResponse.addErrorMessage("relation_name", ValidationConstants.REQUIRED_MESSAGE); + agaResponse.addErrorMessage("relation_name", ValidationConstants.REQUIRED_MESSAGE); } - if (assocResponse.hasErrors()) - throw new ObjectValidationException(dto, assocResponse.errorMessagesString()); + if (agaResponse.hasErrors()) + throw new ObjectValidationException(dto, agaResponse.errorMessagesString()); - return assocResponse.getEntity(); + return agaResponse.getEntity(); } } From 4f8e9a58d943159cbd1280fb7a3ebba79cca48e6 Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Wed, 4 Oct 2023 11:39:31 +0100 Subject: [PATCH 03/76] Backend changes to consolidate note types --- .../constants/VocabularyConstants.java | 11 +- .../services/validation/AlleleValidator.java | 2 +- .../validation/AnnotationValidator.java | 8 +- .../DiseaseAnnotationValidator.java | 2 +- .../services/validation/NoteValidator.java | 14 +-- .../validation/dto/AlleleDTOValidator.java | 2 +- .../dto/AnnotationDTOValidator.java | 4 +- .../dto/DiseaseAnnotationDTOValidator.java | 2 +- .../validation/dto/NoteDTOValidator.java | 4 +- ...ctComponentSlotAnnotationDTOValidator.java | 2 +- ...tructComponentSlotAnnotationValidator.java | 2 +- .../v0.27.0.4__note_vocabulary_refactor.sql | 107 ++++++++++++++++++ .../curation_api/base/BaseITCase.java | 4 +- .../bulkupload/ConstructBulkUploadITCase.java | 6 +- .../DiseaseAnnotationBulkUploadITCase.java | 7 +- .../crud/controllers/AlleleITCase.java | 4 +- .../crud/controllers/ConstructITCase.java | 6 +- .../controllers/DiseaseAnnotationITCase.java | 10 +- .../crud/controllers/GeneITCase.java | 6 +- 19 files changed, 157 insertions(+), 46 deletions(-) create mode 100644 src/main/resources/db/migration/v0.27.0.4__note_vocabulary_refactor.sql diff --git a/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java index 9e70eaddf..3cf24cdaa 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java @@ -8,7 +8,6 @@ public final class VocabularyConstants { public static final String GENETIC_SEX_VOCABULARY = "genetic_sex"; public static final String CONDITION_RELATION_TYPE_VOCABULARY = "condition_relation"; public static final String DISEASE_RELATION_VOCABULARY = "disease_relation"; - public static final String DISEASE_ANNOTATION_NOTE_TYPES_VOCABULARY = "da_note_type"; public static final String ECO_TERM_ABBREVIATION_VOCABULARY = "agr_da_eco_term"; public static final String GENE_DISEASE_RELATION_VOCABULARY_TERM_SET = "gene_disease_relation"; @@ -21,8 +20,7 @@ public final class VocabularyConstants { public static final String ALLELE_COLLECTION_VOCABULARY = "allele_collection"; public static final String GERMLINE_TRANSMISSION_STATUS_VOCABULARY = "allele_germline_transmission_status"; public static final String ALLELE_NOMENCLATURE_EVENT_VOCABULARY = "allele_nomenclature_event"; - public static final String ALLELE_NOTE_TYPES_VOCABULARY = "allele_note_type"; - + public static final String FULL_NAME_TYPE_TERM_SET = "full_name_type"; public static final String SYSTEMATIC_NAME_TYPE_TERM_SET = "systematic_name_type"; public static final String SYMBOL_NAME_TYPE_TERM_SET = "symbol_name_type"; @@ -38,6 +36,11 @@ public final class VocabularyConstants { public static final String ORTHOLOGY_PREDICTION_METHOD_VOCABULARY = "ortho_prediction_method"; public static final String CONSTRUCT_GENOMIC_ENTITY_RELATION_VOCABULARY = "construct_genomic_entity_predicate"; - public static final String CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY = "construct_component_note_type"; + + public static final String NOTE_TYPE_VOCABULARY = "note_type"; + public static final String ALLELE_NOTE_TYPES_VOCABULARY_TERM_SET = "allele_note_type"; + public static final String DISEASE_ANNOTATION_NOTE_TYPES_VOCABULARY_TERM_SET = "da_note_type"; + public static final String GENE_NOTE_TYPES_VOCABULARY_TERM_SET = "gene_note_type"; + public static final String CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY_TERM_SET = "construct_component_note_type"; } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/AlleleValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/AlleleValidator.java index 67db848e1..7ca540df0 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/AlleleValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/AlleleValidator.java @@ -345,7 +345,7 @@ public List validateRelatedNotes(Allele uiEntity, Allele dbEntity) { Set validatedNoteIdentities = new HashSet<>(); if (CollectionUtils.isNotEmpty(uiEntity.getRelatedNotes())) { for (Note note : uiEntity.getRelatedNotes()) { - ObjectResponse noteResponse = noteValidator.validateNote(note, VocabularyConstants.ALLELE_NOTE_TYPES_VOCABULARY); + ObjectResponse noteResponse = noteValidator.validateNote(note, VocabularyConstants.ALLELE_NOTE_TYPES_VOCABULARY_TERM_SET); if (noteResponse.getEntity() == null) { addMessageResponse(field, noteResponse.errorMessagesString()); return null; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/AnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/AnnotationValidator.java index a037e07b4..9718e0b88 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/AnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/AnnotationValidator.java @@ -77,14 +77,14 @@ public DataProvider validateDataProvider(Annotation uiEntity, Annotation dbEntit return validatedDataProvider; } - public List validateRelatedNotes(Annotation uiEntity, Annotation dbEntity) { + public List validateRelatedNotes(Annotation uiEntity, Annotation dbEntity, String noteTypeSet) { String field = "relatedNotes"; List validatedNotes = new ArrayList(); Set validatedNoteIdentities = new HashSet<>(); if (CollectionUtils.isNotEmpty(uiEntity.getRelatedNotes())) { for (Note note : uiEntity.getRelatedNotes()) { - ObjectResponse noteResponse = noteValidator.validateNote(note, VocabularyConstants.DISEASE_ANNOTATION_NOTE_TYPES_VOCABULARY); + ObjectResponse noteResponse = noteValidator.validateNote(note, noteTypeSet); if (noteResponse.getEntity() == null) { addMessageResponse(field, noteResponse.errorMessagesString()); return null; @@ -192,7 +192,7 @@ public Reference validateSingleReference(Annotation uiEntity, Annotation dbEntit return singleRefResponse.getEntity(); } - public Annotation validateCommonAnnotationFields(Annotation uiEntity, Annotation dbEntity) { + public Annotation validateCommonAnnotationFields(Annotation uiEntity, Annotation dbEntity, String noteTypeSet) { Boolean newEntity = false; if (dbEntity.getId() == null) newEntity = true; @@ -213,7 +213,7 @@ public Annotation validateCommonAnnotationFields(Annotation uiEntity, Annotation List conditionRelations = validateConditionRelations(uiEntity, dbEntity); dbEntity.setConditionRelations(conditionRelations); - List relatedNotes = validateRelatedNotes(uiEntity, dbEntity); + List relatedNotes = validateRelatedNotes(uiEntity, dbEntity, noteTypeSet); dbEntity.setRelatedNotes(relatedNotes); return dbEntity; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/DiseaseAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/DiseaseAnnotationValidator.java index 0ee9dafff..067cc45e7 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/DiseaseAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/DiseaseAnnotationValidator.java @@ -318,7 +318,7 @@ public DiseaseAnnotation validateCommonDiseaseAnnotationFields(DiseaseAnnotation List diseaseQualifiers = validateDiseaseQualifiers(uiEntity, dbEntity); dbEntity.setDiseaseQualifiers(diseaseQualifiers); - dbEntity = (DiseaseAnnotation) validateCommonAnnotationFields(uiEntity, dbEntity); + dbEntity = (DiseaseAnnotation) validateCommonAnnotationFields(uiEntity, dbEntity, VocabularyConstants.DISEASE_ANNOTATION_NOTE_TYPES_VOCABULARY_TERM_SET); String uniqueId = validateUniqueId(uiEntity, dbEntity); dbEntity.setUniqueId(uniqueId); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/NoteValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/NoteValidator.java index abdb7a2b1..e9086d0c3 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/NoteValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/NoteValidator.java @@ -32,13 +32,13 @@ public class NoteValidator extends AuditedObjectValidator { @Inject ReferenceValidator referenceValidator; - public ObjectResponse validateNote(Note uiEntity, String noteVocabularyName) { - Note note = validateNote(uiEntity, noteVocabularyName, false); + public ObjectResponse validateNote(Note uiEntity, String noteVocabularySetName) { + Note note = validateNote(uiEntity, noteVocabularySetName, false); response.setEntity(note); return response; } - public Note validateNote(Note uiEntity, String noteVocabularyName, Boolean throwError) { + public Note validateNote(Note uiEntity, String noteVocabularySetName, Boolean throwError) { response = new ObjectResponse<>(uiEntity); String errorTitle = "Could not update Note: [" + uiEntity.getId() + "]"; @@ -58,7 +58,7 @@ public Note validateNote(Note uiEntity, String noteVocabularyName, Boolean throw } dbEntity = (Note) validateAuditedObjectFields(uiEntity, dbEntity, newEntity); - VocabularyTerm noteType = validateNoteType(uiEntity, dbEntity, noteVocabularyName); + VocabularyTerm noteType = validateNoteType(uiEntity, dbEntity, noteVocabularySetName); dbEntity.setNoteType(noteType); String freeText = validateFreeText(uiEntity); @@ -107,7 +107,7 @@ private Reference validateReference(Reference uiEntity, List previousCur return singleRefResponse.getEntity(); } - public VocabularyTerm validateNoteType(Note uiEntity, Note dbEntity, String noteVocabularyName) { + public VocabularyTerm validateNoteType(Note uiEntity, Note dbEntity, String noteVocabularySetName) { String field = "noteType"; if (uiEntity.getNoteType() == null) { addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); @@ -115,7 +115,7 @@ public VocabularyTerm validateNoteType(Note uiEntity, Note dbEntity, String note } VocabularyTerm noteType; - if (noteVocabularyName == null) { + if (noteVocabularySetName == null) { SearchResponse vtSearchResponse = vocabularyTermService.findByField("name", uiEntity.getNoteType().getName()); if (vtSearchResponse == null || vtSearchResponse.getSingleResult() == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); @@ -123,7 +123,7 @@ public VocabularyTerm validateNoteType(Note uiEntity, Note dbEntity, String note } noteType = vtSearchResponse.getSingleResult(); } else { - noteType = vocabularyTermService.getTermInVocabulary(noteVocabularyName, uiEntity.getNoteType().getName()).getEntity(); + noteType = vocabularyTermService.getTermInVocabularyTermSet(noteVocabularySetName, uiEntity.getNoteType().getName()).getEntity(); if (noteType == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); return null; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDTOValidator.java index 29c2882f2..bb17a00a3 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDTOValidator.java @@ -184,7 +184,7 @@ public Allele validateAlleleDTO(AlleleDTO dto, BackendBulkDataProvider dataProvi List notes = new ArrayList<>(); Set noteIdentities = new HashSet<>(); for (NoteDTO noteDTO : dto.getNoteDtos()) { - ObjectResponse noteResponse = noteDtoValidator.validateNoteDTO(noteDTO, VocabularyConstants.ALLELE_NOTE_TYPES_VOCABULARY); + ObjectResponse noteResponse = noteDtoValidator.validateNoteDTO(noteDTO, VocabularyConstants.ALLELE_NOTE_TYPES_VOCABULARY_TERM_SET); if (noteResponse.hasErrors()) { alleleResponse.addErrorMessage("note_dtos", noteResponse.errorMessagesString()); break; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AnnotationDTOValidator.java index 598fc2b90..a7e8afdf3 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AnnotationDTOValidator.java @@ -58,7 +58,7 @@ public class AnnotationDTOValidator extends BaseDTOValidator { @Inject DataProviderDAO dataProviderDAO; - public ObjectResponse validateAnnotationDTO(E annotation, D dto) { + public ObjectResponse validateAnnotationDTO(E annotation, D dto, String noteTypeSet) { ObjectResponse annotResponse = validateAuditedObjectDTO(annotation, dto); annotation = annotResponse.getEntity(); @@ -94,7 +94,7 @@ public ObjectResponse validat List notes = new ArrayList<>(); Set noteIdentities = new HashSet<>(); for (NoteDTO noteDTO : dto.getNoteDtos()) { - ObjectResponse noteResponse = noteDtoValidator.validateNoteDTO(noteDTO, VocabularyConstants.DISEASE_ANNOTATION_NOTE_TYPES_VOCABULARY); + ObjectResponse noteResponse = noteDtoValidator.validateNoteDTO(noteDTO, noteTypeSet); if (noteResponse.hasErrors()) { annotResponse.addErrorMessage("note_dtos", noteResponse.errorMessagesString()); break; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DiseaseAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DiseaseAnnotationDTOValidator.java index 94e5378bf..d1f2c2746 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DiseaseAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DiseaseAnnotationDTOValidator.java @@ -63,7 +63,7 @@ public class DiseaseAnnotationDTOValidator extends AnnotationDTOValidator { DataProviderDAO dataProviderDAO; public ObjectResponse validateDiseaseAnnotationDTO(E annotation, D dto) { - ObjectResponse daResponse = validateAnnotationDTO(annotation, dto); + ObjectResponse daResponse = validateAnnotationDTO(annotation, dto, VocabularyConstants.DISEASE_ANNOTATION_NOTE_TYPES_VOCABULARY_TERM_SET); annotation = daResponse.getEntity(); if (StringUtils.isBlank(dto.getDoTermCurie())) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/NoteDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/NoteDTOValidator.java index 70891c327..bf21637e8 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/NoteDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/NoteDTOValidator.java @@ -32,7 +32,7 @@ public class NoteDTOValidator extends BaseDTOValidator { @Inject VocabularyTermService vocabularyTermService; - public ObjectResponse validateNoteDTO(NoteDTO dto, String note_type_vocabulary) { + public ObjectResponse validateNoteDTO(NoteDTO dto, String noteTypeVocabularyTermSet) { Note note = new Note(); ObjectResponse noteResponse = validateAuditedObjectDTO(note, dto); @@ -45,7 +45,7 @@ public ObjectResponse validateNoteDTO(NoteDTO dto, String note_type_vocabu if (StringUtils.isBlank(dto.getNoteTypeName())) { noteResponse.addErrorMessage("note_type_name", ValidationConstants.REQUIRED_MESSAGE); } else { - VocabularyTerm noteType = vocabularyTermService.getTermInVocabulary(note_type_vocabulary, dto.getNoteTypeName()).getEntity(); + VocabularyTerm noteType = vocabularyTermService.getTermInVocabularyTermSet(noteTypeVocabularyTermSet, dto.getNoteTypeName()).getEntity(); if (noteType == null) noteResponse.addErrorMessage("note_type_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getNoteTypeName() + ")"); note.setNoteType(noteType); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDTOValidator.java index 886d550ae..2cef6cc12 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDTOValidator.java @@ -91,7 +91,7 @@ public ObjectResponse validateConstructCompone List notes = new ArrayList<>(); Set noteIdentities = new HashSet<>(); for (NoteDTO noteDTO : dto.getNoteDtos()) { - ObjectResponse noteResponse = noteDtoValidator.validateNoteDTO(noteDTO, VocabularyConstants.CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY); + ObjectResponse noteResponse = noteDtoValidator.validateNoteDTO(noteDTO, VocabularyConstants.CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY_TERM_SET); if (noteResponse.hasErrors()) { ccsaResponse.addErrorMessage("note_dtos", noteResponse.errorMessagesString()); break; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationValidator.java index 79ba8002f..bb1cfd86e 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationValidator.java @@ -165,7 +165,7 @@ public List validateRelatedNotes(ConstructComponentSlotAnnotation uiEntity Set validatedNoteIdentities = new HashSet<>(); if (CollectionUtils.isNotEmpty(uiEntity.getRelatedNotes())) { for (Note note : uiEntity.getRelatedNotes()) { - ObjectResponse noteResponse = noteValidator.validateNote(note, VocabularyConstants.CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY); + ObjectResponse noteResponse = noteValidator.validateNote(note, VocabularyConstants.CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY_TERM_SET); if (noteResponse.getEntity() == null) { addMessageResponse(field, noteResponse.errorMessagesString()); return null; diff --git a/src/main/resources/db/migration/v0.27.0.4__note_vocabulary_refactor.sql b/src/main/resources/db/migration/v0.27.0.4__note_vocabulary_refactor.sql new file mode 100644 index 000000000..f627a2827 --- /dev/null +++ b/src/main/resources/db/migration/v0.27.0.4__note_vocabulary_refactor.sql @@ -0,0 +1,107 @@ +-- Create vocabulary for all note types +INSERT INTO vocabulary (id, name, vocabularylabel) VALUES (nextval('hibernate_sequence'), 'Note Type', 'note_type'); + +-- Create sets for each note type (use temporary table to avoid not null constraint) + +CREATE TABLE tmp_vocab_set ( + id bigint, + name varchar(255), + vocabularytermsetdescription varchar(255), + vocabularylabel varchar(255), + vocabularytermsetvocabulary_id bigint); + +INSERT INTO tmp_vocab_set (id, name, vocabularytermsetdescription, vocabularylabel) + SELECT nextval('hibernate_sequence'), name, vocabularydescription, vocabularylabel + FROM vocabulary WHERE vocabulary.vocabularylabel = 'allele_note_type' + OR vocabulary.vocabularylabel = 'da_note_type' + OR vocabulary.vocabularylabel = 'gene_note_type' + OR vocabulary.vocabularylabel = 'construct_component_note_type'; + +UPDATE tmp_vocab_set SET vocabularytermsetvocabulary_id = subquery.id + FROM (SELECT id FROM vocabulary WHERE vocabularylabel = 'note_type') AS subquery + WHERE vocabularylabel = 'allele_note_type' + OR vocabularylabel = 'da_note_type' + OR vocabularylabel = 'gene_note_type' + OR vocabularylabel = 'construct_component_note_type'; + +INSERT INTO vocabularytermset (id, name, vocabularytermsetdescription, vocabularylabel, vocabularytermsetvocabulary_id) + SELECT id, name, vocabularytermsetdescription, vocabularylabel, vocabularytermsetvocabulary_id FROM tmp_vocab_set; + +DROP TABLE tmp_vocab_set; + +-- Resolve duplicate comment term +UPDATE note SET notetype_id = subquery.id + FROM (SELECT id FROM vocabularyterm WHERE name = 'comment' AND vocabulary_id = ( + SELECT id FROM vocabulary WHERE vocabularylabel = 'allele_note_type' + )) as subquery + WHERE notetype_id = (SELECT id FROM vocabularyterm WHERE name = 'comment' AND vocabulary_id = ( + SELECT id FROM vocabulary WHERE vocabularylabel = 'construct_component_note_type' + )); + +DELETE FROM vocabularyterm WHERE name = 'comment' AND vocabulary_id = ( + SELECT id FROM vocabulary WHERE vocabularylabel = 'construct_component_note_type' + ); + +-- Create temp table for links between new sets and terms +CREATE TABLE tmp_vocab_link ( + vocabularytermsets_id bigint, + memberterms_id bigint); + +INSERT INTO tmp_vocab_link (memberterms_id) + SELECT id FROM vocabularyterm WHERE vocabulary_id = ( + SELECT id from vocabulary where vocabularylabel = 'allele_note_type' + ); + +UPDATE tmp_vocab_link SET vocabularytermsets_id = subquery.id + FROM (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'allele_note_type') AS subquery + WHERE vocabularytermsets_id IS NULL; + + +INSERT INTO tmp_vocab_link (memberterms_id) + SELECT id FROM vocabularyterm WHERE vocabulary_id = ( + SELECT id from vocabulary where vocabularylabel = 'gene_note_type' + ); + +UPDATE tmp_vocab_link SET vocabularytermsets_id = subquery.id + FROM (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'gene_note_type') AS subquery + WHERE vocabularytermsets_id IS NULL; + + +INSERT INTO tmp_vocab_link (memberterms_id) + SELECT id FROM vocabularyterm WHERE vocabulary_id = ( + SELECT id from vocabulary where vocabularylabel = 'da_note_type' + ); + +UPDATE tmp_vocab_link SET vocabularytermsets_id = subquery.id + FROM (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'da_note_type') AS subquery + WHERE vocabularytermsets_id IS NULL; + +INSERT INTO tmp_vocab_link (memberterms_id) + SELECT id FROM vocabularyterm WHERE vocabulary_id = ( + SELECT id from vocabulary where vocabularylabel = 'construct_component_note_type' + ); + +INSERT INTO tmp_vocab_link (memberterms_id) + SELECT id FROM vocabularyterm WHERE name = 'comment' AND vocabulary_id = ( + SELECT id from vocabulary where vocabularylabel = 'allele_note_type' + ); + +UPDATE tmp_vocab_link SET vocabularytermsets_id = subquery.id + FROM (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'construct_component_note_type') AS subquery + WHERE vocabularytermsets_id IS NULL; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) + SELECT vocabularytermsets_id, memberterms_id FROM tmp_vocab_link; + +DROP TABLE tmp_vocab_link; + +-- Set all note terms to belong to general note vocabulary +UPDATE vocabularyterm SET vocabulary_id = subquery.id + FROM (SELECT id FROM vocabulary WHERE vocabularylabel = 'note_type') AS subquery + WHERE vocabularyterm.vocabulary_id IN ( + SELECT id FROM vocabulary WHERE vocabularylabel = 'allele_note_type' + OR vocabularylabel = 'da_note_type' + OR vocabularylabel = 'gene_note_type' + OR vocabularylabel = 'construct_component_note_type' + ); + diff --git a/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java b/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java index 90412e54b..248bb235c 100644 --- a/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java @@ -57,7 +57,7 @@ public class BaseITCase { private static Pattern keyPattern = Pattern.compile("^(.+)\\.([^\\.]+)$"); - public VocabularyTerm addObsoleteVocabularyTermToSet(String setName, String termName, Vocabulary vocabulary) { + public VocabularyTerm addVocabularyTermToSet(String setName, String termName, Vocabulary vocabulary, Boolean obsolete) { VocabularyTermSet set = getVocabularyTermSet(setName); VocabularyTerm term = createVocabularyTerm(vocabulary, termName, false); @@ -73,7 +73,7 @@ public VocabularyTerm addObsoleteVocabularyTermToSet(String setName, String term then(). statusCode(200); - term.setObsolete(true); + term.setObsolete(obsolete); ObjectResponse response = RestAssured.given(). contentType("application/json"). diff --git a/src/test/java/org/alliancegenome/curation_api/bulkupload/ConstructBulkUploadITCase.java b/src/test/java/org/alliancegenome/curation_api/bulkupload/ConstructBulkUploadITCase.java index 20047d082..8415553c6 100644 --- a/src/test/java/org/alliancegenome/curation_api/bulkupload/ConstructBulkUploadITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/bulkupload/ConstructBulkUploadITCase.java @@ -61,9 +61,9 @@ public void init() { private final String constructTestFilePath = "src/test/resources/bulk/05_construct/"; private void loadRequiredEntities() throws Exception { - Vocabulary noteTypeVocabulary = getVocabulary(VocabularyConstants.CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY); - noteType = createVocabularyTerm(noteTypeVocabulary, "test_construct_component_note", false); - noteType2 = createVocabularyTerm(noteTypeVocabulary, "test_construct_component_summary", false); + Vocabulary noteTypeVocabulary = getVocabulary(VocabularyConstants.NOTE_TYPE_VOCABULARY); + noteType = addVocabularyTermToSet(VocabularyConstants.CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY_TERM_SET, "test_construct_component_note", noteTypeVocabulary, false); + noteType2 = addVocabularyTermToSet(VocabularyConstants.CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY_TERM_SET, "test_construct_component_summary", noteTypeVocabulary, false); Vocabulary relationVocabulary = createVocabulary("construct_genomic_entity_predicate", false); relation = createVocabularyTerm(relationVocabulary, "is_regulated_by", false); relation2 = createVocabularyTerm(relationVocabulary, "targets", false); diff --git a/src/test/java/org/alliancegenome/curation_api/bulkupload/DiseaseAnnotationBulkUploadITCase.java b/src/test/java/org/alliancegenome/curation_api/bulkupload/DiseaseAnnotationBulkUploadITCase.java index 7b4cb529d..38abf5da3 100644 --- a/src/test/java/org/alliancegenome/curation_api/bulkupload/DiseaseAnnotationBulkUploadITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/bulkupload/DiseaseAnnotationBulkUploadITCase.java @@ -154,15 +154,16 @@ private void loadRequiredEntities() throws Exception { loadReference(reference, referenceXref); loadOrganization("OBSOLETE"); - Vocabulary noteTypeVocabulary = createVocabulary(VocabularyConstants.DISEASE_ANNOTATION_NOTE_TYPES_VOCABULARY, false); + Vocabulary noteTypeVocabulary = getVocabulary(VocabularyConstants.NOTE_TYPE_VOCABULARY); Vocabulary relationVocabulary = createVocabulary(VocabularyConstants.DISEASE_RELATION_VOCABULARY, false); Vocabulary geneticSexVocabulary = createVocabulary(VocabularyConstants.GENETIC_SEX_VOCABULARY, false); Vocabulary diseaseGeneticModifierRelationVocabulary = createVocabulary(VocabularyConstants.DISEASE_GENETIC_MODIFIER_RELATION_VOCABULARY, false); Vocabulary diseaseQualifierVocabulary = createVocabulary(VocabularyConstants.DISEASE_QUALIFIER_VOCABULARY, false); Vocabulary annotationTypeVocabulary = createVocabulary(VocabularyConstants.ANNOTATION_TYPE_VOCABULARY, false); Vocabulary conditionRelationTypeVocabulary = createVocabulary(VocabularyConstants.CONDITION_RELATION_TYPE_VOCABULARY, false); - createVocabularyTerm(noteTypeVocabulary, noteType, false); - createVocabularyTerm(noteTypeVocabulary, noteType2, false); + VocabularyTerm nt = createVocabularyTerm(noteTypeVocabulary, noteType, false); + VocabularyTerm nt2 = createVocabularyTerm(noteTypeVocabulary, noteType2, false); + createVocabularyTermSet(VocabularyConstants.DISEASE_ANNOTATION_NOTE_TYPES_VOCABULARY_TERM_SET, noteTypeVocabulary, List.of(nt, nt2)); VocabularyTerm alleleAndGeneRelationVocabularyTerm = createVocabularyTerm(relationVocabulary, alleleAndGeneRelation, false); VocabularyTerm agmRelationVocabularyTerm = createVocabularyTerm(relationVocabulary, agmRelation, false); VocabularyTerm agmRelationVocabularyTerm2 = createVocabularyTerm(relationVocabulary, agmRelation2, false); diff --git a/src/test/java/org/alliancegenome/curation_api/crud/controllers/AlleleITCase.java b/src/test/java/org/alliancegenome/curation_api/crud/controllers/AlleleITCase.java index af699291b..ae7eeb167 100644 --- a/src/test/java/org/alliancegenome/curation_api/crud/controllers/AlleleITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/crud/controllers/AlleleITCase.java @@ -134,7 +134,7 @@ private void loadRequiredEntities() { nameTypeVocabulary = getVocabulary(VocabularyConstants.NAME_TYPE_VOCABULARY); synonymScopeVocabulary = getVocabulary(VocabularyConstants.SYNONYM_SCOPE_VOCABULARY); functionalImpactVocabulary = getVocabulary(VocabularyConstants.ALLELE_FUNCTIONAL_IMPACT_VOCABULARY); - noteTypeVocabulary = getVocabulary(VocabularyConstants.ALLELE_NOTE_TYPES_VOCABULARY); + noteTypeVocabulary = getVocabulary(VocabularyConstants.NOTE_TYPE_VOCABULARY); databaseStatusVocabulary = getVocabulary(VocabularyConstants.ALLELE_DATABASE_STATUS_VOCABULARY); nomenclatureEventVocabulary = getVocabulary(VocabularyConstants.ALLELE_NOMENCLATURE_EVENT_VOCABULARY); dominantInheritanceMode = getVocabularyTerm(inheritanceModeVocabulary, "dominant"); @@ -181,7 +181,7 @@ private void loadRequiredEntities() { obsoleteMpTerm = createMpTerm("MP:00000", true); noteType = getVocabularyTerm(noteTypeVocabulary, "comment"); noteType2 = getVocabularyTerm(noteTypeVocabulary, "user_submitted_note"); - obsoleteNoteType = createVocabularyTerm(noteTypeVocabulary, "obsolete_type", true); + obsoleteNoteType = addVocabularyTermToSet(VocabularyConstants.ALLELE_NOTE_TYPES_VOCABULARY_TERM_SET, "obsolete_type", noteTypeVocabulary, true); relatedNote = createNote(noteType, "Test text", false, reference); alleleMutationType = createAlleleMutationTypeSlotAnnotation(List.of(reference), List.of(soTerm)); alleleGermlineTransmissionStatus = createAlleleGermlineTransmissionStatusSlotAnnotation(List.of(reference), cellLineGTS); diff --git a/src/test/java/org/alliancegenome/curation_api/crud/controllers/ConstructITCase.java b/src/test/java/org/alliancegenome/curation_api/crud/controllers/ConstructITCase.java index 0c8973395..94b0749ac 100644 --- a/src/test/java/org/alliancegenome/curation_api/crud/controllers/ConstructITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/crud/controllers/ConstructITCase.java @@ -88,11 +88,11 @@ public class ConstructITCase extends BaseITCase { private ConstructSynonymSlotAnnotation constructSynonym; private void loadRequiredEntities() { - noteTypeVocabulary = getVocabulary(VocabularyConstants.CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY); - alleleNoteTypeVocabulary = getVocabulary(VocabularyConstants.ALLELE_NOTE_TYPES_VOCABULARY); + noteTypeVocabulary = getVocabulary(VocabularyConstants.NOTE_TYPE_VOCABULARY); + alleleNoteTypeVocabulary = getVocabulary(VocabularyConstants.NOTE_TYPE_VOCABULARY); noteType = getVocabularyTerm(noteTypeVocabulary, "test_construct_component_note"); noteType2 = getVocabularyTerm(noteTypeVocabulary, "test_construct_component_summary"); - obsoleteNoteType = createVocabularyTerm(noteTypeVocabulary, "obsolete_type", true); + obsoleteNoteType = addVocabularyTermToSet(VocabularyConstants.CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY_TERM_SET, "obsolete_type", noteTypeVocabulary, true); alleleNoteType = getVocabularyTerm(alleleNoteTypeVocabulary, "notes_on_origin"); relationVocabulary = getVocabulary("construct_genomic_entity_predicate"); isRegulatedByRelation = getVocabularyTerm(relationVocabulary, "is_regulated_by"); diff --git a/src/test/java/org/alliancegenome/curation_api/crud/controllers/DiseaseAnnotationITCase.java b/src/test/java/org/alliancegenome/curation_api/crud/controllers/DiseaseAnnotationITCase.java index 05116eed5..40d6932ee 100644 --- a/src/test/java/org/alliancegenome/curation_api/crud/controllers/DiseaseAnnotationITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/crud/controllers/DiseaseAnnotationITCase.java @@ -158,16 +158,16 @@ private void loadRequiredEntities() { experimentalCondition = createExperimentalCondition("Statement", "ZECO:da001", "Test"); experimentalCondition2 = createExperimentalCondition("Statement2", "ZECO:da002", "Test2"); relationVocabulary = getVocabulary(VocabularyConstants.DISEASE_RELATION_VOCABULARY); - noteTypeVocabulary = getVocabulary(VocabularyConstants.DISEASE_ANNOTATION_NOTE_TYPES_VOCABULARY); + noteTypeVocabulary = getVocabulary(VocabularyConstants.NOTE_TYPE_VOCABULARY); geneticSexVocabulary = getVocabulary(VocabularyConstants.GENETIC_SEX_VOCABULARY); conditionRelationTypeVocabulary = getVocabulary(VocabularyConstants.CONDITION_RELATION_TYPE_VOCABULARY); diseaseGeneticModifierRelationVocabulary = getVocabulary(VocabularyConstants.DISEASE_GENETIC_MODIFIER_RELATION_VOCABULARY); diseaseQualifierVocabulary = getVocabulary(VocabularyConstants.DISEASE_QUALIFIER_VOCABULARY); annotationTypeVocabulary = getVocabulary(VocabularyConstants.ANNOTATION_TYPE_VOCABULARY); geneRelation = getVocabularyTerm(relationVocabulary, "is_marker_for"); - obsoleteGeneRelation = addObsoleteVocabularyTermToSet(VocabularyConstants.GENE_DISEASE_RELATION_VOCABULARY_TERM_SET, "obsolete_gene_relation", relationVocabulary); - obsoleteAlleleRelation = addObsoleteVocabularyTermToSet(VocabularyConstants.ALLELE_DISEASE_RELATION_VOCABULARY_TERM_SET, "obsolete_allele_relation", relationVocabulary); - obsoleteAgmRelation = addObsoleteVocabularyTermToSet(VocabularyConstants.AGM_DISEASE_RELATION_VOCABULARY_TERM_SET, "obsolete_agm_relation", relationVocabulary); + obsoleteGeneRelation = addVocabularyTermToSet(VocabularyConstants.GENE_DISEASE_RELATION_VOCABULARY_TERM_SET, "obsolete_gene_relation", relationVocabulary, true); + obsoleteAlleleRelation = addVocabularyTermToSet(VocabularyConstants.ALLELE_DISEASE_RELATION_VOCABULARY_TERM_SET, "obsolete_allele_relation", relationVocabulary, true); + obsoleteAgmRelation = addVocabularyTermToSet(VocabularyConstants.AGM_DISEASE_RELATION_VOCABULARY_TERM_SET, "obsolete_agm_relation", relationVocabulary, true); alleleAndGeneRelation = getVocabularyTerm(relationVocabulary, "is_implicated_in"); agmRelation = getVocabularyTerm(relationVocabulary, "is_model_of"); agmRelation2 = getVocabularyTerm(relationVocabulary, "is_exacerbated_model_of"); @@ -186,7 +186,7 @@ private void loadRequiredEntities() { person = createPerson("TEST:Person0001"); noteType = getVocabularyTerm(noteTypeVocabulary, "disease_note"); noteType2 = getVocabularyTerm(noteTypeVocabulary, "disease_summary"); - obsoleteNoteType = createVocabularyTerm(noteTypeVocabulary, "obsolete_type", true); + obsoleteNoteType = addVocabularyTermToSet(VocabularyConstants.DISEASE_ANNOTATION_NOTE_TYPES_VOCABULARY_TERM_SET, "obsolete_type", noteTypeVocabulary, true); relatedNote = createNote(noteType, "Test text", false, null); duplicateNote = createNote(noteType, "Test text", false, null); conditionRelationType = createVocabularyTerm(conditionRelationTypeVocabulary, "has_condition", false); diff --git a/src/test/java/org/alliancegenome/curation_api/crud/controllers/GeneITCase.java b/src/test/java/org/alliancegenome/curation_api/crud/controllers/GeneITCase.java index 573ac63f0..a38560134 100644 --- a/src/test/java/org/alliancegenome/curation_api/crud/controllers/GeneITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/crud/controllers/GeneITCase.java @@ -92,9 +92,9 @@ private void loadRequiredEntities() { systematicNameType = getVocabularyTerm(nameType, "systematic_name"); fullNameType = getVocabularyTerm(nameType, "full_name"); obsoleteNameType = createVocabularyTerm(nameType, "obsolete_name", true); - obsoleteFullNameType = addObsoleteVocabularyTermToSet(VocabularyConstants.FULL_NAME_TYPE_TERM_SET, "obsolete_full_name", nameType); - obsoleteSymbolNameType = addObsoleteVocabularyTermToSet(VocabularyConstants.SYMBOL_NAME_TYPE_TERM_SET, "obsolete_symbol_name", nameType); - obsoleteSystematicNameType = addObsoleteVocabularyTermToSet(VocabularyConstants.SYSTEMATIC_NAME_TYPE_TERM_SET, "obsolete_systematic_name", nameType); + obsoleteFullNameType = addVocabularyTermToSet(VocabularyConstants.FULL_NAME_TYPE_TERM_SET, "obsolete_full_name", nameType, true); + obsoleteSymbolNameType = addVocabularyTermToSet(VocabularyConstants.SYMBOL_NAME_TYPE_TERM_SET, "obsolete_symbol_name", nameType, true); + obsoleteSystematicNameType = addVocabularyTermToSet(VocabularyConstants.SYSTEMATIC_NAME_TYPE_TERM_SET, "obsolete_systematic_name", nameType, true); exactSynonymScope = getVocabularyTerm(synonymScope, "exact"); broadSynonymScope = getVocabularyTerm(synonymScope, "broad"); obsoleteSynonymScope = createVocabularyTerm(synonymScope, "obsolete", true); From e5d331bba686f990eadf63f15f260570ebc0dbd2 Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Wed, 4 Oct 2023 12:12:21 +0100 Subject: [PATCH 04/76] UI updates for consolidation of note vocabularies --- .../allelesPage/relatedNotes/RelatedNotesDialog.js | 3 ++- .../allelesPage/relatedNotes/RelatedNotesFormTable.js | 4 ++-- .../src/containers/constructsPage/RelatedNotesDialog.js | 3 ++- .../diseaseAnnotationsPage/RelatedNotesDialog.js | 3 ++- .../containers/diseaseAnnotationsPage/RelatedNotesForm.js | 3 ++- .../db/migration/v0.27.0.4__note_vocabulary_refactor.sql | 8 ++++++++ 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/cliapp/src/containers/allelesPage/relatedNotes/RelatedNotesDialog.js b/src/main/cliapp/src/containers/allelesPage/relatedNotes/RelatedNotesDialog.js index b580678fb..a3d9737ca 100644 --- a/src/main/cliapp/src/containers/allelesPage/relatedNotes/RelatedNotesDialog.js +++ b/src/main/cliapp/src/containers/allelesPage/relatedNotes/RelatedNotesDialog.js @@ -11,6 +11,7 @@ import { DialogErrorMessageComponent } from '../../../components/Error/DialogErr import { EllipsisTableCell } from '../../../components/EllipsisTableCell'; import { TrueFalseDropdown } from '../../../components/TrueFalseDropDownSelector'; import { useControlledVocabularyService } from '../../../service/useControlledVocabularyService'; +import { useVocabularyTermSetService } from '../../../service/useVocabularyTermSetService'; import { ValidationService } from '../../../service/ValidationService'; import { ControlledVocabularyDropdown } from '../../../components/ControlledVocabularySelector'; import { autocompleteSearch, buildAutocompleteFilter, multipleAutocompleteOnChange, getRefStrings } from '../../../utils/utils'; @@ -30,7 +31,7 @@ export const RelatedNotesDialog = ({ const [editingRows, setEditingRows] = useState({}); const [errorMessages, setErrorMessages] = useState([]); const booleanTerms = useControlledVocabularyService('generic_boolean_terms'); - const noteTypeTerms = useControlledVocabularyService('allele_note_type'); + const noteTypeTerms = useVocabularyTermSetService('allele_note_type'); const validationService = new ValidationService(); const searchService = new SearchService(); const tableRef = useRef(null); diff --git a/src/main/cliapp/src/containers/allelesPage/relatedNotes/RelatedNotesFormTable.js b/src/main/cliapp/src/containers/allelesPage/relatedNotes/RelatedNotesFormTable.js index 9eaa2faf2..1edefcc16 100644 --- a/src/main/cliapp/src/containers/allelesPage/relatedNotes/RelatedNotesFormTable.js +++ b/src/main/cliapp/src/containers/allelesPage/relatedNotes/RelatedNotesFormTable.js @@ -5,7 +5,7 @@ import { Row } from 'primereact/row'; import { DeleteAction } from '../../../components/Actions/DeletionAction'; import { InternalEditor } from '../../../components/Editors/InternalEditor'; import { ReferencesEditor } from '../../../components/Editors/ReferencesEditor'; -import { ControlledVocabularyEditor } from '../../../components/Editors/ControlledVocabularyEditor'; +import { VocabularyTermSetEditor } from '../../../components/Editors/VocabularyTermSetEditor'; import { TableInputTextAreaEditor } from '../../../components/Editors/TableInputTextAreaEditor'; export const RelatedNotesFormTable = ({ @@ -39,7 +39,7 @@ export const RelatedNotesFormTable = ({ className='max-w-4rem' bodyClassName="text-center" headerClassName='surface-0' frozen /> { - return { const booleanTerms = useControlledVocabularyService('generic_boolean_terms'); - const noteTypeTerms = useControlledVocabularyService('da_note_type'); + const noteTypeTerms = useVocabularyTermSetService('da_note_type'); const tableRef = useRef(null); const toast_topright = useRef(null); diff --git a/src/main/resources/db/migration/v0.27.0.4__note_vocabulary_refactor.sql b/src/main/resources/db/migration/v0.27.0.4__note_vocabulary_refactor.sql index f627a2827..aa0b97e50 100644 --- a/src/main/resources/db/migration/v0.27.0.4__note_vocabulary_refactor.sql +++ b/src/main/resources/db/migration/v0.27.0.4__note_vocabulary_refactor.sql @@ -41,6 +41,8 @@ UPDATE note SET notetype_id = subquery.id DELETE FROM vocabularyterm WHERE name = 'comment' AND vocabulary_id = ( SELECT id FROM vocabulary WHERE vocabularylabel = 'construct_component_note_type' ); + +UPDATE vocabularyterm SET definition = 'general comment' WHERE name = 'comment'; -- Create temp table for links between new sets and terms CREATE TABLE tmp_vocab_link ( @@ -105,3 +107,9 @@ UPDATE vocabularyterm SET vocabulary_id = subquery.id OR vocabularylabel = 'construct_component_note_type' ); +-- Delete old vocabularies +DELETE FROM vocabulary WHERE vocabularylabel = 'allele_note_type' + OR vocabularylabel = 'da_note_type' + OR vocabularylabel = 'gene_note_type' + OR vocabularylabel = 'construct_component_note_type'; + From 8c6e9c58ce2e3def9920807bdf60224a22d22e3f Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Wed, 4 Oct 2023 13:35:27 +0100 Subject: [PATCH 05/76] Consolidate relation vocabularies --- .../constants/VocabularyConstants.java | 3 +- ...ctComponentSlotAnnotationDTOValidator.java | 2 +- ...tructComponentSlotAnnotationValidator.java | 2 +- .../v0.27.0.4__note_vocabulary_refactor.sql | 84 ++++++++++++++++++- .../bulkupload/ConstructBulkUploadITCase.java | 4 +- .../crud/controllers/ConstructITCase.java | 4 +- 6 files changed, 91 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java index 3cf24cdaa..ca269beb0 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java @@ -35,7 +35,8 @@ public final class VocabularyConstants { public static final String ORTHOLOGY_BEST_REVERSE_SCORE_VOCABULARY_TERM_SET = "ortho_best_rev_score"; public static final String ORTHOLOGY_PREDICTION_METHOD_VOCABULARY = "ortho_prediction_method"; - public static final String CONSTRUCT_GENOMIC_ENTITY_RELATION_VOCABULARY = "construct_genomic_entity_predicate"; + public static final String CONSTRUCT_RELATION_VOCABULARY = "construct_relation"; + public static final String CONSTRUCT_GENOMIC_ENTITY_RELATION_VOCABULARY_TERM_SET = "construct_genomic_entity_relation"; public static final String NOTE_TYPE_VOCABULARY = "note_type"; public static final String ALLELE_NOTE_TYPES_VOCABULARY_TERM_SET = "allele_note_type"; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDTOValidator.java index 2cef6cc12..d0cabe213 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDTOValidator.java @@ -58,7 +58,7 @@ public ObjectResponse validateConstructCompone } if (StringUtils.isNotEmpty(dto.getRelationName())) { - VocabularyTerm diseaseRelation = vocabularyTermService.getTermInVocabulary(VocabularyConstants.CONSTRUCT_GENOMIC_ENTITY_RELATION_VOCABULARY, dto.getRelationName()).getEntity(); + VocabularyTerm diseaseRelation = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.CONSTRUCT_GENOMIC_ENTITY_RELATION_VOCABULARY_TERM_SET, dto.getRelationName()).getEntity(); if (diseaseRelation == null) ccsaResponse.addErrorMessage("relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getRelationName() + ")"); annotation.setRelation(diseaseRelation); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationValidator.java index bb1cfd86e..ae9553872 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationValidator.java @@ -124,7 +124,7 @@ private VocabularyTerm validateRelation(ConstructComponentSlotAnnotation uiEntit return null; } - VocabularyTerm relation = vocabularyTermService.getTermInVocabulary(VocabularyConstants.CONSTRUCT_GENOMIC_ENTITY_RELATION_VOCABULARY, uiEntity.getRelation().getName()).getEntity(); + VocabularyTerm relation = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.CONSTRUCT_GENOMIC_ENTITY_RELATION_VOCABULARY_TERM_SET, uiEntity.getRelation().getName()).getEntity(); if (relation == null) { addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); diff --git a/src/main/resources/db/migration/v0.27.0.4__note_vocabulary_refactor.sql b/src/main/resources/db/migration/v0.27.0.4__note_vocabulary_refactor.sql index aa0b97e50..9421b1e8f 100644 --- a/src/main/resources/db/migration/v0.27.0.4__note_vocabulary_refactor.sql +++ b/src/main/resources/db/migration/v0.27.0.4__note_vocabulary_refactor.sql @@ -27,7 +27,7 @@ UPDATE tmp_vocab_set SET vocabularytermsetvocabulary_id = subquery.id INSERT INTO vocabularytermset (id, name, vocabularytermsetdescription, vocabularylabel, vocabularytermsetvocabulary_id) SELECT id, name, vocabularytermsetdescription, vocabularylabel, vocabularytermsetvocabulary_id FROM tmp_vocab_set; -DROP TABLE tmp_vocab_set; +DELETE FROM tmp_vocab_set; -- Resolve duplicate comment term UPDATE note SET notetype_id = subquery.id @@ -95,7 +95,7 @@ UPDATE tmp_vocab_link SET vocabularytermsets_id = subquery.id INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) SELECT vocabularytermsets_id, memberterms_id FROM tmp_vocab_link; -DROP TABLE tmp_vocab_link; +DELETE FROM tmp_vocab_link; -- Set all note terms to belong to general note vocabulary UPDATE vocabularyterm SET vocabulary_id = subquery.id @@ -112,4 +112,84 @@ DELETE FROM vocabulary WHERE vocabularylabel = 'allele_note_type' OR vocabularylabel = 'da_note_type' OR vocabularylabel = 'gene_note_type' OR vocabularylabel = 'construct_component_note_type'; + +-- Consolidate construct relations +UPDATE vocabulary SET vocabularylabel = 'construct_relation', name = 'Construct Relation' WHERE vocabularylabel = 'construct_genomic_entity_predicate'; + +INSERT INTO vocabularytermset (id, name, vocabularylabel, vocabularytermsetvocabulary_id) + SELECT nextval('hibernate_sequence'), 'Construct Genomic Entity Relation', 'construct_genomic_entity_relation', id + FROM vocabulary where vocabularylabel = 'construct_relation'; + +-- Create vocabulary for all allele relation types +INSERT INTO vocabulary (id, name, vocabularylabel) VALUES (nextval('hibernate_sequence'), 'Allele Relation', 'allele_relation'); + +-- Create sets for each allele relation type (use temporary table to avoid not null constraint) + +INSERT INTO tmp_vocab_set (id, name, vocabularylabel) + SELECT nextval('hibernate_sequence'), name, vocabularylabel + FROM vocabulary WHERE vocabulary.vocabularylabel = 'allele_allele_predicate' + OR vocabulary.vocabularylabel = 'allele_construct_predicate' + OR vocabulary.vocabularylabel = 'allele_generation_method_predicate'; + +UPDATE tmp_vocab_set SET vocabularytermsetvocabulary_id = subquery.id + FROM (SELECT id FROM vocabulary WHERE vocabularylabel = 'allele_relation') AS subquery + WHERE vocabularytermsetvocabulary_id IS NULL; + +UPDATE tmp_vocab_set SET vocabularylabel = 'allele_allele_relation', name = 'Allele Allele Association Relation' WHERE vocabularylabel = 'allele_allele_predicate'; +UPDATE tmp_vocab_set SET vocabularylabel = 'allele_construct_relation', name = 'Allele Construct Association Relation' WHERE vocabularylabel = 'allele_construct_predicate'; +UPDATE tmp_vocab_set SET vocabularylabel = 'allele_generation_method_relation', name = 'Allele Generation Method Association Relation' WHERE vocabularylabel = 'allele_generation_method_predicate'; + +INSERT INTO vocabularytermset (id, name, vocabularytermsetdescription, vocabularylabel, vocabularytermsetvocabulary_id) + SELECT id, name, vocabularytermsetdescription, vocabularylabel, vocabularytermsetvocabulary_id FROM tmp_vocab_set; + +DROP TABLE tmp_vocab_set; + +-- Populate temp table with links between new allele relation sets and terms +INSERT INTO tmp_vocab_link (memberterms_id) + SELECT id FROM vocabularyterm WHERE vocabulary_id = ( + SELECT id from vocabulary where vocabularylabel = 'allele_allele_predicate' + ); + +UPDATE tmp_vocab_link SET vocabularytermsets_id = subquery.id + FROM (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'allele_allele_relation') AS subquery + WHERE vocabularytermsets_id IS NULL; + + +INSERT INTO tmp_vocab_link (memberterms_id) + SELECT id FROM vocabularyterm WHERE vocabulary_id = ( + SELECT id from vocabulary where vocabularylabel = 'allele_construct_predicate' + ); + +UPDATE tmp_vocab_link SET vocabularytermsets_id = subquery.id + FROM (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'allele_construct_relation') AS subquery + WHERE vocabularytermsets_id IS NULL; + + +INSERT INTO tmp_vocab_link (memberterms_id) + SELECT id FROM vocabularyterm WHERE vocabulary_id = ( + SELECT id from vocabulary where vocabularylabel = 'allele_generation_method_predicate' + ); + +UPDATE tmp_vocab_link SET vocabularytermsets_id = subquery.id + FROM (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'allele_generation_method_relation') AS subquery + WHERE vocabularytermsets_id IS NULL; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) + SELECT vocabularytermsets_id, memberterms_id FROM tmp_vocab_link; + +DROP TABLE tmp_vocab_link; + +-- Set all note terms to belong to general note vocabulary +UPDATE vocabularyterm SET vocabulary_id = subquery.id + FROM (SELECT id FROM vocabulary WHERE vocabularylabel = 'allele_relation') AS subquery + WHERE vocabularyterm.vocabulary_id IN ( + SELECT id FROM vocabulary WHERE vocabularylabel = 'allele_allele_predicate' + OR vocabularylabel = 'allele_construct_predicate' + OR vocabularylabel = 'allele_generation_method_predicate' + ); + +-- Delete old vocabularies +DELETE FROM vocabulary WHERE vocabularylabel = 'allele_allele_predicate' + OR vocabularylabel = 'allele_construct_predicate' + OR vocabularylabel = 'allele_generation_method_predicate'; diff --git a/src/test/java/org/alliancegenome/curation_api/bulkupload/ConstructBulkUploadITCase.java b/src/test/java/org/alliancegenome/curation_api/bulkupload/ConstructBulkUploadITCase.java index 8415553c6..3c9a30ecf 100644 --- a/src/test/java/org/alliancegenome/curation_api/bulkupload/ConstructBulkUploadITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/bulkupload/ConstructBulkUploadITCase.java @@ -7,6 +7,7 @@ import java.time.OffsetDateTime; import java.time.ZoneId; +import java.util.List; import org.alliancegenome.curation_api.base.BaseITCase; import org.alliancegenome.curation_api.constants.VocabularyConstants; @@ -64,9 +65,10 @@ private void loadRequiredEntities() throws Exception { Vocabulary noteTypeVocabulary = getVocabulary(VocabularyConstants.NOTE_TYPE_VOCABULARY); noteType = addVocabularyTermToSet(VocabularyConstants.CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY_TERM_SET, "test_construct_component_note", noteTypeVocabulary, false); noteType2 = addVocabularyTermToSet(VocabularyConstants.CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY_TERM_SET, "test_construct_component_summary", noteTypeVocabulary, false); - Vocabulary relationVocabulary = createVocabulary("construct_genomic_entity_predicate", false); + Vocabulary relationVocabulary = createVocabulary(VocabularyConstants.CONSTRUCT_RELATION_VOCABULARY, false); relation = createVocabularyTerm(relationVocabulary, "is_regulated_by", false); relation2 = createVocabularyTerm(relationVocabulary, "targets", false); + createVocabularyTermSet(VocabularyConstants.CONSTRUCT_GENOMIC_ENTITY_RELATION_VOCABULARY_TERM_SET, relationVocabulary, List.of(relation, relation2)); } @Test diff --git a/src/test/java/org/alliancegenome/curation_api/crud/controllers/ConstructITCase.java b/src/test/java/org/alliancegenome/curation_api/crud/controllers/ConstructITCase.java index 94b0749ac..d758963ce 100644 --- a/src/test/java/org/alliancegenome/curation_api/crud/controllers/ConstructITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/crud/controllers/ConstructITCase.java @@ -94,10 +94,10 @@ private void loadRequiredEntities() { noteType2 = getVocabularyTerm(noteTypeVocabulary, "test_construct_component_summary"); obsoleteNoteType = addVocabularyTermToSet(VocabularyConstants.CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY_TERM_SET, "obsolete_type", noteTypeVocabulary, true); alleleNoteType = getVocabularyTerm(alleleNoteTypeVocabulary, "notes_on_origin"); - relationVocabulary = getVocabulary("construct_genomic_entity_predicate"); + relationVocabulary = getVocabulary(VocabularyConstants.CONSTRUCT_RELATION_VOCABULARY); isRegulatedByRelation = getVocabularyTerm(relationVocabulary, "is_regulated_by"); targetsRelation = getVocabularyTerm(relationVocabulary, "targets"); - obsoleteRelation = createVocabularyTerm(relationVocabulary, "obsolete_relation", true); + obsoleteRelation = addVocabularyTermToSet(VocabularyConstants.CONSTRUCT_GENOMIC_ENTITY_RELATION_VOCABULARY_TERM_SET, "obsolete_relation", relationVocabulary, true); taxon = getNCBITaxonTerm("NCBITaxon:6239"); taxon2 = getNCBITaxonTerm("NCBITaxon:9606"); obsoleteTaxon = getNCBITaxonTerm("NCBITaxon:0000"); From ab52119395a2da0a304d507306fff5ffe9a46de8 Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Wed, 4 Oct 2023 20:18:11 +0100 Subject: [PATCH 06/76] Add Nomenclature Events to allele detail page --- .../src/components/Editors/ObsoleteEditor.js | 20 ++++ .../allelesPage/AlleleDetailPage.js | 9 +- .../containers/allelesPage/AllelesTable.js | 2 +- .../NomenclatureEventsDialog.js | 14 +-- .../NomenclatureEventsForm.js | 106 ++++++++++++++++++ .../NomenclatureEventsFormTable.js | 93 +++++++++++++++ .../allelesPage/useAlleleReducer.js | 8 ++ 7 files changed, 243 insertions(+), 9 deletions(-) create mode 100644 src/main/cliapp/src/components/Editors/ObsoleteEditor.js rename src/main/cliapp/src/containers/allelesPage/{ => nomenclatureEvents}/NomenclatureEventsDialog.js (95%) create mode 100644 src/main/cliapp/src/containers/allelesPage/nomenclatureEvents/NomenclatureEventsForm.js create mode 100644 src/main/cliapp/src/containers/allelesPage/nomenclatureEvents/NomenclatureEventsFormTable.js diff --git a/src/main/cliapp/src/components/Editors/ObsoleteEditor.js b/src/main/cliapp/src/components/Editors/ObsoleteEditor.js new file mode 100644 index 000000000..3af43ae37 --- /dev/null +++ b/src/main/cliapp/src/components/Editors/ObsoleteEditor.js @@ -0,0 +1,20 @@ +import { DialogErrorMessageComponent } from "../Error/DialogErrorMessageComponent"; +import { useControlledVocabularyService } from "../../service/useControlledVocabularyService"; +import { TrueFalseDropdown } from "../TrueFalseDropDownSelector"; + +export const ObsoleteEditor = ({ props, obsoleteOnChangeHandler, errorMessages, rowIndex }) => { + const booleanTerms = useControlledVocabularyService("generic_boolean_terms"); + + return ( + <> + + + + ); +}; \ No newline at end of file diff --git a/src/main/cliapp/src/containers/allelesPage/AlleleDetailPage.js b/src/main/cliapp/src/containers/allelesPage/AlleleDetailPage.js index 5b780f081..da08719bf 100644 --- a/src/main/cliapp/src/containers/allelesPage/AlleleDetailPage.js +++ b/src/main/cliapp/src/containers/allelesPage/AlleleDetailPage.js @@ -28,7 +28,7 @@ import { RelatedNotesForm } from './relatedNotes/RelatedNotesForm'; import { SymbolForm } from './symbol/SymbolForm'; import { GermilineTransmissionStatusForm } from './germlineTransmissionStatus/GermlineTransmissionStatusForm'; import { ReferencesForm } from './referencesTable/ReferencesForm'; - +import { NomenclatureEventsForm } from './nomenclatureEvents/NomenclatureEventsForm'; export default function AlleleDetailPage(){ const { curie } = useParams(); @@ -257,6 +257,13 @@ const { isLoading } = useQuery([curie], + + + + { + const tableRef = useRef(null); + + const createNewNomenclatureEventHandler = (e) => { + e.preventDefault(); + const dataKey = state.allele.alleleNomenclatureEvents?.length; + const newNomenclatureEvent = { + dataKey: dataKey, + internal: false, + obsolete: false, + nomenclatureEvent: null + } + + dispatch({ + type: "ADD_ROW", + row: newNomenclatureEvent, + entityType: "alleleNomenclatureEvents", + }) + }; + + const onRowEditChange = (e) => { + return null; + }; + + const nomenclatureEventOnChangeHandler = (props, event) => { + //termporary solution -- replace with props.editorCallback() after PrimeReact upgrade + props.rowData.nomenclatureEvent = event.target.value; + dispatch({ + type: 'EDIT_ROW', + entityType: 'alleleNomenclatureEvents', + index: props.rowIndex, + field: "nomenclatureEvent", + value: event.target.value + }); + }; + + const internalOnChangeHandler = (props, event) => { + //temporary solution -- replace with props.editorCallback() after PrimeReact upgrade + props.rowData.internal = event.target.value; + dispatch({ + type: 'EDIT_ROW', + entityType: 'alleleNomenclatureEvents', + index: props.rowIndex, + field: "internal", + value: event.target?.value?.name + }); + }; + + const obsoleteOnChangeHandler = (props, event) => { + //temporary solution -- replace with props.editorCallback() after PrimeReact upgrade + props.rowData.obsolete = event.target.value; + dispatch({ + type: 'EDIT_ROW', + entityType: 'alleleNomenclatureEvents', + index: props.rowIndex, + field: "obsolete", + value: event.target?.value?.name + }); + }; + + const evidenceOnChangeHandler = (event, setFieldValue, props) => { + //updates value in table input box + setFieldValue(event.target.value); + dispatch({ + type: 'EDIT_ROW', + entityType: 'alleleNomenclatureEvents', + index: props.rowIndex, + field: "evidence", + value: event.target.value + }); + } + + const deletionHandler = (e, index) => { + e.preventDefault(); + dispatch({type: "DELETE_ROW", entityType: "alleleNomenclatureEvents", index: index}); + dispatch({type: "UPDATE_TABLE_ERROR_MESSAGES", entityType: "alleleNomenclatureEvents", errorMessages: []}); + }; + + return ( + + } + tableName="Nomenclature Events" + showTable={state.entityStates.alleleNomenclatureEvents.show} + button={ + ) + } + }; + + const relatedNotesEditor = (props) => { + if (props?.rowData?.relatedNotes) { + return ( + <> +
+ +
+ + + ) + } else { + return ( + <> +
+ +
+ + + ) + } + }; + + + const columns = [ + { + field: "curie", + header: "Curie", + sortable: { isEnabled }, + filterConfig: FILTER_CONFIGS.curieFilterConfig, + }, + { + field: "taxon.name", + header: "Taxon", + body: taxonTemplate, + sortable: isEnabled, + filterConfig: FILTER_CONFIGS.taxonFilterConfig, + editor: (props) => + }, + { + field: "variantType.name", + header: "Variant Type", + body: variantTypeTemplate, + sortable: isEnabled, + filterConfig: FILTER_CONFIGS.variantTypeFilterConfig, + editor: (props) => + }, + { + field: "variantStatus.name", + header: "Variant Status", + sortable: isEnabled, + filterConfig: FILTER_CONFIGS.variantStatusFilterConfig, + editor: (props) => variantStatusEditor(props) + }, + { + field: "relatedNotes.freeText", + header: "Related Notes", + body: relatedNotesTemplate, + sortable: true, + filterConfig: FILTER_CONFIGS.relatedNotesFilterConfig, + editor: relatedNotesEditor + }, + { + field: "sourceGeneralConsequence.name", + header: "Source General Consequence", + body: sourceGeneralConsequenceTemplate, + sortable: isEnabled, + filterConfig: FILTER_CONFIGS.sourceGeneralConsequenceFilterConfig, + editor: (props) => + }, + { + field: "dataProvider.sourceOrganization.abbreviation", + header: "Data Provider", + sortable: isEnabled, + filterConfig: FILTER_CONFIGS.variantDataProviderFilterConfig, + }, + { + field: "updatedBy.uniqueId", + header: "Updated By", + sortable: isEnabled, + filterConfig: FILTER_CONFIGS.updatedByFilterConfig, + }, + { + field: "dateUpdated", + header: "Date Updated", + sortable: isEnabled, + filter: true, + filterConfig: FILTER_CONFIGS.dateUpdatedFilterConfig + }, + { + field: "createdBy.uniqueId", + header: "Created By", + sortable: isEnabled, + filter: true, + filterConfig: FILTER_CONFIGS.createdByFilterConfig + }, + { + field: "dateCreated", + header: "Date Created", + sortable: isEnabled, + filter: true, + filterConfig: FILTER_CONFIGS.dataCreatedFilterConfig + }, + { + field: "internal", + header: "Internal", + body: internalTemplate, + filter: true, + filterConfig: FILTER_CONFIGS.internalFilterConfig, + sortable: isEnabled, + editor: (props) => ( + + ) + }, + { + field: "obsolete", + header: "Obsolete", + body: obsoleteTemplate, + filter: true, + filterConfig: FILTER_CONFIGS.obsoleteFilterConfig, + sortable: isEnabled, + editor: (props) => ( + + ) + } + ]; + + const defaultColumnNames = columns.map((col) => { + return col.header; + }); + + const widthsObject = {}; + + columns.forEach((col) => { + widthsObject[col.field] = 10; + }); + + const initialTableState = getDefaultTableState("Variants", defaultColumnNames, undefined, widthsObject); + + return ( + <> +
+ + + +
+ + + ); +}; diff --git a/src/main/cliapp/src/containers/variantsPage/index.js b/src/main/cliapp/src/containers/variantsPage/index.js new file mode 100644 index 000000000..80d0bfe76 --- /dev/null +++ b/src/main/cliapp/src/containers/variantsPage/index.js @@ -0,0 +1,3 @@ +import VariantsPage from "./VariantsPage"; + +export { VariantsPage }; \ No newline at end of file diff --git a/src/main/cliapp/src/routes.js b/src/main/cliapp/src/routes.js index 2f8a7b1eb..e25df3dc3 100644 --- a/src/main/cliapp/src/routes.js +++ b/src/main/cliapp/src/routes.js @@ -14,6 +14,7 @@ import { ConditionRelationPage } from './containers/conditionRelationPage'; import { AffectedGenomicModelPage } from './containers/affectedGenomicModelPage'; import { AllelesPage, AlleleDetailPage } from './containers/allelesPage'; import { GenesPage } from './containers/genesPage'; +import { VariantsPage} from './containers/variantsPage'; import { ConstructsPage } from './containers/constructsPage'; import { ProfilePage } from './containers/profilePage'; import { MoleculesPage } from './containers/moleculesPage'; @@ -47,6 +48,7 @@ export default ( } /> } /> } /> + } /> } /> } /> } /> diff --git a/src/main/cliapp/src/service/AlleleService.js b/src/main/cliapp/src/service/AlleleService.js index 229f48eb9..d9ebc2f9a 100644 --- a/src/main/cliapp/src/service/AlleleService.js +++ b/src/main/cliapp/src/service/AlleleService.js @@ -12,7 +12,7 @@ export class AlleleService extends BaseAuthService { async deleteAllele(allele) { const deletionService = new DeletionService(); - return await deletionService.delete(`allele`, allele.id); + return await deletionService.delete(`allele`, allele.curie); } async getAllele(curie) { diff --git a/src/main/cliapp/src/service/VariantService.js b/src/main/cliapp/src/service/VariantService.js new file mode 100644 index 000000000..ad83bb125 --- /dev/null +++ b/src/main/cliapp/src/service/VariantService.js @@ -0,0 +1,22 @@ +import { BaseAuthService } from './BaseAuthService'; +import { DeletionService } from './DeletionService'; + +export class VariantService extends BaseAuthService { + saveVariant(updatedVariant) { + return this.api.put(`/variant`, updatedVariant); + } + + createVariant(newVariant) { + return this.api.post(`/variant`, newVariant); + } + + async deleteVariant(variant) { + const deletionService = new DeletionService(); + return await deletionService.delete(`variant`, variant.curie); + } + + async getVariant(curie) { + return this.api.get(`/variant/${curie}`); + } +} + From 2f6b81b19dfda99695b6f89ba9ce33eb535da9a6 Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Thu, 12 Oct 2023 18:17:13 +0100 Subject: [PATCH 30/76] Update deprecation method and add term --- .../alliancegenome/curation_api/services/VariantService.java | 2 +- src/main/resources/db/migration/v0.27.0.7__add_variants.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/alliancegenome/curation_api/services/VariantService.java b/src/main/java/org/alliancegenome/curation_api/services/VariantService.java index 1b059ba9c..4e9080d31 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/VariantService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/VariantService.java @@ -57,7 +57,7 @@ public Variant upsert(VariantDTO dto, BackendBulkDataProvider dataProvider) thro } @Transactional - public void removeOrDeprecateNonUpdated(String curie, String dataProviderName, String md5sum) { + public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { Variant variant = variantDAO.find(curie); if (variant != null) { List notesToDelete = variant.getRelatedNotes(); diff --git a/src/main/resources/db/migration/v0.27.0.7__add_variants.sql b/src/main/resources/db/migration/v0.27.0.7__add_variants.sql index 6364677a6..7f1339b71 100644 --- a/src/main/resources/db/migration/v0.27.0.7__add_variants.sql +++ b/src/main/resources/db/migration/v0.27.0.7__add_variants.sql @@ -51,7 +51,7 @@ ALTER TABLE variant_note_aud ADD CONSTRAINT variant_note_aud_rev_fk FOREIGN KEY INSERT INTO vocabulary (id, name, vocabularylabel) VALUES (nextval('hibernate_sequence'), 'Variant Status', 'variant_status'); --- INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('hibernate_sequence'), 'live', id FROM vocabulary WHERE vocabularylabel = 'variant_status'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('hibernate_sequence'), 'public', id FROM vocabulary WHERE vocabularylabel = 'variant_status'; CREATE TABLE tmp_vocab_link ( vocabularytermsets_id bigint, From 9f340bf449e82c741242dbbcedeecd0595748912 Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Thu, 12 Oct 2023 19:46:28 +0100 Subject: [PATCH 31/76] Add missing @Transactional --- .../alleleAssociations/AlleleGeneAssociationService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java index 8bc064d4f..7d197f581 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java @@ -91,6 +91,7 @@ public List getAlleleGeneAssociationsByDataProvider(BackendBulkDataProvide return associationIds; } + @Transactional public AlleleGeneAssociation deprecateOrDeleteAssociation(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { AlleleGeneAssociation association = alleleGeneAssociationDAO.find(id); From 9e8913576a8693ca37196e041e22c994c0d354d9 Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Thu, 12 Oct 2023 20:18:10 +0100 Subject: [PATCH 32/76] Use authenticatedPerson for ID lookup --- .../curation_api/services/DiseaseAnnotationService.java | 5 ++++- .../alleleAssociations/AlleleGeneAssociationService.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java index ac1980d3f..9c86e9c9c 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java @@ -13,6 +13,7 @@ import org.alliancegenome.curation_api.dao.CrossReferenceDAO; import org.alliancegenome.curation_api.dao.DataProviderDAO; import org.alliancegenome.curation_api.dao.DiseaseAnnotationDAO; +import org.alliancegenome.curation_api.dao.PersonDAO; import org.alliancegenome.curation_api.exceptions.ApiErrorException; import org.alliancegenome.curation_api.model.entities.ConditionRelation; import org.alliancegenome.curation_api.model.entities.DiseaseAnnotation; @@ -42,6 +43,8 @@ public class DiseaseAnnotationService extends BaseEntityCrudService Date: Thu, 12 Oct 2023 22:19:08 +0100 Subject: [PATCH 33/76] Add missing return to avoid deletion --- .../alleleAssociations/AlleleGeneAssociationService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java index 586f9268a..91f01f885 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java @@ -119,6 +119,7 @@ public AlleleGeneAssociation deprecateOrDeleteAssociation(Long id, Boolean throw association.setDateUpdated(OffsetDateTime.now()); return alleleGeneAssociationDAO.persist(association); } + return association; } Long noteId = null; From f24d7f0d8e3440d74da6aea0ccfa9d280825a96f Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Thu, 12 Oct 2023 23:05:34 +0100 Subject: [PATCH 34/76] Remove unused DAO injection --- .../org/alliancegenome/curation_api/services/VariantService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/alliancegenome/curation_api/services/VariantService.java b/src/main/java/org/alliancegenome/curation_api/services/VariantService.java index 4e9080d31..1ea521e70 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/VariantService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/VariantService.java @@ -27,7 +27,6 @@ public class VariantService extends BaseDTOCrudService { @Inject VariantDAO variantDAO; - @Inject PersonService personService; @Inject NoteService noteService; @Inject VariantValidator variantValidator; @Inject VariantDTOValidator variantDtoValidator; From 7723725806a6c755baaa82540c75e2c2aad2c4e1 Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Thu, 12 Oct 2023 23:36:05 +0100 Subject: [PATCH 35/76] Add entity constants --- .../curation_api/constants/EntityConstants.java | 8 ++++++++ .../org/alliancegenome/curation_api/dao/VariantDAO.java | 8 -------- .../services/AGMDiseaseAnnotationService.java | 5 +++-- .../services/AffectedGenomicModelService.java | 3 ++- .../services/AlleleDiseaseAnnotationService.java | 5 +++-- .../curation_api/services/AlleleService.java | 3 ++- .../curation_api/services/ConstructService.java | 3 ++- .../services/GeneDiseaseAnnotationService.java | 5 +++-- .../alliancegenome/curation_api/services/GeneService.java | 5 +++-- .../curation_api/services/VariantService.java | 7 ++++++- 10 files changed, 32 insertions(+), 20 deletions(-) create mode 100644 src/main/java/org/alliancegenome/curation_api/constants/EntityConstants.java diff --git a/src/main/java/org/alliancegenome/curation_api/constants/EntityConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/EntityConstants.java new file mode 100644 index 000000000..d0bf4b615 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/constants/EntityConstants.java @@ -0,0 +1,8 @@ +package org.alliancegenome.curation_api.constants; + +public final class EntityConstants { + + public static final String DATA_PROVIDER = "dataProvider.sourceOrganization.abbreviation"; + public static final String SUBJECT_TAXON = "subject.taxon.curie" + +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/dao/VariantDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/VariantDAO.java index 1b14faa21..b91149b2c 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/VariantDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/VariantDAO.java @@ -1,7 +1,5 @@ package org.alliancegenome.curation_api.dao; -import java.util.List; - import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import javax.persistence.Query; @@ -19,12 +17,6 @@ protected VariantDAO() { super(Variant.class); } - public List findAllCuriesByDataProvider(String dataProvider) { - Query jpqlQuery = entityManager.createQuery("SELECT variant.curie FROM Variant variant WHERE variant.dataProvider.sourceOrganization.abbreviation = :dataProvider"); - jpqlQuery.setParameter("dataProvider", dataProvider); - return (List) jpqlQuery.getResultList(); - } - public void deleteAttachedNote(Long id) { Query jpqlQuery = entityManager.createNativeQuery("DELETE FROM variant_note WHERE relatednotes_id = '" + id + "'"); jpqlQuery.executeUpdate(); diff --git a/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java index 3f93baef6..5da369281 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java @@ -11,6 +11,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; +import org.alliancegenome.curation_api.constants.EntityConstants; import org.alliancegenome.curation_api.dao.AGMDiseaseAnnotationDAO; import org.alliancegenome.curation_api.dao.ConditionRelationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; @@ -99,9 +100,9 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); - params.put("dataProvider.sourceOrganization.abbreviation", dataProvider.sourceOrganization); + params.put(EntityConstants.DATA_PROVIDER, dataProvider.sourceOrganization); if(StringUtils.equals(dataProvider.sourceOrganization, "RGD")) - params.put("subject.taxon.curie", dataProvider.canonicalTaxonCurie); + params.put(EntityConstants.SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); List annotationIdStrings = agmDiseaseAnnotationDAO.findFilteredIds(params); annotationIdStrings.removeIf(Objects::isNull); List annotationIds = annotationIdStrings.stream().map(Long::parseLong).collect(Collectors.toList()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java b/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java index 7129e8af5..eec052bff 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java @@ -11,6 +11,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; +import org.alliancegenome.curation_api.constants.EntityConstants; import org.alliancegenome.curation_api.dao.AffectedGenomicModelDAO; import org.alliancegenome.curation_api.dao.AlleleDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; @@ -101,7 +102,7 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getCuriesByDataProvider(String dataProvider) { Map params = new HashMap<>(); - params.put("dataProvider.sourceOrganization.abbreviation", dataProvider); + params.put(EntityConstants.DATA_PROVIDER, dataProvider); List curies = agmDAO.findFilteredIds(params); curies.removeIf(Objects::isNull); return curies; diff --git a/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java index 883324c2b..cc5a4dd5a 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java @@ -11,6 +11,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; +import org.alliancegenome.curation_api.constants.EntityConstants; import org.alliancegenome.curation_api.dao.AlleleDiseaseAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; @@ -96,9 +97,9 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); - params.put("dataProvider.sourceOrganization.abbreviation", dataProvider.sourceOrganization); + params.put(EntityConstants.DATA_PROVIDER, dataProvider.sourceOrganization); if(StringUtils.equals(dataProvider.sourceOrganization, "RGD")) - params.put("subject.taxon.curie", dataProvider.canonicalTaxonCurie); + params.put(EntityConstants.SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); List annotationIdStrings = alleleDiseaseAnnotationDAO.findFilteredIds(params); annotationIdStrings.removeIf(Objects::isNull); List annotationIds = annotationIdStrings.stream().map(Long::parseLong).collect(Collectors.toList()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java b/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java index 92b39d42f..b926abf3b 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java @@ -11,6 +11,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; +import org.alliancegenome.curation_api.constants.EntityConstants; import org.alliancegenome.curation_api.dao.AlleleDAO; import org.alliancegenome.curation_api.dao.slotAnnotations.alleleSlotAnnotations.AlleleFullNameSlotAnnotationDAO; import org.alliancegenome.curation_api.dao.slotAnnotations.alleleSlotAnnotations.AlleleInheritanceModeSlotAnnotationDAO; @@ -121,7 +122,7 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getCuriesByDataProvider(String dataProvider) { Map params = new HashMap<>(); - params.put("dataProvider.sourceOrganization.abbreviation", dataProvider); + params.put(EntityConstants.DATA_PROVIDER, dataProvider); List curies = alleleDAO.findFilteredIds(params); curies.removeIf(Objects::isNull); return curies; diff --git a/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java b/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java index ce3ce533d..d2aebfb58 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java @@ -12,6 +12,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; +import org.alliancegenome.curation_api.constants.EntityConstants; import org.alliancegenome.curation_api.dao.ConstructDAO; import org.alliancegenome.curation_api.dao.slotAnnotations.constructSlotAnnotations.ConstructComponentSlotAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; @@ -147,7 +148,7 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getConstructIdsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); - params.put("dataProvider.sourceOrganization.abbreviation", dataProvider.sourceOrganization); + params.put(EntityConstants.DATA_PROVIDER, dataProvider.sourceOrganization); List constructIdStrings = constructDAO.findFilteredIds(params); constructIdStrings.removeIf(Objects::isNull); List constructIds = constructIdStrings.stream().map(Long::parseLong).collect(Collectors.toList()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java index 93ff301df..7b3f79086 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java @@ -11,6 +11,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; +import org.alliancegenome.curation_api.constants.EntityConstants; import org.alliancegenome.curation_api.dao.GeneDiseaseAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; @@ -96,9 +97,9 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); - params.put("dataProvider.sourceOrganization.abbreviation", dataProvider.sourceOrganization); + params.put(EntityConstants.DATA_PROVIDER, dataProvider.sourceOrganization); if(StringUtils.equals(dataProvider.sourceOrganization, "RGD")) - params.put("subject.taxon.curie", dataProvider.canonicalTaxonCurie); + params.put(EntityConstants.SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); List annotationIdStrings = geneDiseaseAnnotationDAO.findFilteredIds(params); annotationIdStrings.removeIf(Objects::isNull); List annotationIds = annotationIdStrings.stream().map(Long::parseLong).collect(Collectors.toList()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneService.java index a3ebafcc2..0efc3366e 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneService.java @@ -11,6 +11,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; +import org.alliancegenome.curation_api.constants.EntityConstants; import org.alliancegenome.curation_api.dao.GeneDAO; import org.alliancegenome.curation_api.dao.slotAnnotations.geneSlotAnnotations.GeneFullNameSlotAnnotationDAO; import org.alliancegenome.curation_api.dao.slotAnnotations.geneSlotAnnotations.GeneSymbolSlotAnnotationDAO; @@ -135,9 +136,9 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getCuriesByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); - params.put("dataProvider.sourceOrganization.abbreviation", dataProvider.sourceOrganization); + params.put(EntityConstants.DATA_PROVIDER, dataProvider.sourceOrganization); if(StringUtils.equals(dataProvider.sourceOrganization, "RGD")) - params.put("taxon.curie", dataProvider.canonicalTaxonCurie); + params.put(EntityConstants.SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); List curies = geneDAO.findFilteredIds(params); curies.removeIf(Objects::isNull); diff --git a/src/main/java/org/alliancegenome/curation_api/services/VariantService.java b/src/main/java/org/alliancegenome/curation_api/services/VariantService.java index 1ea521e70..7e54d9c06 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/VariantService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/VariantService.java @@ -1,6 +1,8 @@ package org.alliancegenome.curation_api.services; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; import javax.annotation.PostConstruct; @@ -8,6 +10,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; +import org.alliancegenome.curation_api.constants.EntityConstants; import org.alliancegenome.curation_api.dao.VariantDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; @@ -69,7 +72,9 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { } public List getCuriesByDataProvider(String dataProvider) { - List curies = variantDAO.findAllCuriesByDataProvider(dataProvider); + Map params = new HashMap<>(); + params.put(EntityConstants.DATA_PROVIDER, dataProvider); + List curies = variantDAO.findFilteredIds(params); curies.removeIf(Objects::isNull); return curies; } From 37583860044c3a5e9dbeb9388e757ae0213a80fe Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Thu, 12 Oct 2023 23:38:15 +0100 Subject: [PATCH 36/76] Add missing semicolon --- .../alliancegenome/curation_api/constants/EntityConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/alliancegenome/curation_api/constants/EntityConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/EntityConstants.java index d0bf4b615..a69803d34 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/EntityConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/EntityConstants.java @@ -3,6 +3,6 @@ public final class EntityConstants { public static final String DATA_PROVIDER = "dataProvider.sourceOrganization.abbreviation"; - public static final String SUBJECT_TAXON = "subject.taxon.curie" + public static final String SUBJECT_TAXON = "subject.taxon.curie"; } \ No newline at end of file From f69a7dcd7ea48186c401457c4e1e47ba6efc0448 Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 00:03:12 +0100 Subject: [PATCH 37/76] Check for Okta email --- .../curation_api/services/DiseaseAnnotationService.java | 2 +- .../alleleAssociations/AlleleGeneAssociationService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java index 9c86e9c9c..66bc06302 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java @@ -99,7 +99,7 @@ public DiseaseAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean th if (deprecateAnnotation) { if (!annotation.getObsolete()) { annotation.setObsolete(true); - if (authenticatedPerson != null) { + if (authenticatedPerson.getOktaEmail() != null) { annotation.setUpdatedBy(personDAO.find(authenticatedPerson.getId())); } else { annotation.setUpdatedBy(personService.fetchByUniqueIdOrCreate(loadDescription)); diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java index 91f01f885..d76bda195 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java @@ -111,7 +111,7 @@ public AlleleGeneAssociation deprecateOrDeleteAssociation(Long id, Boolean throw if (deprecate) { if (!association.getObsolete()) { association.setObsolete(true); - if (authenticatedPerson != null) { + if (authenticatedPerson.getOktaEmail() != null) { association.setUpdatedBy(personDAO.find(authenticatedPerson.getId())); } else { association.setUpdatedBy(personService.fetchByUniqueIdOrCreate(loadDescription)); From 602bb86d486742f3b1bb5a929778cf2f02ae1aad Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 09:14:10 +0100 Subject: [PATCH 38/76] Rename constants --- .../{EntityConstants.java => EntityFieldConstants.java} | 2 +- .../curation_api/services/AGMDiseaseAnnotationService.java | 6 +++--- .../curation_api/services/AffectedGenomicModelService.java | 4 ++-- .../services/AlleleDiseaseAnnotationService.java | 6 +++--- .../alliancegenome/curation_api/services/AlleleService.java | 4 ++-- .../curation_api/services/ConstructService.java | 4 ++-- .../curation_api/services/GeneDiseaseAnnotationService.java | 6 +++--- .../alliancegenome/curation_api/services/GeneService.java | 6 +++--- .../curation_api/services/VariantService.java | 4 ++-- 9 files changed, 21 insertions(+), 21 deletions(-) rename src/main/java/org/alliancegenome/curation_api/constants/{EntityConstants.java => EntityFieldConstants.java} (83%) diff --git a/src/main/java/org/alliancegenome/curation_api/constants/EntityConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java similarity index 83% rename from src/main/java/org/alliancegenome/curation_api/constants/EntityConstants.java rename to src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java index a69803d34..c534f1d80 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/EntityConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java @@ -1,6 +1,6 @@ package org.alliancegenome.curation_api.constants; -public final class EntityConstants { +public final class EntityFieldConstants { public static final String DATA_PROVIDER = "dataProvider.sourceOrganization.abbreviation"; public static final String SUBJECT_TAXON = "subject.taxon.curie"; diff --git a/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java index 5da369281..c288c0bdd 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java @@ -11,7 +11,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; -import org.alliancegenome.curation_api.constants.EntityConstants; +import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.AGMDiseaseAnnotationDAO; import org.alliancegenome.curation_api.dao.ConditionRelationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; @@ -100,9 +100,9 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); - params.put(EntityConstants.DATA_PROVIDER, dataProvider.sourceOrganization); + params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider.sourceOrganization); if(StringUtils.equals(dataProvider.sourceOrganization, "RGD")) - params.put(EntityConstants.SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); + params.put(EntityFieldConstants.SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); List annotationIdStrings = agmDiseaseAnnotationDAO.findFilteredIds(params); annotationIdStrings.removeIf(Objects::isNull); List annotationIds = annotationIdStrings.stream().map(Long::parseLong).collect(Collectors.toList()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java b/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java index eec052bff..b4bb68827 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java @@ -11,7 +11,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; -import org.alliancegenome.curation_api.constants.EntityConstants; +import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.AffectedGenomicModelDAO; import org.alliancegenome.curation_api.dao.AlleleDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; @@ -102,7 +102,7 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getCuriesByDataProvider(String dataProvider) { Map params = new HashMap<>(); - params.put(EntityConstants.DATA_PROVIDER, dataProvider); + params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider); List curies = agmDAO.findFilteredIds(params); curies.removeIf(Objects::isNull); return curies; diff --git a/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java index cc5a4dd5a..51c04a4fb 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java @@ -11,7 +11,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; -import org.alliancegenome.curation_api.constants.EntityConstants; +import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.AlleleDiseaseAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; @@ -97,9 +97,9 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); - params.put(EntityConstants.DATA_PROVIDER, dataProvider.sourceOrganization); + params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider.sourceOrganization); if(StringUtils.equals(dataProvider.sourceOrganization, "RGD")) - params.put(EntityConstants.SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); + params.put(EntityFieldConstants.SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); List annotationIdStrings = alleleDiseaseAnnotationDAO.findFilteredIds(params); annotationIdStrings.removeIf(Objects::isNull); List annotationIds = annotationIdStrings.stream().map(Long::parseLong).collect(Collectors.toList()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java b/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java index b926abf3b..768f524e1 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java @@ -11,7 +11,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; -import org.alliancegenome.curation_api.constants.EntityConstants; +import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.AlleleDAO; import org.alliancegenome.curation_api.dao.slotAnnotations.alleleSlotAnnotations.AlleleFullNameSlotAnnotationDAO; import org.alliancegenome.curation_api.dao.slotAnnotations.alleleSlotAnnotations.AlleleInheritanceModeSlotAnnotationDAO; @@ -122,7 +122,7 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getCuriesByDataProvider(String dataProvider) { Map params = new HashMap<>(); - params.put(EntityConstants.DATA_PROVIDER, dataProvider); + params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider); List curies = alleleDAO.findFilteredIds(params); curies.removeIf(Objects::isNull); return curies; diff --git a/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java b/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java index d2aebfb58..acf1083c7 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java @@ -12,7 +12,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; -import org.alliancegenome.curation_api.constants.EntityConstants; +import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.ConstructDAO; import org.alliancegenome.curation_api.dao.slotAnnotations.constructSlotAnnotations.ConstructComponentSlotAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; @@ -148,7 +148,7 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getConstructIdsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); - params.put(EntityConstants.DATA_PROVIDER, dataProvider.sourceOrganization); + params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider.sourceOrganization); List constructIdStrings = constructDAO.findFilteredIds(params); constructIdStrings.removeIf(Objects::isNull); List constructIds = constructIdStrings.stream().map(Long::parseLong).collect(Collectors.toList()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java index 7b3f79086..dce149c30 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java @@ -11,7 +11,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; -import org.alliancegenome.curation_api.constants.EntityConstants; +import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.GeneDiseaseAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; @@ -97,9 +97,9 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); - params.put(EntityConstants.DATA_PROVIDER, dataProvider.sourceOrganization); + params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider.sourceOrganization); if(StringUtils.equals(dataProvider.sourceOrganization, "RGD")) - params.put(EntityConstants.SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); + params.put(EntityFieldConstants.SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); List annotationIdStrings = geneDiseaseAnnotationDAO.findFilteredIds(params); annotationIdStrings.removeIf(Objects::isNull); List annotationIds = annotationIdStrings.stream().map(Long::parseLong).collect(Collectors.toList()); diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneService.java index 0efc3366e..03ea7ce2f 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneService.java @@ -11,7 +11,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; -import org.alliancegenome.curation_api.constants.EntityConstants; +import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.GeneDAO; import org.alliancegenome.curation_api.dao.slotAnnotations.geneSlotAnnotations.GeneFullNameSlotAnnotationDAO; import org.alliancegenome.curation_api.dao.slotAnnotations.geneSlotAnnotations.GeneSymbolSlotAnnotationDAO; @@ -136,9 +136,9 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getCuriesByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); - params.put(EntityConstants.DATA_PROVIDER, dataProvider.sourceOrganization); + params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider.sourceOrganization); if(StringUtils.equals(dataProvider.sourceOrganization, "RGD")) - params.put(EntityConstants.SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); + params.put(EntityFieldConstants.SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); List curies = geneDAO.findFilteredIds(params); curies.removeIf(Objects::isNull); diff --git a/src/main/java/org/alliancegenome/curation_api/services/VariantService.java b/src/main/java/org/alliancegenome/curation_api/services/VariantService.java index 7e54d9c06..9f37c2cf4 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/VariantService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/VariantService.java @@ -10,7 +10,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; -import org.alliancegenome.curation_api.constants.EntityConstants; +import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.VariantDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; @@ -73,7 +73,7 @@ public void removeOrDeprecateNonUpdated(String curie, String loadDescription) { public List getCuriesByDataProvider(String dataProvider) { Map params = new HashMap<>(); - params.put(EntityConstants.DATA_PROVIDER, dataProvider); + params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider); List curies = variantDAO.findFilteredIds(params); curies.removeIf(Objects::isNull); return curies; From d1a772c2c5f00a3bfff14bac7db31d0b904cdb3f Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 09:28:38 +0100 Subject: [PATCH 39/76] Deal with failure to convert to Long --- .../curation_api/dao/base/BaseSQLDAO.java | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java index d0e3509bc..9b952f349 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java @@ -116,13 +116,9 @@ public List findFilteredIds(Map params) { List primaryKeys = new ArrayList<>(); SearchResponse results = findByParams(params); for (E entity : results.getResults()) { - String pkString; - try { - pkString = (String) entityManager.getEntityManagerFactory().getPersistenceUnitUtil().getIdentifier(entity); - } catch (ClassCastException e) { - pkString = Long.toString((Long) entityManager.getEntityManagerFactory().getPersistenceUnitUtil().getIdentifier(entity)); - } - primaryKeys.add(pkString); + String pkString = returnStringId(entity); + if (pkString != null) + primaryKeys.add(pkString); } return primaryKeys; @@ -145,19 +141,29 @@ public SearchResponse findAllIds() { List primaryKeys = new ArrayList<>(); for (E entity : allQuery.getResultList()) { - String pkString; - try { - pkString = (String) entityManager.getEntityManagerFactory().getPersistenceUnitUtil().getIdentifier(entity); - } catch (ClassCastException e) { - pkString = Long.toString((Long) entityManager.getEntityManagerFactory().getPersistenceUnitUtil().getIdentifier(entity)); - } - primaryKeys.add(pkString); + String pkString = returnStringId(entity); + if (pkString != null) + primaryKeys.add(pkString); } results.setResults(primaryKeys); results.setTotalResults(totalResults); return results; } + + private String returnStringId(E entity) { + String pkString = null; + try { + pkString = (String) entityManager.getEntityManagerFactory().getPersistenceUnitUtil().getIdentifier(entity); + } catch (ClassCastException e) { + try { + pkString = Long.toString((Long) entityManager.getEntityManagerFactory().getPersistenceUnitUtil().getIdentifier(entity)); + } catch (Exception ex) { + Log.error("Could not convert entity ID to string: " + ex.getMessage()); + } + } + return pkString; + } public SearchResponse findAll(Pagination pagination) { Log.debug("SqlDAO: findAll: " + myClass); From 273485fd4a452ee4f3af00487e9da2fc97a7e51b Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 10:09:33 +0100 Subject: [PATCH 40/76] Add new entity field constant --- .../curation_api/constants/EntityFieldConstants.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java index c534f1d80..ea0f6ae51 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java @@ -3,6 +3,7 @@ public final class EntityFieldConstants { public static final String DATA_PROVIDER = "dataProvider.sourceOrganization.abbreviation"; + public static final String SUBJECT_DATA_PROVIDER = "subject." + DATA_PROVIDER; public static final String SUBJECT_TAXON = "subject.taxon.curie"; } \ No newline at end of file From aeb1cdd2f2a69316f11c507986d648779894fd3f Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 10:10:14 +0100 Subject: [PATCH 41/76] More fixes --- .../curation_api/jobs/executors/LoadFileExecutor.java | 2 +- .../alleleAssociations/AlleleGeneAssociationService.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java index 7a798290a..44f35eebb 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java @@ -210,7 +210,7 @@ public void runCleanup(DiseaseAnnotationService service, BulkLoadFileHistory his for (Long id : idsToRemove) { try { String loadDescription = dataProviderName + " association bulk load (" + md5sum + ")"; - service.deprecateOrDeleteAssociation(id, false, loadDescription, true); + service.deprecateOrDeleteAssociation(id, false, loadDescription, false); history.incrementDeleted(); } catch (Exception e) { history.incrementDeleteFailed(); diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java index cb57fa68c..981ab149a 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java @@ -13,6 +13,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; +import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.AlleleDAO; import org.alliancegenome.curation_api.dao.GeneDAO; import org.alliancegenome.curation_api.dao.NoteDAO; @@ -89,7 +90,7 @@ public AlleleGeneAssociation upsert(AlleleGeneAssociationDTO dto, BackendBulkDat public List getAlleleGeneAssociationsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); - params.put("subject.dataProvider.sourceOrganization.abbreviation", dataProvider.sourceOrganization); + params.put(EntityFieldConstants.SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); List associationIdStrings = alleleGeneAssociationDAO.findFilteredIds(params); associationIdStrings.removeIf(Objects::isNull); List associationIds = associationIdStrings.stream().map(Long::parseLong).collect(Collectors.toList()); @@ -114,7 +115,7 @@ public AlleleGeneAssociation deprecateOrDeleteAssociation(Long id, Boolean throw if (deprecate) { if (!association.getObsolete()) { association.setObsolete(true); - if (authenticatedPerson.getOktaEmail() != null) { + if (authenticatedPerson.getId() != null) { association.setUpdatedBy(personDAO.find(authenticatedPerson.getId())); } else { association.setUpdatedBy(personService.fetchByUniqueIdOrCreate(loadDescription)); From 176b5e18242aef3670003f8fea3372e8d4225fdb Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 10:14:20 +0100 Subject: [PATCH 42/76] Also change DA service --- .../curation_api/services/DiseaseAnnotationService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java index 66bc06302..36c6e8ae2 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/DiseaseAnnotationService.java @@ -99,7 +99,7 @@ public DiseaseAnnotation deprecateOrDeleteAnnotationAndNotes(Long id, Boolean th if (deprecateAnnotation) { if (!annotation.getObsolete()) { annotation.setObsolete(true); - if (authenticatedPerson.getOktaEmail() != null) { + if (authenticatedPerson.getId() != null) { annotation.setUpdatedBy(personDAO.find(authenticatedPerson.getId())); } else { annotation.setUpdatedBy(personService.fetchByUniqueIdOrCreate(loadDescription)); From 33be3160efa3b50f4b40cc3bb5e47b349340383a Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 12:10:15 +0100 Subject: [PATCH 43/76] Initial ConstructGenomicEntityAssociation code --- .../constants/EntityFieldConstants.java | 1 + .../curation_api/dao/GenomicEntityDAO.java | 15 ++ .../ConstructGenomicEntityAssociationDAO.java | 28 +++ .../enums/BackendBulkLoadType.java | 2 +- .../model/entities/Construct.java | 6 + .../model/entities/GenomicEntity.java | 8 + .../ConstructGenomicEntityAssociation.java | 72 +++++++ .../ConstructGenomicEntityAssociationDTO.java | 38 ++++ ...structGenomicEntityAssociationService.java | 180 ++++++++++++++++ ...ructGenomicEntityAssociationValidator.java | 202 ++++++++++++++++++ ...tGenomicEntityAssociationDTOValidator.java | 142 ++++++++++++ 11 files changed, 693 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/alliancegenome/curation_api/dao/GenomicEntityDAO.java create mode 100644 src/main/java/org/alliancegenome/curation_api/dao/associations/constructAssociations/ConstructGenomicEntityAssociationDAO.java create mode 100644 src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java create mode 100644 src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTO.java create mode 100644 src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java create mode 100644 src/main/java/org/alliancegenome/curation_api/services/validation/associations/constructAssociations/ConstructGenomicEntityAssociationValidator.java create mode 100644 src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTOValidator.java diff --git a/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java index c534f1d80..ea0f6ae51 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java @@ -3,6 +3,7 @@ public final class EntityFieldConstants { public static final String DATA_PROVIDER = "dataProvider.sourceOrganization.abbreviation"; + public static final String SUBJECT_DATA_PROVIDER = "subject." + DATA_PROVIDER; public static final String SUBJECT_TAXON = "subject.taxon.curie"; } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/dao/GenomicEntityDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/GenomicEntityDAO.java new file mode 100644 index 000000000..e013121ac --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/dao/GenomicEntityDAO.java @@ -0,0 +1,15 @@ +package org.alliancegenome.curation_api.dao; + +import javax.enterprise.context.ApplicationScoped; + +import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; +import org.alliancegenome.curation_api.model.entities.GenomicEntity; + +@ApplicationScoped +public class GenomicEntityDAO extends BaseSQLDAO { + + protected GenomicEntityDAO() { + super(GenomicEntity.class); + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/dao/associations/constructAssociations/ConstructGenomicEntityAssociationDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/associations/constructAssociations/ConstructGenomicEntityAssociationDAO.java new file mode 100644 index 000000000..50caa22b6 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/dao/associations/constructAssociations/ConstructGenomicEntityAssociationDAO.java @@ -0,0 +1,28 @@ +package org.alliancegenome.curation_api.dao.associations.constructAssociations; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.persistence.Query; + +import org.alliancegenome.curation_api.dao.NoteDAO; +import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; +import org.alliancegenome.curation_api.model.entities.associations.constructAssociations.ConstructGenomicEntityAssociation; + +@ApplicationScoped +public class ConstructGenomicEntityAssociationDAO extends BaseSQLDAO { + + @Inject + NoteDAO noteDAO; + + protected ConstructGenomicEntityAssociationDAO() { + super(ConstructGenomicEntityAssociation.class); + } + + public void deleteAttachedNote(Long id) { + Query jpqlQuery = entityManager.createNativeQuery("DELETE FROM constructgenomicentityassociation_note WHERE relatednotes_id = '" + id + "'"); + jpqlQuery.executeUpdate(); + + noteDAO.remove(id); + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/enums/BackendBulkLoadType.java b/src/main/java/org/alliancegenome/curation_api/enums/BackendBulkLoadType.java index b1f11d198..fa2d355ef 100644 --- a/src/main/java/org/alliancegenome/curation_api/enums/BackendBulkLoadType.java +++ b/src/main/java/org/alliancegenome/curation_api/enums/BackendBulkLoadType.java @@ -2,5 +2,5 @@ public enum BackendBulkLoadType { GENE_DTO, ALLELE_DTO, AGM_DTO, DISEASE_ANNOTATION_DTO, DISEASE_ANNOTATION, GENE, ALLELE, AGM, CONSTRUCT, AGM_DISEASE_ANNOTATION, ALLELE_DISEASE_ANNOTATION, GENE_DISEASE_ANNOTATION, ONTOLOGY, MOLECULE, - FULL_INGEST, RESOURCE_DESCRIPTOR, ORTHOLOGY, ALLELE_ASSOCIATION, VARIANT; + FULL_INGEST, RESOURCE_DESCRIPTOR, ORTHOLOGY, ALLELE_ASSOCIATION, CONSTRUCT_ASSOCIATION, VARIANT; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Construct.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Construct.java index 9211573b3..feeb41e29 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Construct.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Construct.java @@ -14,6 +14,7 @@ import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.associations.constructAssociations.ConstructGenomicEntityAssociation; import org.alliancegenome.curation_api.model.entities.slotAnnotations.constructSlotAnnotations.ConstructComponentSlotAnnotation; import org.alliancegenome.curation_api.model.entities.slotAnnotations.constructSlotAnnotations.ConstructFullNameSlotAnnotation; import org.alliancegenome.curation_api.model.entities.slotAnnotations.constructSlotAnnotations.ConstructSymbolSlotAnnotation; @@ -78,4 +79,9 @@ public class Construct extends Reagent { @JsonManagedReference @JsonView({ View.FieldsAndLists.class, View.ConstructView.class }) private List constructComponents; + + @IndexedEmbedded(includeDepth = 2) + @OneToMany(mappedBy = "subject", cascade = CascadeType.ALL) + @JsonView({ View.FieldsAndLists.class, View.AlleleDetailView.class }) + private List constructGenomicEntityAssociations; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/GenomicEntity.java b/src/main/java/org/alliancegenome/curation_api/model/entities/GenomicEntity.java index 528619a55..42fe3611c 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/GenomicEntity.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/GenomicEntity.java @@ -2,15 +2,18 @@ import java.util.List; +import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.Index; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; +import javax.persistence.OneToMany; import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.associations.constructAssociations.ConstructGenomicEntityAssociation; import org.alliancegenome.curation_api.view.View; import org.hibernate.envers.Audited; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; @@ -42,5 +45,10 @@ public class GenomicEntity extends BiologicalEntity { }) @JsonView({ View.FieldsAndLists.class }) private List crossReferences; + + @IndexedEmbedded(includeDepth = 2) + @OneToMany(mappedBy = "object", cascade = CascadeType.ALL) + @JsonView({ View.FieldsAndLists.class, View.GeneDetailView.class }) + private List constructGenomicEntityAssociations; } 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 new file mode 100644 index 000000000..2a09d54f2 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java @@ -0,0 +1,72 @@ +package org.alliancegenome.curation_api.model.entities.associations.constructAssociations; + +import java.util.List; + +import javax.persistence.Entity; +import javax.persistence.Index; +import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.Construct; +import org.alliancegenome.curation_api.model.entities.EvidenceAssociation; +import org.alliancegenome.curation_api.model.entities.GenomicEntity; +import org.alliancegenome.curation_api.model.entities.Note; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +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.envers.Audited; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonView; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Audited +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociation.class }) +@Schema(name = "ConstructGenomicEntityAssociation", description = "POJO representing an association between a construct and a genomic entity") +@Table(indexes = { + @Index(name = "constructgenomicentityassociation_subject_index", columnList = "subject_curie"), + @Index(name = "constructgenomicentityassociation_object_index", columnList = "object_curie"), + @Index(name = "constructgenomicentityassociation_relation_index", columnList = "relation_id") +}) +public class ConstructGenomicEntityAssociation extends EvidenceAssociation { + + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + @JsonIgnoreProperties("constructGenomicEntityAssociations") + @Fetch(FetchMode.JOIN) + private Construct subject; + + @IndexedEmbedded(includeDepth = 1) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private VocabularyTerm relation; + + @IndexedEmbedded(includeDepth = 1) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @OneToOne + @JsonView({ View.FieldsOnly.class }) + @JsonIgnoreProperties("constructGeneAssociations") + private GenomicEntity object; + + @IndexedEmbedded(includeDepth = 1) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @OneToOne + @JsonView({ View.FieldsAndLists.class, View.ConstructView.class }) + private List relatedNotes; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTO.java new file mode 100644 index 000000000..47ba3a4e7 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTO.java @@ -0,0 +1,38 @@ +package org.alliancegenome.curation_api.model.ingest.dto.associations.constructAssociations; + +import java.util.List; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.ingest.dto.NoteDTO; +import org.alliancegenome.curation_api.model.ingest.dto.associations.EvidenceAssociationDTO; +import org.alliancegenome.curation_api.view.View; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonView; + +import lombok.Getter; +import lombok.Setter; + +@Setter +@Getter +@AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociationDTO.class, NoteDTO.class }) +public class ConstructGenomicEntityAssociationDTO extends EvidenceAssociationDTO { + + @JsonView({ View.FieldsOnly.class }) + @JsonProperty("construct_identifier") + private String constructIdentifier; + + @JsonView({ View.FieldsOnly.class }) + @JsonProperty("genomic_entity_relation_name") + private String genomicEntityRelationName; + + @JsonView({ View.FieldsOnly.class }) + @JsonProperty("genomic_entity_curie") + private String genomicEntityCurie; + + @JsonView({ View.FieldsAndLists.class }) + @JsonProperty("note_dtos") + private List noteDtos; + +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java new file mode 100644 index 000000000..ced9d6948 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java @@ -0,0 +1,180 @@ +package org.alliancegenome.curation_api.services.associations.constructAssociations; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +import javax.annotation.PostConstruct; +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.transaction.Transactional; + +import org.alliancegenome.curation_api.constants.EntityFieldConstants; +import org.alliancegenome.curation_api.dao.ConstructDAO; +import org.alliancegenome.curation_api.dao.GenomicEntityDAO; +import org.alliancegenome.curation_api.dao.PersonDAO; +import org.alliancegenome.curation_api.dao.associations.constructAssociations.ConstructGenomicEntityAssociationDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ApiErrorException; +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.model.entities.Construct; +import org.alliancegenome.curation_api.model.entities.GenomicEntity; +import org.alliancegenome.curation_api.model.entities.Note; +import org.alliancegenome.curation_api.model.entities.associations.constructAssociations.ConstructGenomicEntityAssociation; +import org.alliancegenome.curation_api.model.ingest.dto.associations.constructAssociations.ConstructGenomicEntityAssociationDTO; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.response.SearchResponse; +import org.alliancegenome.curation_api.services.NoteService; +import org.alliancegenome.curation_api.services.PersonService; +import org.alliancegenome.curation_api.services.base.BaseAssociationDTOCrudService; +import org.alliancegenome.curation_api.services.validation.associations.constructAssociations.ConstructGenomicEntityAssociationValidator; +import org.alliancegenome.curation_api.services.validation.dto.associations.constructAssociations.ConstructGenomicEntityAssociationDTOValidator; +import org.apache.commons.collections.CollectionUtils; + +import lombok.extern.jbosslog.JBossLog; + +@JBossLog +@RequestScoped +public class ConstructGenomicEntityAssociationService extends BaseAssociationDTOCrudService { + + @Inject + ConstructGenomicEntityAssociationDAO constructGenomicEntityAssociationDAO; + @Inject + ConstructGenomicEntityAssociationValidator constructGenomicEntityAssociationValidator; + @Inject + ConstructGenomicEntityAssociationDTOValidator constructGenomicEntityAssociationDtoValidator; + @Inject + ConstructDAO constructDAO; + @Inject + NoteService noteService; + @Inject + GenomicEntityDAO genomicEntityDAO; + @Inject + PersonService personService; + @Inject + PersonDAO personDAO; + + @Override + @PostConstruct + protected void init() { + setSQLDao(constructGenomicEntityAssociationDAO); + } + + @Transactional + public ObjectResponse upsert(ConstructGenomicEntityAssociation uiEntity) { + ConstructGenomicEntityAssociation dbEntity = constructGenomicEntityAssociationValidator.validateConstructGenomicEntityAssociation(uiEntity, true, true); + if (dbEntity == null) + return null; + dbEntity = constructGenomicEntityAssociationDAO.persist(dbEntity); + addAssociationToConstruct(dbEntity); + addAssociationToGenomicEntity(dbEntity); + return new ObjectResponse(dbEntity); + } + + public ObjectResponse validate(ConstructGenomicEntityAssociation uiEntity) { + ConstructGenomicEntityAssociation aga = constructGenomicEntityAssociationValidator.validateConstructGenomicEntityAssociation(uiEntity, true, false); + return new ObjectResponse(aga); + } + + @Transactional + public ConstructGenomicEntityAssociation upsert(ConstructGenomicEntityAssociationDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + ConstructGenomicEntityAssociation association = constructGenomicEntityAssociationDtoValidator.validateConstructGenomicEntityAssociationDTO(dto, dataProvider); + if (association != null) { + addAssociationToConstruct(association); + addAssociationToGenomicEntity(association); + } + + return association; + } + + public List getConstructGenomicEntityAssociationsByDataProvider(BackendBulkDataProvider dataProvider) { + Map params = new HashMap<>(); + params.put(EntityFieldConstants.SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); + List associationIdStrings = constructGenomicEntityAssociationDAO.findFilteredIds(params); + associationIdStrings.removeIf(Objects::isNull); + List associationIds = associationIdStrings.stream().map(Long::parseLong).collect(Collectors.toList()); + + return associationIds; + } + + @Transactional + public ConstructGenomicEntityAssociation deprecateOrDeleteAssociation(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { + ConstructGenomicEntityAssociation association = constructGenomicEntityAssociationDAO.find(id); + + if (association == null) { + String errorMessage = "Could not find ConstructGenomicEntityAssociation with id: " + id; + if (throwApiError) { + ObjectResponse response = new ObjectResponse<>(); + response.addErrorMessage("id", errorMessage); + throw new ApiErrorException(response); + } + log.error(errorMessage); + return null; + } + if (deprecate) { + if (!association.getObsolete()) { + association.setObsolete(true); + if (authenticatedPerson != null) { + association.setUpdatedBy(personDAO.find(authenticatedPerson.getId())); + } else { + association.setUpdatedBy(personService.fetchByUniqueIdOrCreate(loadDescription)); + } + association.setDateUpdated(OffsetDateTime.now()); + return constructGenomicEntityAssociationDAO.persist(association); + } + } + + List notesToDelete = association.getRelatedNotes(); + constructGenomicEntityAssociationDAO.remove(association.getId()); + if (CollectionUtils.isNotEmpty(notesToDelete)) + notesToDelete.forEach(note -> noteService.delete(note.getId())); + + return null; + } + + public ObjectResponse getAssociation(String alleleCurie, String relationName, String geneCurie) { + ConstructGenomicEntityAssociation association = null; + + Map params = new HashMap<>(); + params.put("subject.curie", alleleCurie); + params.put("relation.name", relationName); + params.put("object.curie", geneCurie); + + SearchResponse resp = constructGenomicEntityAssociationDAO.findByParams(params); + if (resp != null && resp.getSingleResult() != null) + association = resp.getSingleResult(); + + ObjectResponse response = new ObjectResponse<>(); + response.setEntity(association); + + return response; + } + + private void addAssociationToConstruct(ConstructGenomicEntityAssociation association) { + Construct construct = association.getSubject(); + List currentAssociations = construct.getConstructGenomicEntityAssociations(); + if (currentAssociations == null) + currentAssociations = new ArrayList<>(); + List currentAssociationIds = currentAssociations.stream().map(ConstructGenomicEntityAssociation::getId).collect(Collectors.toList()); + if (!currentAssociationIds.contains(association.getId())); + currentAssociations.add(association); + construct.setConstructGenomicEntityAssociations(currentAssociations); + constructDAO.persist(construct); + } + + private void addAssociationToGenomicEntity(ConstructGenomicEntityAssociation association) { + GenomicEntity genomicEntity = association.getObject(); + List currentAssociations = genomicEntity.getConstructGenomicEntityAssociations(); + if (currentAssociations == null) + currentAssociations = new ArrayList<>(); + List currentAssociationIds = currentAssociations.stream().map(ConstructGenomicEntityAssociation::getId).collect(Collectors.toList()); + if (!currentAssociationIds.contains(association.getId())); + currentAssociations.add(association); + genomicEntity.setConstructGenomicEntityAssociations(currentAssociations); + genomicEntityDAO.persist(genomicEntity); + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/associations/constructAssociations/ConstructGenomicEntityAssociationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/constructAssociations/ConstructGenomicEntityAssociationValidator.java new file mode 100644 index 000000000..5e772bf8c --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/constructAssociations/ConstructGenomicEntityAssociationValidator.java @@ -0,0 +1,202 @@ +package org.alliancegenome.curation_api.services.validation.associations.constructAssociations; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; + +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.dao.ConstructDAO; +import org.alliancegenome.curation_api.dao.GenomicEntityDAO; +import org.alliancegenome.curation_api.dao.NoteDAO; +import org.alliancegenome.curation_api.dao.associations.constructAssociations.ConstructGenomicEntityAssociationDAO; +import org.alliancegenome.curation_api.exceptions.ApiErrorException; +import org.alliancegenome.curation_api.model.entities.Construct; +import org.alliancegenome.curation_api.model.entities.GenomicEntity; +import org.alliancegenome.curation_api.model.entities.Note; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.model.entities.associations.constructAssociations.ConstructGenomicEntityAssociation; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.VocabularyTermService; +import org.alliancegenome.curation_api.services.helpers.notes.NoteIdentityHelper; +import org.alliancegenome.curation_api.services.validation.NoteValidator; +import org.alliancegenome.curation_api.services.validation.associations.EvidenceAssociationValidator; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.ListUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; + +@RequestScoped +public class ConstructGenomicEntityAssociationValidator extends EvidenceAssociationValidator { + + @Inject + ConstructDAO constructDAO; + @Inject + GenomicEntityDAO genomicEntityDAO; + @Inject + ConstructGenomicEntityAssociationDAO constructGenomicEntityAssociationDAO; + @Inject + VocabularyTermService vocabularyTermService; + @Inject + NoteValidator noteValidator; + @Inject + NoteDAO noteDAO; + + private String errorMessage; + + public ConstructGenomicEntityAssociation validateConstructGenomicEntityAssociation(ConstructGenomicEntityAssociation uiEntity, Boolean throwError, Boolean validateConstruct) { + response = new ObjectResponse<>(uiEntity); + errorMessage = "Could not create/update Allele Gene Association: [" + uiEntity.getId() + "]"; + + Long id = uiEntity.getId(); + ConstructGenomicEntityAssociation dbEntity = null; + if (id != null) { + dbEntity = constructGenomicEntityAssociationDAO.find(id); + if (dbEntity == null) { + addMessageResponse("Could not find ConstructGenomicEntityAssociation with ID: [" + id + "]"); + throw new ApiErrorException(response); + } + } else { + dbEntity = new ConstructGenomicEntityAssociation(); + } + + dbEntity = (ConstructGenomicEntityAssociation) validateEvidenceAssociationFields(uiEntity, dbEntity); + + if (validateConstruct) { + Construct subject = validateSubject(uiEntity, dbEntity); + dbEntity.setSubject(subject); + } + + GenomicEntity object = validateObject(uiEntity, dbEntity); + dbEntity.setObject(object); + + VocabularyTerm relation = validateRelation(uiEntity, dbEntity); + dbEntity.setRelation(relation); + + List relatedNotes = validateRelatedNotes(uiEntity, dbEntity); + dbEntity.setRelatedNotes(relatedNotes); + + if (response.hasErrors()) { + response.setErrorMessage(errorMessage); + throw new ApiErrorException(response); + } + + return dbEntity; + } + + private Construct validateSubject(ConstructGenomicEntityAssociation uiEntity, ConstructGenomicEntityAssociation dbEntity) { + String field = "subject"; + if (ObjectUtils.isEmpty(uiEntity.getSubject()) || StringUtils.isBlank(uiEntity.getSubject().getCurie())) { + addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); + return null; + } + + Construct subjectEntity = constructDAO.find(uiEntity.getSubject().getCurie()); + if (subjectEntity == null) { + addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); + return null; + } + + if (subjectEntity.getObsolete() && (dbEntity.getSubject() == null || !subjectEntity.getCurie().equals(dbEntity.getSubject().getCurie()))) { + addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); + return null; + } + + return subjectEntity; + + } + + private GenomicEntity validateObject(ConstructGenomicEntityAssociation uiEntity, ConstructGenomicEntityAssociation dbEntity) { + if (ObjectUtils.isEmpty(uiEntity.getObject()) || StringUtils.isBlank(uiEntity.getObject().getCurie())) { + addMessageResponse("object", ValidationConstants.REQUIRED_MESSAGE); + return null; + } + + GenomicEntity objectEntity = genomicEntityDAO.find(uiEntity.getObject().getCurie()); + if (objectEntity == null) { + addMessageResponse("object", ValidationConstants.INVALID_MESSAGE); + return null; + } + + if (objectEntity.getObsolete() && (dbEntity.getObject() == null || !objectEntity.getCurie().equals(dbEntity.getObject().getCurie()))) { + addMessageResponse("object", ValidationConstants.OBSOLETE_MESSAGE); + return null; + } + + return objectEntity; + + } + + private VocabularyTerm validateRelation(ConstructGenomicEntityAssociation uiEntity, ConstructGenomicEntityAssociation dbEntity) { + String field = "relation"; + if (uiEntity.getRelation() == null) { + addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); + return null; + } + + VocabularyTerm relation = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.CONSTRUCT_GENOMIC_ENTITY_RELATION_VOCABULARY_TERM_SET, uiEntity.getRelation().getName()).getEntity(); + + if (relation == null) { + addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); + return null; + } + + if (relation.getObsolete() && (dbEntity.getRelation() == null || !relation.getName().equals(dbEntity.getRelation().getName()))) { + addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); + return null; + } + + return relation; + } + + public List validateRelatedNotes(ConstructGenomicEntityAssociation uiEntity, ConstructGenomicEntityAssociation dbEntity) { + String field = "relatedNotes"; + + List validatedNotes = new ArrayList(); + Set validatedNoteIdentities = new HashSet<>(); + if (CollectionUtils.isNotEmpty(uiEntity.getRelatedNotes())) { + for (Note note : uiEntity.getRelatedNotes()) { + ObjectResponse noteResponse = noteValidator.validateNote(note, VocabularyConstants.ALLELE_NOTE_TYPES_VOCABULARY_TERM_SET); + if (noteResponse.getEntity() == null) { + addMessageResponse(field, noteResponse.errorMessagesString()); + return null; + } + note = noteResponse.getEntity(); + + String noteIdentity = NoteIdentityHelper.noteIdentity(note); + if (validatedNoteIdentities.contains(noteIdentity)) { + addMessageResponse(field, ValidationConstants.DUPLICATE_MESSAGE + " (" + noteIdentity + ")"); + return null; + } + validatedNoteIdentities.add(noteIdentity); + validatedNotes.add(note); + } + } + + List previousNoteIds = new ArrayList(); + if (CollectionUtils.isNotEmpty(dbEntity.getRelatedNotes())) + previousNoteIds = dbEntity.getRelatedNotes().stream().map(Note::getId).collect(Collectors.toList()); + List validatedNoteIds = new ArrayList(); + if (CollectionUtils.isNotEmpty(validatedNotes)) + validatedNoteIds = validatedNotes.stream().map(Note::getId).collect(Collectors.toList()); + for (Note validatedNote : validatedNotes) { + if (!previousNoteIds.contains(validatedNote.getId())) { + noteDAO.persist(validatedNote); + } + } + List idsToRemove = ListUtils.subtract(previousNoteIds, validatedNoteIds); + for (Long id : idsToRemove) { + constructGenomicEntityAssociationDAO.deleteAttachedNote(id); + } + + if (CollectionUtils.isEmpty(validatedNotes)) + return null; + + return validatedNotes; + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTOValidator.java new file mode 100644 index 000000000..f9155bb56 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTOValidator.java @@ -0,0 +1,142 @@ +package org.alliancegenome.curation_api.services.validation.dto.associations.constructAssociations; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; + +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.dao.ConstructDAO; +import org.alliancegenome.curation_api.dao.GenomicEntityDAO; +import org.alliancegenome.curation_api.dao.NoteDAO; +import org.alliancegenome.curation_api.dao.associations.constructAssociations.ConstructGenomicEntityAssociationDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.model.entities.Construct; +import org.alliancegenome.curation_api.model.entities.GenomicEntity; +import org.alliancegenome.curation_api.model.entities.Note; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.model.entities.associations.constructAssociations.ConstructGenomicEntityAssociation; +import org.alliancegenome.curation_api.model.ingest.dto.NoteDTO; +import org.alliancegenome.curation_api.model.ingest.dto.associations.constructAssociations.ConstructGenomicEntityAssociationDTO; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.response.SearchResponse; +import org.alliancegenome.curation_api.services.VocabularyTermService; +import org.alliancegenome.curation_api.services.helpers.notes.NoteIdentityHelper; +import org.alliancegenome.curation_api.services.validation.dto.NoteDTOValidator; +import org.alliancegenome.curation_api.services.validation.dto.associations.EvidenceAssociationDTOValidator; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +@RequestScoped +public class ConstructGenomicEntityAssociationDTOValidator extends EvidenceAssociationDTOValidator { + + @Inject + ConstructDAO constructDAO; + @Inject + GenomicEntityDAO genomicEntityDAO; + @Inject + NoteDAO noteDAO; + @Inject + NoteDTOValidator noteDtoValidator; + @Inject + VocabularyTermService vocabularyTermService; + @Inject + ConstructGenomicEntityAssociationDAO constructGenomicEntityAssociationDAO; + + public ConstructGenomicEntityAssociation validateConstructGenomicEntityAssociationDTO(ConstructGenomicEntityAssociationDTO dto, BackendBulkDataProvider beDataProvider) throws ObjectValidationException { + ObjectResponse assocResponse = new ObjectResponse(); + + Construct construct = null; + if (StringUtils.isNotBlank(dto.getConstructIdentifier())) { + SearchResponse res = constructDAO.findByField("mod_internal_id", dto.getConstructIdentifier()); + if (res == null || res.getSingleResult() == null) + res = constructDAO.findByField("mod_entity_id", dto.getConstructIdentifier()); + if (res == null || res.getSingleResult() == null) { + assocResponse.addErrorMessage("construct_identifier", ValidationConstants.INVALID_MESSAGE); + } else { + construct = res.getSingleResult(); + if (beDataProvider != null && !construct.getDataProvider().getSourceOrganization().getAbbreviation().equals(beDataProvider.sourceOrganization)) { + assocResponse.addErrorMessage("construct_curie", ValidationConstants.INVALID_MESSAGE + " for " + beDataProvider.name() + " load"); + } + } + } else { + assocResponse.addErrorMessage("construct_identifier", ValidationConstants.REQUIRED_MESSAGE); + } + + ConstructGenomicEntityAssociation association = null; + if (construct != null && StringUtils.isNotBlank(dto.getGenomicEntityRelationName()) && StringUtils.isNotBlank(dto.getGenomicEntityCurie())) { + HashMap params = new HashMap<>(); + params.put("subject.id", construct.getId()); + params.put("relation.name", dto.getGenomicEntityRelationName()); + params.put("object.curie", dto.getGenomicEntityCurie()); + + SearchResponse searchResponse = constructGenomicEntityAssociationDAO.findByParams(params); + if (searchResponse != null && searchResponse.getResults().size() == 1) { + association = searchResponse.getSingleResult(); + } + } + if (association == null) + association = new ConstructGenomicEntityAssociation(); + + association.setSubject(construct); + + ObjectResponse eviResponse = validateEvidenceAssociationDTO(association, dto); + association = eviResponse.getEntity(); + + if (StringUtils.isBlank(dto.getGenomicEntityCurie())) { + assocResponse.addErrorMessage("genomic_entity_curie", ValidationConstants.REQUIRED_MESSAGE); + } else { + GenomicEntity genomicEntity = genomicEntityDAO.find(dto.getGenomicEntityCurie()); + if (genomicEntity == null) + assocResponse.addErrorMessage("genomic_entity_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getGenomicEntityCurie() + ")"); + association.setObject(genomicEntity); + } + + if (StringUtils.isNotEmpty(dto.getGenomicEntityRelationName())) { + VocabularyTerm relation = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.CONSTRUCT_GENOMIC_ENTITY_RELATION_VOCABULARY_TERM_SET, dto.getGenomicEntityRelationName()).getEntity(); + if (relation == null) + assocResponse.addErrorMessage("genomic_entity_relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getGenomicEntityRelationName() + ")"); + association.setRelation(relation); + } else { + assocResponse.addErrorMessage("genomic_entity_relation_name", ValidationConstants.REQUIRED_MESSAGE); + } + + if (CollectionUtils.isNotEmpty(association.getRelatedNotes())) { + association.getRelatedNotes().forEach(note -> { + constructGenomicEntityAssociationDAO.deleteAttachedNote(note.getId()); + }); + } + if (CollectionUtils.isNotEmpty(dto.getNoteDtos())) { + List notes = new ArrayList<>(); + Set noteIdentities = new HashSet<>(); + for (NoteDTO noteDTO : dto.getNoteDtos()) { + ObjectResponse noteResponse = noteDtoValidator.validateNoteDTO(noteDTO, VocabularyConstants.CONSTRUCT_COMPONENT_NOTE_TYPES_VOCABULARY_TERM_SET); + if (noteResponse.hasErrors()) { + assocResponse.addErrorMessage("note_dtos", noteResponse.errorMessagesString()); + break; + } + String noteIdentity = NoteIdentityHelper.noteDtoIdentity(noteDTO); + if (!noteIdentities.contains(noteIdentity)) { + noteIdentities.add(noteIdentity); + notes.add(noteDAO.persist(noteResponse.getEntity())); + } + } + association.setRelatedNotes(notes); + } else { + association.setRelatedNotes(null); + } + + if (assocResponse.hasErrors()) + throw new ObjectValidationException(dto, assocResponse.errorMessagesString()); + + association = constructGenomicEntityAssociationDAO.persist(association); + + return association; + } +} From 018da1345e83c662530a66aa535687f629a9ae68 Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 12:14:27 +0100 Subject: [PATCH 44/76] Add associations to gene in CRUD operations --- .../AlleleGeneAssociationDTOValidator.java | 5 +++-- .../associations/AlleleGeneAssociationITCase.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java index 641e756a7..75f508209 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java @@ -62,10 +62,11 @@ public AlleleGeneAssociation validateAlleleGeneAssociationDTO(AlleleGeneAssociat agaResponse.addErrorMessage("allele_curie", ValidationConstants.REQUIRED_MESSAGE); } else { Allele allele = alleleDAO.find(dto.getAlleleCurie()); - if (allele == null) + if (allele == null) { agaResponse.addErrorMessage("allele_curie", ValidationConstants.INVALID_MESSAGE + " (" + dto.getAlleleCurie() + ")"); - if (beDataProvider != null && !allele.getDataProvider().getSourceOrganization().getAbbreviation().equals(beDataProvider.sourceOrganization)) + } else if (beDataProvider != null && !allele.getDataProvider().getSourceOrganization().getAbbreviation().equals(beDataProvider.sourceOrganization)) { agaResponse.addErrorMessage("allele_curie", ValidationConstants.INVALID_MESSAGE + " for " + beDataProvider.name() + " load"); + } association.setSubject(allele); } diff --git a/src/test/java/org/alliancegenome/curation_api/crud/controllers/associations/AlleleGeneAssociationITCase.java b/src/test/java/org/alliancegenome/curation_api/crud/controllers/associations/AlleleGeneAssociationITCase.java index d2aaca7b2..7b2351645 100644 --- a/src/test/java/org/alliancegenome/curation_api/crud/controllers/associations/AlleleGeneAssociationITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/crud/controllers/associations/AlleleGeneAssociationITCase.java @@ -62,6 +62,7 @@ public class AlleleGeneAssociationITCase extends BaseITCase { private final String alleleGeneAssociationGetEndpoint = "/api/allelegeneassociation/findBy"; private final String alleleGetEndpoint = "/api/allele/"; + private final String geneGetEndpoint = "/api/gene/"; private void loadRequiredEntities() { Vocabulary nameTypeVocabulary = getVocabulary(VocabularyConstants.NAME_TYPE_VOCABULARY); @@ -145,6 +146,16 @@ public void createValidAlleleGeneAssociation() { body("entity.alleleGeneAssociations[0].relation.name", is(relation.getName())). body("entity.alleleGeneAssociations[0].object.curie", is(gene.getCurie())). body("entity.alleleGeneAssociations[0].subject", not(hasKey("alleleGeneAssociations"))); + + RestAssured.given(). + when(). + get(geneGetEndpoint + gene.getCurie()). + then(). + statusCode(200). + body("entity.alleleGeneAssociations", hasSize(1)). + body("entity.alleleGeneAssociations[0].relation.name", is(relation.getName())). + body("entity.alleleGeneAssociations[0].object.curie", is(gene.getCurie())). + body("entity.alleleGeneAssociations[0].object", not(hasKey("alleleGeneAssociations"))); } @Test From ee5da3ac1e9aea85e20b4e1c84a501764e40a7c5 Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 13:37:13 +0100 Subject: [PATCH 45/76] More construct association code --- .../AlleleGeneAssociationCrudController.java | 6 +- ...enomicEntityAssociationCrudController.java | 58 +++++++++++++++++++ .../AlleleGeneAssociationCrudInterface.java | 2 +- ...GenomicEntityAssociationCrudInterface.java | 45 ++++++++++++++ .../jobs/BulkLoadJobExecutor.java | 12 +++- .../jobs/executors/LoadFileExecutor.java | 6 +- .../AssociationExecutor.java} | 0 .../model/ingest/dto/IngestDTO.java | 5 ++ .../AlleleGeneAssociationService.java | 9 ++- ...structGenomicEntityAssociationService.java | 8 +-- 10 files changed, 134 insertions(+), 17 deletions(-) create mode 100644 src/main/java/org/alliancegenome/curation_api/controllers/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudController.java create mode 100644 src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudInterface.java rename src/main/java/org/alliancegenome/curation_api/jobs/executors/{AlleleGeneAssociationExecutor.java => associations/AssociationExecutor.java} (100%) diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/associations/alleleAssociations/AlleleGeneAssociationCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/associations/alleleAssociations/AlleleGeneAssociationCrudController.java index 140215fba..46c7804c0 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/associations/alleleAssociations/AlleleGeneAssociationCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/associations/alleleAssociations/AlleleGeneAssociationCrudController.java @@ -9,7 +9,7 @@ import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController; import org.alliancegenome.curation_api.dao.associations.alleleAssociations.AlleleGeneAssociationDAO; import org.alliancegenome.curation_api.interfaces.crud.associations.alleleAssociations.AlleleGeneAssociationCrudInterface; -import org.alliancegenome.curation_api.jobs.executors.AlleleGeneAssociationExecutor; +import org.alliancegenome.curation_api.jobs.executors.associations.AssociationExecutor; import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGeneAssociation; import org.alliancegenome.curation_api.model.ingest.dto.associations.alleleAssociations.AlleleGeneAssociationDTO; import org.alliancegenome.curation_api.response.APIResponse; @@ -23,7 +23,7 @@ public class AlleleGeneAssociationCrudController extends @Inject AlleleGeneAssociationService alleleGeneAssociationService; @Inject - AlleleGeneAssociationExecutor alleleGeneAssociationExecutor; + AssociationExecutor alleleGeneAssociationExecutor; @Override @PostConstruct @@ -46,7 +46,7 @@ public ObjectResponse validate(AlleleGeneAssociation enti } @Override - public APIResponse updateGeneAlleleAssociations(String dataProvider, + public APIResponse updateAlleleGeneAssociations(String dataProvider, List associations) { return alleleGeneAssociationExecutor.runLoad(dataProvider, associations); } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudController.java new file mode 100644 index 000000000..26bd8946e --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudController.java @@ -0,0 +1,58 @@ +package org.alliancegenome.curation_api.controllers.crud.associations.constructAssociations; + +import java.util.List; + +import javax.annotation.PostConstruct; +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; + +import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController; +import org.alliancegenome.curation_api.dao.associations.constructAssociations.ConstructGenomicEntityAssociationDAO; +import org.alliancegenome.curation_api.interfaces.crud.associations.constructAssociations.ConstructGenomicEntityAssociationCrudInterface; +import org.alliancegenome.curation_api.jobs.executors.associations.constructAssociations.ConstructGenomicEntityAssociationExecutor; +import org.alliancegenome.curation_api.model.entities.associations.constructAssociations.ConstructGenomicEntityAssociation; +import org.alliancegenome.curation_api.model.ingest.dto.associations.constructAssociations.ConstructGenomicEntityAssociationDTO; +import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.associations.constructAssociations.ConstructGenomicEntityAssociationService; + +@RequestScoped +public class ConstructGenomicEntityAssociationCrudController extends + BaseEntityCrudController implements ConstructGenomicEntityAssociationCrudInterface { + + @Inject + ConstructGenomicEntityAssociationService constructGenomicEntityAssociationService; + @Inject + ConstructGenomicEntityAssociationExecutor constructGenomicEntityAssociationExecutor; + + @Override + @PostConstruct + protected void init() { + setService(constructGenomicEntityAssociationService); + } + + @Override + public ObjectResponse update(ConstructGenomicEntityAssociation entity) { + return constructGenomicEntityAssociationService.upsert(entity); + } + + @Override + public ObjectResponse create(ConstructGenomicEntityAssociation entity) { + return constructGenomicEntityAssociationService.upsert(entity); + } + + public ObjectResponse validate(ConstructGenomicEntityAssociation entity) { + return constructGenomicEntityAssociationService.validate(entity); + } + + @Override + public APIResponse updateConstructGenomicEntityAssociations(String dataProvider, + List associations) { + return constructGenomicEntityAssociationExecutor.runLoad(dataProvider, associations); + } + + public ObjectResponse getAssociation(Long constructId, String relationName, + String genomicEntityCurie) { + return constructGenomicEntityAssociationService.getAssociation(constructId, relationName, genomicEntityCurie); + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/alleleAssociations/AlleleGeneAssociationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/alleleAssociations/AlleleGeneAssociationCrudInterface.java index 957353067..0329474dc 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/alleleAssociations/AlleleGeneAssociationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/alleleAssociations/AlleleGeneAssociationCrudInterface.java @@ -31,7 +31,7 @@ public interface AlleleGeneAssociationCrudInterface extends BaseIdCrudInterface< @POST @Path("/bulk/{dataProvider}/associationFile") @JsonView(View.FieldsAndLists.class) - public APIResponse updateGeneAlleleAssociations(@PathParam("dataProvider") String dataProvider, List associationData); + public APIResponse updateAlleleGeneAssociations(@PathParam("dataProvider") String dataProvider, List associationData); @GET @Path("/findBy") diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudInterface.java new file mode 100644 index 000000000..af8e8da1d --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudInterface.java @@ -0,0 +1,45 @@ +package org.alliancegenome.curation_api.interfaces.crud.associations.constructAssociations; + +import java.util.List; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.alliancegenome.curation_api.interfaces.base.BaseIdCrudInterface; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGeneAssociation; +import org.alliancegenome.curation_api.model.entities.associations.constructAssociations.ConstructGenomicEntityAssociation; +import org.alliancegenome.curation_api.model.ingest.dto.associations.constructAssociations.ConstructGenomicEntityAssociationDTO; +import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.tags.Tag; + +import com.fasterxml.jackson.annotation.JsonView; + +@Path("/constructgenomicentityassociation") +@Tag(name = "CRUD - Construct Genomic Entity Associations") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public interface ConstructGenomicEntityAssociationCrudInterface extends BaseIdCrudInterface { + + @POST + @Path("/bulk/{dataProvider}/associationFile") + @JsonView(View.FieldsAndLists.class) + public APIResponse updateConstructGenomicEntityAssociations(@PathParam("dataProvider") String dataProvider, List associationData); + + @GET + @Path("/findBy") + @JsonView(View.FieldsAndLists.class) + public ObjectResponse getAssociation(@QueryParam("constructId") Long constructId, @QueryParam("relationName") String relationName, @QueryParam("genomicEntityCurie") String geneCurie); + + @POST + @Path("/validate") + @JsonView(View.FieldsAndLists.class) + public ObjectResponse validate(ConstructGenomicEntityAssociation entity); +} diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/BulkLoadJobExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/BulkLoadJobExecutor.java index ec00447c3..8d4524699 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/BulkLoadJobExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/BulkLoadJobExecutor.java @@ -6,6 +6,7 @@ import static org.alliancegenome.curation_api.enums.BackendBulkLoadType.ALLELE_ASSOCIATION; import static org.alliancegenome.curation_api.enums.BackendBulkLoadType.ALLELE_DISEASE_ANNOTATION; import static org.alliancegenome.curation_api.enums.BackendBulkLoadType.CONSTRUCT; +import static org.alliancegenome.curation_api.enums.BackendBulkLoadType.CONSTRUCT_ASSOCIATION; import static org.alliancegenome.curation_api.enums.BackendBulkLoadType.DISEASE_ANNOTATION; import static org.alliancegenome.curation_api.enums.BackendBulkLoadType.FULL_INGEST; import static org.alliancegenome.curation_api.enums.BackendBulkLoadType.GENE; @@ -23,7 +24,6 @@ import org.alliancegenome.curation_api.jobs.executors.AgmExecutor; import org.alliancegenome.curation_api.jobs.executors.AlleleDiseaseAnnotationExecutor; import org.alliancegenome.curation_api.jobs.executors.AlleleExecutor; -import org.alliancegenome.curation_api.jobs.executors.AlleleGeneAssociationExecutor; import org.alliancegenome.curation_api.jobs.executors.ConstructExecutor; import org.alliancegenome.curation_api.jobs.executors.GeneDiseaseAnnotationExecutor; import org.alliancegenome.curation_api.jobs.executors.GeneExecutor; @@ -32,6 +32,8 @@ import org.alliancegenome.curation_api.jobs.executors.OrthologyExecutor; import org.alliancegenome.curation_api.jobs.executors.ResourceDescriptorExecutor; import org.alliancegenome.curation_api.jobs.executors.VariantExecutor; +import org.alliancegenome.curation_api.jobs.executors.associations.AssociationExecutor; +import org.alliancegenome.curation_api.jobs.executors.associations.constructAssociations.ConstructGenomicEntityAssociationExecutor; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import lombok.extern.jbosslog.JBossLog; @@ -54,13 +56,14 @@ public class BulkLoadJobExecutor { @Inject OntologyExecutor ontologyExecutor; @Inject ConstructExecutor constructExecutor; @Inject VariantExecutor variantExecutor; - @Inject AlleleGeneAssociationExecutor alleleGeneAssociationExecutor; + @Inject AssociationExecutor alleleGeneAssociationExecutor; + @Inject ConstructGenomicEntityAssociationExecutor constructGenomicEntityAssociationExecutor; public void process(BulkLoadFile bulkLoadFile, Boolean cleanUp) throws Exception { BackendBulkLoadType loadType = bulkLoadFile.getBulkLoad().getBackendBulkLoadType(); - List ingestTypes = List.of(AGM_DISEASE_ANNOTATION, ALLELE_DISEASE_ANNOTATION, GENE_DISEASE_ANNOTATION, DISEASE_ANNOTATION, AGM, ALLELE, GENE, VARIANT, CONSTRUCT, FULL_INGEST, ALLELE_ASSOCIATION); + List ingestTypes = List.of(AGM_DISEASE_ANNOTATION, ALLELE_DISEASE_ANNOTATION, GENE_DISEASE_ANNOTATION, DISEASE_ANNOTATION, AGM, ALLELE, GENE, VARIANT, CONSTRUCT, FULL_INGEST, ALLELE_ASSOCIATION, CONSTRUCT_ASSOCIATION); if (ingestTypes.contains(loadType)) { @@ -94,6 +97,9 @@ public void process(BulkLoadFile bulkLoadFile, Boolean cleanUp) throws Exception if (loadType == ALLELE_ASSOCIATION || loadType == FULL_INGEST) { alleleGeneAssociationExecutor.runLoad(bulkLoadFile, cleanUp); } + if (loadType == CONSTRUCT_ASSOCIATION || loadType == FULL_INGEST) { + constructGenomicEntityAssociationExecutor.runLoad(bulkLoadFile, cleanUp); + } } else if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.MOLECULE) { moleculeExecutor.runLoad(bulkLoadFile); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java index 7a798290a..ee5d2908c 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java @@ -34,11 +34,11 @@ public class LoadFileExecutor { @Inject - ObjectMapper mapper; + protected ObjectMapper mapper; @Inject - LoadProcessDisplayService loadProcessDisplayService; + protected LoadProcessDisplayService loadProcessDisplayService; @Inject - BulkLoadFileDAO bulkLoadFileDAO; + protected BulkLoadFileDAO bulkLoadFileDAO; @Inject BulkLoadFileHistoryDAO bulkLoadFileHistoryDAO; @Inject diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleGeneAssociationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/AssociationExecutor.java similarity index 100% rename from src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleGeneAssociationExecutor.java rename to src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/AssociationExecutor.java diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/IngestDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/IngestDTO.java index 8aa10eac5..2c2407c1e 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/IngestDTO.java +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/IngestDTO.java @@ -3,6 +3,7 @@ import java.util.List; import org.alliancegenome.curation_api.model.ingest.dto.associations.alleleAssociations.AlleleGeneAssociationDTO; +import org.alliancegenome.curation_api.model.ingest.dto.associations.constructAssociations.ConstructGenomicEntityAssociationDTO; import org.alliancegenome.curation_api.view.View; import com.fasterxml.jackson.annotation.JsonProperty; @@ -58,5 +59,9 @@ public class IngestDTO { @JsonView({ View.FieldsAndLists.class }) @JsonProperty("allele_gene_association_ingest_set") private List alleleGeneAssociationIngestSet; + + @JsonView({ View.FieldsAndLists.class }) + @JsonProperty("cosntruct_genomic_entity_association_ingest_set") + private List constructGenomicEntityAssociationIngestSet; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java index 3ba8c697c..87b96e317 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java @@ -13,6 +13,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; +import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.AlleleDAO; import org.alliancegenome.curation_api.dao.GeneDAO; import org.alliancegenome.curation_api.dao.NoteDAO; @@ -68,6 +69,7 @@ public ObjectResponse upsert(AlleleGeneAssociation uiEnti return null; dbEntity = alleleGeneAssociationDAO.persist(dbEntity); addAssociationToAllele(dbEntity); + addAssociationToGene(dbEntity); return new ObjectResponse(dbEntity); } @@ -87,9 +89,9 @@ public AlleleGeneAssociation upsert(AlleleGeneAssociationDTO dto, BackendBulkDat return association; } - public List getAlleleGeneAssociationsByDataProvider(BackendBulkDataProvider dataProvider) { + public List getAssociationsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); - params.put("subject.dataProvider.sourceOrganization.abbreviation", dataProvider.sourceOrganization); + params.put(EntityFieldConstants.SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); List associationIdStrings = alleleGeneAssociationDAO.findFilteredIds(params); associationIdStrings.removeIf(Objects::isNull); List associationIds = associationIdStrings.stream().map(Long::parseLong).collect(Collectors.toList()); @@ -114,7 +116,7 @@ public AlleleGeneAssociation deprecateOrDeleteAssociation(Long id, Boolean throw if (deprecate) { if (!association.getObsolete()) { association.setObsolete(true); - if (authenticatedPerson != null) { + if (authenticatedPerson.getId() != null) { association.setUpdatedBy(personDAO.find(authenticatedPerson.getId())); } else { association.setUpdatedBy(personService.fetchByUniqueIdOrCreate(loadDescription)); @@ -122,6 +124,7 @@ public AlleleGeneAssociation deprecateOrDeleteAssociation(Long id, Boolean throw association.setDateUpdated(OffsetDateTime.now()); return alleleGeneAssociationDAO.persist(association); } + return association; } Long noteId = null; diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java index ced9d6948..82385ee23 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java @@ -91,7 +91,7 @@ public ConstructGenomicEntityAssociation upsert(ConstructGenomicEntityAssociatio return association; } - public List getConstructGenomicEntityAssociationsByDataProvider(BackendBulkDataProvider dataProvider) { + public List getAssociationsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); params.put(EntityFieldConstants.SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); List associationIdStrings = constructGenomicEntityAssociationDAO.findFilteredIds(params); @@ -136,13 +136,13 @@ public ConstructGenomicEntityAssociation deprecateOrDeleteAssociation(Long id, B return null; } - public ObjectResponse getAssociation(String alleleCurie, String relationName, String geneCurie) { + public ObjectResponse getAssociation(Long constructId, String relationName, String genomicEntityCurie) { ConstructGenomicEntityAssociation association = null; Map params = new HashMap<>(); - params.put("subject.curie", alleleCurie); + params.put("subject.id", constructId); params.put("relation.name", relationName); - params.put("object.curie", geneCurie); + params.put("object.curie", genomicEntityCurie); SearchResponse resp = constructGenomicEntityAssociationDAO.findByParams(params); if (resp != null && resp.getSingleResult() != null) From e3794fd9a66a5ebf57226f7ac8fbf7b29a54d01e Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 14:01:09 +0100 Subject: [PATCH 46/76] Move ingest file loading to shared method --- .../AlleleGeneAssociationCrudController.java | 4 +- .../jobs/BulkLoadJobExecutor.java | 4 +- .../AgmDiseaseAnnotationExecutor.java | 64 +++++------ .../jobs/executors/AgmExecutor.java | 67 +++++------ .../AlleleDiseaseAnnotationExecutor.java | 67 +++++------ .../jobs/executors/AlleleExecutor.java | 67 +++++------ .../jobs/executors/ConstructExecutor.java | 68 +++++------ .../GeneDiseaseAnnotationExecutor.java | 66 +++++------ .../jobs/executors/GeneExecutor.java | 65 +++++------ .../jobs/executors/LoadFileExecutor.java | 21 ++++ .../jobs/executors/VariantExecutor.java | 67 +++++------ .../AlleleGeneAssociationExecutor.java} | 76 +++++-------- ...tructGenomicEntityAssociationExecutor.java | 106 ++++++++++++++++++ 13 files changed, 375 insertions(+), 367 deletions(-) rename src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/{AssociationExecutor.java => alleleAssociations/AlleleGeneAssociationExecutor.java} (59%) create mode 100644 src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/constructAssociations/ConstructGenomicEntityAssociationExecutor.java diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/associations/alleleAssociations/AlleleGeneAssociationCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/associations/alleleAssociations/AlleleGeneAssociationCrudController.java index 46c7804c0..fe42de500 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/associations/alleleAssociations/AlleleGeneAssociationCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/associations/alleleAssociations/AlleleGeneAssociationCrudController.java @@ -9,7 +9,7 @@ import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController; import org.alliancegenome.curation_api.dao.associations.alleleAssociations.AlleleGeneAssociationDAO; import org.alliancegenome.curation_api.interfaces.crud.associations.alleleAssociations.AlleleGeneAssociationCrudInterface; -import org.alliancegenome.curation_api.jobs.executors.associations.AssociationExecutor; +import org.alliancegenome.curation_api.jobs.executors.associations.alleleAssociations.AlleleGeneAssociationExecutor; import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGeneAssociation; import org.alliancegenome.curation_api.model.ingest.dto.associations.alleleAssociations.AlleleGeneAssociationDTO; import org.alliancegenome.curation_api.response.APIResponse; @@ -23,7 +23,7 @@ public class AlleleGeneAssociationCrudController extends @Inject AlleleGeneAssociationService alleleGeneAssociationService; @Inject - AssociationExecutor alleleGeneAssociationExecutor; + AlleleGeneAssociationExecutor alleleGeneAssociationExecutor; @Override @PostConstruct diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/BulkLoadJobExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/BulkLoadJobExecutor.java index 8d4524699..68b56eae5 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/BulkLoadJobExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/BulkLoadJobExecutor.java @@ -32,7 +32,7 @@ import org.alliancegenome.curation_api.jobs.executors.OrthologyExecutor; import org.alliancegenome.curation_api.jobs.executors.ResourceDescriptorExecutor; import org.alliancegenome.curation_api.jobs.executors.VariantExecutor; -import org.alliancegenome.curation_api.jobs.executors.associations.AssociationExecutor; +import org.alliancegenome.curation_api.jobs.executors.associations.alleleAssociations.AlleleGeneAssociationExecutor; import org.alliancegenome.curation_api.jobs.executors.associations.constructAssociations.ConstructGenomicEntityAssociationExecutor; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; @@ -56,7 +56,7 @@ public class BulkLoadJobExecutor { @Inject OntologyExecutor ontologyExecutor; @Inject ConstructExecutor constructExecutor; @Inject VariantExecutor variantExecutor; - @Inject AssociationExecutor alleleGeneAssociationExecutor; + @Inject AlleleGeneAssociationExecutor alleleGeneAssociationExecutor; @Inject ConstructGenomicEntityAssociationExecutor constructGenomicEntityAssociationExecutor; public void process(BulkLoadFile bulkLoadFile, Boolean cleanUp) throws Exception { diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java index a25849ce9..e62624d5b 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java @@ -41,43 +41,33 @@ public class AgmDiseaseAnnotationExecutor extends LoadFileExecutor { public void runLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { - try { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); - BackendBulkDataProvider dataProvider = manual.getDataProvider(); - log.info("Running with dataProvider: " + dataProvider.name()); - - IngestDTO ingestDto = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), IngestDTO.class); - bulkLoadFile.setLinkMLSchemaVersion(getVersionNumber(ingestDto.getLinkMLVersion())); - if (StringUtils.isNotBlank(ingestDto.getAllianceMemberReleaseVersion())) - bulkLoadFile.setAllianceMemberReleaseVersion(ingestDto.getAllianceMemberReleaseVersion()); - - if(!checkSchemaVersion(bulkLoadFile, AGMDiseaseAnnotationDTO.class)) return; - - List annotations = ingestDto.getDiseaseAgmIngestSet(); - if (annotations == null) annotations = new ArrayList<>(); - - List annotationIdsLoaded = new ArrayList<>(); - List annotationIdsBefore = new ArrayList<>(); - annotationIdsBefore.addAll(agmDiseaseAnnotationService.getAnnotationIdsByDataProvider(dataProvider)); - annotationIdsBefore.removeIf(Objects::isNull); - - bulkLoadFile.setRecordCount(annotations.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); - - BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); - - runLoad(history, dataProvider, annotations, annotationIdsLoaded); - - if(cleanUp) runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, bulkLoadFile.getMd5Sum()); - - history.finishLoad(); - - trackHistory(history, bulkLoadFile); - - } catch (Exception e) { - failLoad(bulkLoadFile, e); - e.printStackTrace(); - } + BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BackendBulkDataProvider dataProvider = manual.getDataProvider(); + log.info("Running with dataProvider: " + dataProvider.name()); + + IngestDTO ingestDto = readIngestFile(bulkLoadFile); + if (ingestDto == null) return; + + List annotations = ingestDto.getDiseaseAgmIngestSet(); + if (annotations == null) annotations = new ArrayList<>(); + + List annotationIdsLoaded = new ArrayList<>(); + List annotationIdsBefore = new ArrayList<>(); + annotationIdsBefore.addAll(agmDiseaseAnnotationService.getAnnotationIdsByDataProvider(dataProvider)); + annotationIdsBefore.removeIf(Objects::isNull); + + bulkLoadFile.setRecordCount(annotations.size() + bulkLoadFile.getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFile); + + BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); + + runLoad(history, dataProvider, annotations, annotationIdsLoaded); + + if(cleanUp) runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, bulkLoadFile.getMd5Sum()); + + history.finishLoad(); + + trackHistory(history, bulkLoadFile); } // Gets called from the API directly diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmExecutor.java index 066b11ca5..eaf5e7fdf 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmExecutor.java @@ -1,9 +1,7 @@ package org.alliancegenome.curation_api.jobs.executors; -import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; -import java.util.zip.GZIPInputStream; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; @@ -23,7 +21,6 @@ import org.alliancegenome.curation_api.services.AffectedGenomicModelService; import org.alliancegenome.curation_api.services.ontology.NcbiTaxonTermService; import org.alliancegenome.curation_api.util.ProcessDisplayHelper; -import org.apache.commons.lang3.StringUtils; import io.quarkus.logging.Log; @@ -41,43 +38,33 @@ public class AgmExecutor extends LoadFileExecutor { public void runLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { - try { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); - Log.info("Running with: " + manual.getDataProvider().name()); - - IngestDTO ingestDto = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), IngestDTO.class); - bulkLoadFile.setLinkMLSchemaVersion(getVersionNumber(ingestDto.getLinkMLVersion())); - if (StringUtils.isNotBlank(ingestDto.getAllianceMemberReleaseVersion())) - bulkLoadFile.setAllianceMemberReleaseVersion(ingestDto.getAllianceMemberReleaseVersion()); - - if(!checkSchemaVersion(bulkLoadFile, AffectedGenomicModelDTO.class)) return; - - List agms = ingestDto.getAgmIngestSet(); - if (agms == null) agms = new ArrayList<>(); - - BackendBulkDataProvider dataProvider = manual.getDataProvider(); - - List amgCuriesLoaded = new ArrayList<>(); - List agmCuriesBefore = affectedGenomicModelService.getCuriesByDataProvider(dataProvider.name()); - Log.debug("runLoad: Before: total " + agmCuriesBefore.size()); - - bulkLoadFile.setRecordCount(agms.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); - - BulkLoadFileHistory history = new BulkLoadFileHistory(agms.size()); - - runLoad(history, agms, dataProvider, amgCuriesLoaded); - - if(cleanUp) runCleanup(affectedGenomicModelService, history, dataProvider.name(), agmCuriesBefore, amgCuriesLoaded, bulkLoadFile.getMd5Sum()); - - history.finishLoad(); - - trackHistory(history, bulkLoadFile); - - } catch (Exception e) { - failLoad(bulkLoadFile, e); - e.printStackTrace(); - } + BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + Log.info("Running with: " + manual.getDataProvider().name()); + + IngestDTO ingestDto = readIngestFile(bulkLoadFile); + if (ingestDto == null) return; + + List agms = ingestDto.getAgmIngestSet(); + if (agms == null) agms = new ArrayList<>(); + + BackendBulkDataProvider dataProvider = manual.getDataProvider(); + + List amgCuriesLoaded = new ArrayList<>(); + List agmCuriesBefore = affectedGenomicModelService.getCuriesByDataProvider(dataProvider.name()); + Log.debug("runLoad: Before: total " + agmCuriesBefore.size()); + + bulkLoadFile.setRecordCount(agms.size() + bulkLoadFile.getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFile); + + BulkLoadFileHistory history = new BulkLoadFileHistory(agms.size()); + + runLoad(history, agms, dataProvider, amgCuriesLoaded); + + if(cleanUp) runCleanup(affectedGenomicModelService, history, dataProvider.name(), agmCuriesBefore, amgCuriesLoaded, bulkLoadFile.getMd5Sum()); + + history.finishLoad(); + + trackHistory(history, bulkLoadFile); } // Gets called from the API directly diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleDiseaseAnnotationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleDiseaseAnnotationExecutor.java index ce8c3aa89..c7420cec3 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleDiseaseAnnotationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleDiseaseAnnotationExecutor.java @@ -1,10 +1,8 @@ package org.alliancegenome.curation_api.jobs.executors; -import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.zip.GZIPInputStream; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; @@ -24,7 +22,6 @@ import org.alliancegenome.curation_api.services.AlleleDiseaseAnnotationService; import org.alliancegenome.curation_api.services.DiseaseAnnotationService; import org.alliancegenome.curation_api.util.ProcessDisplayHelper; -import org.apache.commons.lang3.StringUtils; import lombok.extern.jbosslog.JBossLog; @@ -41,43 +38,33 @@ public class AlleleDiseaseAnnotationExecutor extends LoadFileExecutor { public void runLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { - try { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); - BackendBulkDataProvider dataProvider = manual.getDataProvider(); - log.info("Running with dataProvider: " + dataProvider.name()); - - IngestDTO ingestDto = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), IngestDTO.class); - bulkLoadFile.setLinkMLSchemaVersion(getVersionNumber(ingestDto.getLinkMLVersion())); - if (StringUtils.isNotBlank(ingestDto.getAllianceMemberReleaseVersion())) - bulkLoadFile.setAllianceMemberReleaseVersion(ingestDto.getAllianceMemberReleaseVersion()); - - if(!checkSchemaVersion(bulkLoadFile, AlleleDiseaseAnnotationDTO.class)) return; - - List annotations = ingestDto.getDiseaseAlleleIngestSet(); - if (annotations == null) annotations = new ArrayList<>(); - - List annotationIdsLoaded = new ArrayList<>(); - List annotationIdsBefore = new ArrayList<>(); - annotationIdsBefore.addAll(alleleDiseaseAnnotationService.getAnnotationIdsByDataProvider(dataProvider)); - annotationIdsBefore.removeIf(Objects::isNull); - - bulkLoadFile.setRecordCount(annotations.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); - - BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); - - runLoad(history, dataProvider, annotations, annotationIdsLoaded); - - if(cleanUp) runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, bulkLoadFile.getMd5Sum()); - - history.finishLoad(); - - trackHistory(history, bulkLoadFile); - - } catch (Exception e) { - failLoad(bulkLoadFile, e); - e.printStackTrace(); - } + BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BackendBulkDataProvider dataProvider = manual.getDataProvider(); + log.info("Running with dataProvider: " + dataProvider.name()); + + IngestDTO ingestDto = readIngestFile(bulkLoadFile); + if (ingestDto == null) return; + + List annotations = ingestDto.getDiseaseAlleleIngestSet(); + if (annotations == null) annotations = new ArrayList<>(); + + List annotationIdsLoaded = new ArrayList<>(); + List annotationIdsBefore = new ArrayList<>(); + annotationIdsBefore.addAll(alleleDiseaseAnnotationService.getAnnotationIdsByDataProvider(dataProvider)); + annotationIdsBefore.removeIf(Objects::isNull); + + bulkLoadFile.setRecordCount(annotations.size() + bulkLoadFile.getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFile); + + BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); + + runLoad(history, dataProvider, annotations, annotationIdsLoaded); + + if(cleanUp) runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, bulkLoadFile.getMd5Sum()); + + history.finishLoad(); + + trackHistory(history, bulkLoadFile); } // Gets called from the API directly diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleExecutor.java index 937982f86..8ad779b5e 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleExecutor.java @@ -1,9 +1,7 @@ package org.alliancegenome.curation_api.jobs.executors; -import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; -import java.util.zip.GZIPInputStream; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; @@ -22,7 +20,6 @@ import org.alliancegenome.curation_api.response.LoadHistoryResponce; import org.alliancegenome.curation_api.services.AlleleService; import org.alliancegenome.curation_api.util.ProcessDisplayHelper; -import org.apache.commons.lang3.StringUtils; import io.quarkus.logging.Log; @@ -36,43 +33,33 @@ public class AlleleExecutor extends LoadFileExecutor { public void runLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { - try { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); - Log.info("Running with: " + manual.getDataProvider().name()); - - IngestDTO ingestDto = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), IngestDTO.class); - bulkLoadFile.setLinkMLSchemaVersion(getVersionNumber(ingestDto.getLinkMLVersion())); - if (StringUtils.isNotBlank(ingestDto.getAllianceMemberReleaseVersion())) - bulkLoadFile.setAllianceMemberReleaseVersion(ingestDto.getAllianceMemberReleaseVersion()); - - if(!checkSchemaVersion(bulkLoadFile, AlleleDTO.class)) return; - - List alleles = ingestDto.getAlleleIngestSet(); - if (alleles == null) alleles = new ArrayList<>(); - - BackendBulkDataProvider dataProvider = manual.getDataProvider(); - - List alleleCuriesLoaded = new ArrayList<>(); - List alleleCuriesBefore = alleleService.getCuriesByDataProvider(dataProvider.name()); - Log.debug("runLoad: Before: total " + alleleCuriesBefore.size()); - - bulkLoadFile.setRecordCount(alleles.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); - - BulkLoadFileHistory history = new BulkLoadFileHistory(alleles.size()); - - runLoad(history, alleles, dataProvider, alleleCuriesLoaded); - - if(cleanUp) runCleanup(alleleService, history, dataProvider.name(), alleleCuriesBefore, alleleCuriesLoaded, bulkLoadFile.getMd5Sum()); - - history.finishLoad(); - - trackHistory(history, bulkLoadFile); - - } catch (Exception e) { - failLoad(bulkLoadFile, e); - e.printStackTrace(); - } + BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + Log.info("Running with: " + manual.getDataProvider().name()); + + IngestDTO ingestDto = readIngestFile(bulkLoadFile); + if (ingestDto == null) return; + + List alleles = ingestDto.getAlleleIngestSet(); + if (alleles == null) alleles = new ArrayList<>(); + + BackendBulkDataProvider dataProvider = manual.getDataProvider(); + + List alleleCuriesLoaded = new ArrayList<>(); + List alleleCuriesBefore = alleleService.getCuriesByDataProvider(dataProvider.name()); + Log.debug("runLoad: Before: total " + alleleCuriesBefore.size()); + + bulkLoadFile.setRecordCount(alleles.size() + bulkLoadFile.getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFile); + + BulkLoadFileHistory history = new BulkLoadFileHistory(alleles.size()); + + runLoad(history, alleles, dataProvider, alleleCuriesLoaded); + + if(cleanUp) runCleanup(alleleService, history, dataProvider.name(), alleleCuriesBefore, alleleCuriesLoaded, bulkLoadFile.getMd5Sum()); + + history.finishLoad(); + + trackHistory(history, bulkLoadFile); } // Gets called from the API directly diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/ConstructExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ConstructExecutor.java index baef1b55b..a950a31cd 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/ConstructExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ConstructExecutor.java @@ -1,10 +1,8 @@ package org.alliancegenome.curation_api.jobs.executors; -import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -import java.util.zip.GZIPInputStream; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; @@ -17,7 +15,6 @@ import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; -import org.alliancegenome.curation_api.model.ingest.dto.AlleleDTO; import org.alliancegenome.curation_api.model.ingest.dto.ConstructDTO; import org.alliancegenome.curation_api.model.ingest.dto.IngestDTO; import org.alliancegenome.curation_api.response.APIResponse; @@ -26,7 +23,6 @@ import org.alliancegenome.curation_api.services.ontology.NcbiTaxonTermService; import org.alliancegenome.curation_api.util.ProcessDisplayHelper; import org.apache.commons.collections4.ListUtils; -import org.apache.commons.lang3.StringUtils; import io.quarkus.logging.Log; @@ -44,43 +40,33 @@ public class ConstructExecutor extends LoadFileExecutor { public void runLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { - try { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); - Log.info("Running with: " + manual.getDataProvider().name()); - - IngestDTO ingestDto = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), IngestDTO.class); - bulkLoadFile.setLinkMLSchemaVersion(getVersionNumber(ingestDto.getLinkMLVersion())); - if (StringUtils.isNotBlank(ingestDto.getAllianceMemberReleaseVersion())) - bulkLoadFile.setAllianceMemberReleaseVersion(ingestDto.getAllianceMemberReleaseVersion()); - - if(!checkSchemaVersion(bulkLoadFile, ConstructDTO.class)) return; - - List constructs = ingestDto.getConstructIngestSet(); - if (constructs == null) constructs = new ArrayList<>(); - - BackendBulkDataProvider dataProvider = manual.getDataProvider(); - - List constructIdsLoaded = new ArrayList<>(); - List constructIdsBefore = constructService.getConstructIdsByDataProvider(dataProvider); - Log.debug("runLoad: Before: total " + constructIdsBefore.size()); - - bulkLoadFile.setRecordCount(constructs.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); - - BulkLoadFileHistory history = new BulkLoadFileHistory(constructs.size()); - - runLoad(history, constructs, dataProvider, constructIdsLoaded); - - if(cleanUp) runCleanup(constructService, history, dataProvider.name(), constructIdsBefore, constructIdsLoaded, bulkLoadFile.getMd5Sum()); - - history.finishLoad(); - - trackHistory(history, bulkLoadFile); - - } catch (Exception e) { - failLoad(bulkLoadFile, e); - e.printStackTrace(); - } + BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + Log.info("Running with: " + manual.getDataProvider().name()); + + IngestDTO ingestDto = readIngestFile(bulkLoadFile); + if (ingestDto == null) return; + + List constructs = ingestDto.getConstructIngestSet(); + if (constructs == null) constructs = new ArrayList<>(); + + BackendBulkDataProvider dataProvider = manual.getDataProvider(); + + List constructIdsLoaded = new ArrayList<>(); + List constructIdsBefore = constructService.getConstructIdsByDataProvider(dataProvider); + Log.debug("runLoad: Before: total " + constructIdsBefore.size()); + + bulkLoadFile.setRecordCount(constructs.size() + bulkLoadFile.getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFile); + + BulkLoadFileHistory history = new BulkLoadFileHistory(constructs.size()); + + runLoad(history, constructs, dataProvider, constructIdsLoaded); + + if(cleanUp) runCleanup(constructService, history, dataProvider.name(), constructIdsBefore, constructIdsLoaded, bulkLoadFile.getMd5Sum()); + + history.finishLoad(); + + trackHistory(history, bulkLoadFile); } // Gets called from the API directly diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneDiseaseAnnotationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneDiseaseAnnotationExecutor.java index a61f3eb8f..680142bc0 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneDiseaseAnnotationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneDiseaseAnnotationExecutor.java @@ -1,10 +1,8 @@ package org.alliancegenome.curation_api.jobs.executors; -import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.zip.GZIPInputStream; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; @@ -24,7 +22,6 @@ import org.alliancegenome.curation_api.services.DiseaseAnnotationService; import org.alliancegenome.curation_api.services.GeneDiseaseAnnotationService; import org.alliancegenome.curation_api.util.ProcessDisplayHelper; -import org.apache.commons.lang3.StringUtils; import lombok.extern.jbosslog.JBossLog; @@ -41,44 +38,33 @@ public class GeneDiseaseAnnotationExecutor extends LoadFileExecutor { public void runLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { - try { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); - BackendBulkDataProvider dataProvider = manual.getDataProvider(); - log.info("Running with dataProvider: " + dataProvider.name()); - - IngestDTO ingestDto = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), IngestDTO.class); - bulkLoadFile.setLinkMLSchemaVersion(getVersionNumber(ingestDto.getLinkMLVersion())); - if (StringUtils.isNotBlank(ingestDto.getAllianceMemberReleaseVersion())) - bulkLoadFile.setAllianceMemberReleaseVersion(ingestDto.getAllianceMemberReleaseVersion()); - - if(!checkSchemaVersion(bulkLoadFile, GeneDiseaseAnnotationDTO.class)) return; - - List annotations = ingestDto.getDiseaseGeneIngestSet(); - if (annotations == null) annotations = new ArrayList<>(); - - List annotationIdsLoaded = new ArrayList<>(); - List annotationIdsBefore = new ArrayList<>(); - annotationIdsBefore.addAll(geneDiseaseAnnotationService.getAnnotationIdsByDataProvider(dataProvider)); - annotationIdsBefore.removeIf(Objects::isNull); - - bulkLoadFile.setRecordCount(annotations.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); - - BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); - - runLoad(history, dataProvider, annotations, annotationIdsLoaded); - - if(cleanUp) runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, bulkLoadFile.getMd5Sum()); - - history.finishLoad(); - - trackHistory(history, bulkLoadFile); - - } catch (Exception e) { - failLoad(bulkLoadFile, e); - e.printStackTrace(); - } + BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BackendBulkDataProvider dataProvider = manual.getDataProvider(); + log.info("Running with dataProvider: " + dataProvider.name()); + IngestDTO ingestDto = readIngestFile(bulkLoadFile); + if (ingestDto == null) return; + + List annotations = ingestDto.getDiseaseGeneIngestSet(); + if (annotations == null) annotations = new ArrayList<>(); + + List annotationIdsLoaded = new ArrayList<>(); + List annotationIdsBefore = new ArrayList<>(); + annotationIdsBefore.addAll(geneDiseaseAnnotationService.getAnnotationIdsByDataProvider(dataProvider)); + annotationIdsBefore.removeIf(Objects::isNull); + + bulkLoadFile.setRecordCount(annotations.size() + bulkLoadFile.getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFile); + + BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); + + runLoad(history, dataProvider, annotations, annotationIdsLoaded); + + if(cleanUp) runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, bulkLoadFile.getMd5Sum()); + + history.finishLoad(); + + trackHistory(history, bulkLoadFile); } // Gets called from the API directly diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExecutor.java index 9d4b38f3e..f52c03452 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExecutor.java @@ -1,9 +1,7 @@ package org.alliancegenome.curation_api.jobs.executors; -import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; -import java.util.zip.GZIPInputStream; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; @@ -23,7 +21,6 @@ import org.alliancegenome.curation_api.services.GeneService; import org.alliancegenome.curation_api.services.ontology.NcbiTaxonTermService; import org.alliancegenome.curation_api.util.ProcessDisplayHelper; -import org.apache.commons.lang3.StringUtils; import lombok.extern.jbosslog.JBossLog; @@ -42,42 +39,32 @@ public class GeneExecutor extends LoadFileExecutor { public void runLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { - try { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); - BackendBulkDataProvider dataProvider = manual.getDataProvider(); - log.info("Running with dataProvider : " + dataProvider.name()); - - IngestDTO ingestDto = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), IngestDTO.class); - bulkLoadFile.setLinkMLSchemaVersion(getVersionNumber(ingestDto.getLinkMLVersion())); - if (StringUtils.isNotBlank(ingestDto.getAllianceMemberReleaseVersion())) - bulkLoadFile.setAllianceMemberReleaseVersion(ingestDto.getAllianceMemberReleaseVersion()); - - if(!checkSchemaVersion(bulkLoadFile, GeneDTO.class)) return; - - List genes = ingestDto.getGeneIngestSet(); - if (genes == null) genes = new ArrayList<>(); - - List geneCuriesLoaded = new ArrayList<>(); - List geneCuriesBefore = geneService.getCuriesByDataProvider(dataProvider); - log.debug("runLoad: Before: total " + geneCuriesBefore.size()); - - bulkLoadFile.setRecordCount(genes.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); - - BulkLoadFileHistory history = new BulkLoadFileHistory(genes.size()); - - runLoad(history, genes, dataProvider, geneCuriesLoaded); - - if(cleanUp) runCleanup(geneService, history, dataProvider.name(), geneCuriesBefore, geneCuriesLoaded, bulkLoadFile.getMd5Sum()); - - history.finishLoad(); - - trackHistory(history, bulkLoadFile); - - } catch (Exception e) { - failLoad(bulkLoadFile, e); - e.printStackTrace(); - } + BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BackendBulkDataProvider dataProvider = manual.getDataProvider(); + log.info("Running with dataProvider : " + dataProvider.name()); + + IngestDTO ingestDto = readIngestFile(bulkLoadFile); + if (ingestDto == null) return; + + List genes = ingestDto.getGeneIngestSet(); + if (genes == null) genes = new ArrayList<>(); + + List geneCuriesLoaded = new ArrayList<>(); + List geneCuriesBefore = geneService.getCuriesByDataProvider(dataProvider); + log.debug("runLoad: Before: total " + geneCuriesBefore.size()); + + bulkLoadFile.setRecordCount(genes.size() + bulkLoadFile.getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFile); + + BulkLoadFileHistory history = new BulkLoadFileHistory(genes.size()); + + runLoad(history, genes, dataProvider, geneCuriesLoaded); + + if(cleanUp) runCleanup(geneService, history, dataProvider.name(), geneCuriesBefore, geneCuriesLoaded, bulkLoadFile.getMd5Sum()); + + history.finishLoad(); + + trackHistory(history, bulkLoadFile); } // Gets called from the API directly diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java index ee5d2908c..ae07e395a 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java @@ -1,11 +1,13 @@ package org.alliancegenome.curation_api.jobs.executors; +import java.io.FileInputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import java.util.zip.GZIPInputStream; import javax.inject.Inject; @@ -18,6 +20,8 @@ import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileException; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; +import org.alliancegenome.curation_api.model.ingest.dto.IngestDTO; +import org.alliancegenome.curation_api.model.ingest.dto.associations.constructAssociations.ConstructGenomicEntityAssociationDTO; import org.alliancegenome.curation_api.services.APIVersionInfoService; import org.alliancegenome.curation_api.services.DiseaseAnnotationService; import org.alliancegenome.curation_api.services.base.BaseAssociationDTOCrudService; @@ -107,6 +111,23 @@ protected boolean checkSchemaVersion(BulkLoadFile bulkLoadFile, Class dtoClas return true; } + protected IngestDTO readIngestFile(BulkLoadFile bulkLoadFile) { + try { + IngestDTO ingestDto = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), IngestDTO.class); + bulkLoadFile.setLinkMLSchemaVersion(getVersionNumber(ingestDto.getLinkMLVersion())); + if (StringUtils.isNotBlank(ingestDto.getAllianceMemberReleaseVersion())) + bulkLoadFile.setAllianceMemberReleaseVersion(ingestDto.getAllianceMemberReleaseVersion()); + + if(!checkSchemaVersion(bulkLoadFile, ConstructGenomicEntityAssociationDTO.class)) return null; + + return ingestDto; + } catch (Exception e) { + failLoad(bulkLoadFile, e); + e.printStackTrace(); + } + return null; + } + protected boolean validSchemaVersion(String submittedSchemaVersion, Class dtoClass) { List versionRange = apiVersionInfoService.getVersionRange(dtoClass.getAnnotation(AGRCurationSchemaVersion.class)); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantExecutor.java index 0f269f5b9..91c96b2a9 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantExecutor.java @@ -1,9 +1,7 @@ package org.alliancegenome.curation_api.jobs.executors; -import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; -import java.util.zip.GZIPInputStream; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; @@ -22,7 +20,6 @@ import org.alliancegenome.curation_api.response.LoadHistoryResponce; import org.alliancegenome.curation_api.services.VariantService; import org.alliancegenome.curation_api.util.ProcessDisplayHelper; -import org.apache.commons.lang3.StringUtils; import io.quarkus.logging.Log; @@ -36,43 +33,33 @@ public class VariantExecutor extends LoadFileExecutor { public void runLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { - try { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); - Log.info("Running with: " + manual.getDataProvider().name()); - - IngestDTO ingestDto = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), IngestDTO.class); - bulkLoadFile.setLinkMLSchemaVersion(getVersionNumber(ingestDto.getLinkMLVersion())); - if (StringUtils.isNotBlank(ingestDto.getAllianceMemberReleaseVersion())) - bulkLoadFile.setAllianceMemberReleaseVersion(ingestDto.getAllianceMemberReleaseVersion()); - - if(!checkSchemaVersion(bulkLoadFile, VariantDTO.class)) return; - - List variants = ingestDto.getVariantIngestSet(); - if (variants == null) variants = new ArrayList<>(); - - BackendBulkDataProvider dataProvider = manual.getDataProvider(); - - List variantCuriesLoaded = new ArrayList<>(); - List variantCuriesBefore = variantService.getCuriesByDataProvider(dataProvider.name()); - Log.debug("runLoad: Before: total " + variantCuriesBefore.size()); - - bulkLoadFile.setRecordCount(variants.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); - - BulkLoadFileHistory history = new BulkLoadFileHistory(variants.size()); - - runLoad(history, variants, dataProvider, variantCuriesLoaded); - - if(cleanUp) runCleanup(variantService, history, dataProvider.name(), variantCuriesBefore, variantCuriesLoaded, bulkLoadFile.getMd5Sum()); - - history.finishLoad(); - - trackHistory(history, bulkLoadFile); - - } catch (Exception e) { - failLoad(bulkLoadFile, e); - e.printStackTrace(); - } + BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + Log.info("Running with: " + manual.getDataProvider().name()); + + IngestDTO ingestDto = readIngestFile(bulkLoadFile); + if (ingestDto == null) return; + + List variants = ingestDto.getVariantIngestSet(); + if (variants == null) variants = new ArrayList<>(); + + BackendBulkDataProvider dataProvider = manual.getDataProvider(); + + List variantCuriesLoaded = new ArrayList<>(); + List variantCuriesBefore = variantService.getCuriesByDataProvider(dataProvider.name()); + Log.debug("runLoad: Before: total " + variantCuriesBefore.size()); + + bulkLoadFile.setRecordCount(variants.size() + bulkLoadFile.getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFile); + + BulkLoadFileHistory history = new BulkLoadFileHistory(variants.size()); + + runLoad(history, variants, dataProvider, variantCuriesLoaded); + + if(cleanUp) runCleanup(variantService, history, dataProvider.name(), variantCuriesBefore, variantCuriesLoaded, bulkLoadFile.getMd5Sum()); + + history.finishLoad(); + + trackHistory(history, bulkLoadFile); } // Gets called from the API directly diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/AssociationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/alleleAssociations/AlleleGeneAssociationExecutor.java similarity index 59% rename from src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/AssociationExecutor.java rename to src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/alleleAssociations/AlleleGeneAssociationExecutor.java index 5bbaf46d5..ed6f1703c 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/AssociationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/alleleAssociations/AlleleGeneAssociationExecutor.java @@ -1,19 +1,16 @@ -package org.alliancegenome.curation_api.jobs.executors; +package org.alliancegenome.curation_api.jobs.executors.associations.alleleAssociations; -import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Objects; -import java.util.zip.GZIPInputStream; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; -import org.alliancegenome.curation_api.dao.associations.alleleAssociations.AlleleGeneAssociationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; import org.alliancegenome.curation_api.exceptions.ObjectUpdateException.ObjectUpdateExceptionData; +import org.alliancegenome.curation_api.jobs.executors.LoadFileExecutor; import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGeneAssociation; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; @@ -24,7 +21,6 @@ import org.alliancegenome.curation_api.response.LoadHistoryResponce; import org.alliancegenome.curation_api.services.associations.alleleAssociations.AlleleGeneAssociationService; import org.alliancegenome.curation_api.util.ProcessDisplayHelper; -import org.apache.commons.lang3.StringUtils; import lombok.extern.jbosslog.JBossLog; @@ -32,50 +28,38 @@ @ApplicationScoped public class AlleleGeneAssociationExecutor extends LoadFileExecutor { - @Inject - AlleleGeneAssociationDAO alleleGeneAssociationDAO; @Inject AlleleGeneAssociationService alleleGeneAssociationService; - + public void runLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { - try { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); - BackendBulkDataProvider dataProvider = manual.getDataProvider(); - log.info("Running with dataProvider: " + dataProvider.name()); - - IngestDTO ingestDto = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), IngestDTO.class); - bulkLoadFile.setLinkMLSchemaVersion(getVersionNumber(ingestDto.getLinkMLVersion())); - if (StringUtils.isNotBlank(ingestDto.getAllianceMemberReleaseVersion())) - bulkLoadFile.setAllianceMemberReleaseVersion(ingestDto.getAllianceMemberReleaseVersion()); - - if(!checkSchemaVersion(bulkLoadFile, AlleleGeneAssociationDTO.class)) return; - - List associations = ingestDto.getAlleleGeneAssociationIngestSet(); - if (associations == null) associations = new ArrayList<>(); - - - List associationIdsLoaded = new ArrayList<>(); - List associationIdsBefore = alleleGeneAssociationService.getAlleleGeneAssociationsByDataProvider(dataProvider); - associationIdsBefore.removeIf(Objects::isNull); - - bulkLoadFile.setRecordCount(associations.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); - - BulkLoadFileHistory history = new BulkLoadFileHistory(associations.size()); - - runLoad(history, dataProvider, associations, associationIdsLoaded); - - if(cleanUp) runCleanup(alleleGeneAssociationService, history, dataProvider.name(), associationIdsBefore, associationIdsLoaded, bulkLoadFile.getMd5Sum()); - - history.finishLoad(); - - trackHistory(history, bulkLoadFile); - - } catch (Exception e) { - failLoad(bulkLoadFile, e); - e.printStackTrace(); - } + BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BackendBulkDataProvider dataProvider = manual.getDataProvider(); + log.info("Running with dataProvider: " + dataProvider.name()); + + IngestDTO ingestDto = readIngestFile(bulkLoadFile); + if (ingestDto == null) return; + + List associations = ingestDto.getAlleleGeneAssociationIngestSet(); + if (associations == null) associations = new ArrayList<>(); + + + List associationIdsLoaded = new ArrayList<>(); + List associationIdsBefore = alleleGeneAssociationService.getAssociationsByDataProvider(dataProvider); + associationIdsBefore.removeIf(Objects::isNull); + + bulkLoadFile.setRecordCount(associations.size() + bulkLoadFile.getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFile); + + BulkLoadFileHistory history = new BulkLoadFileHistory(associations.size()); + + runLoad(history, dataProvider, associations, associationIdsLoaded); + + if(cleanUp) runCleanup(alleleGeneAssociationService, history, dataProvider.name(), associationIdsBefore, associationIdsLoaded, bulkLoadFile.getMd5Sum()); + + history.finishLoad(); + + trackHistory(history, bulkLoadFile); } // Gets called from the API directly diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/constructAssociations/ConstructGenomicEntityAssociationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/constructAssociations/ConstructGenomicEntityAssociationExecutor.java new file mode 100644 index 000000000..3145baf0c --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/constructAssociations/ConstructGenomicEntityAssociationExecutor.java @@ -0,0 +1,106 @@ +package org.alliancegenome.curation_api.jobs.executors.associations.constructAssociations; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; + +import org.alliancegenome.curation_api.dao.associations.constructAssociations.ConstructGenomicEntityAssociationDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException.ObjectUpdateExceptionData; +import org.alliancegenome.curation_api.jobs.executors.LoadFileExecutor; +import org.alliancegenome.curation_api.model.entities.associations.constructAssociations.ConstructGenomicEntityAssociation; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; +import org.alliancegenome.curation_api.model.ingest.dto.IngestDTO; +import org.alliancegenome.curation_api.model.ingest.dto.associations.constructAssociations.ConstructGenomicEntityAssociationDTO; +import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.response.LoadHistoryResponce; +import org.alliancegenome.curation_api.services.associations.constructAssociations.ConstructGenomicEntityAssociationService; +import org.alliancegenome.curation_api.util.ProcessDisplayHelper; + +import lombok.extern.jbosslog.JBossLog; + +@JBossLog +@ApplicationScoped +public class ConstructGenomicEntityAssociationExecutor extends LoadFileExecutor { + + @Inject + ConstructGenomicEntityAssociationDAO constructGenomicEntityAssociationDAO; + @Inject + ConstructGenomicEntityAssociationService constructGenomicEntityAssociationService; + + public void runLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { + + BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BackendBulkDataProvider dataProvider = manual.getDataProvider(); + log.info("Running with dataProvider: " + dataProvider.name()); + + IngestDTO ingestDto = readIngestFile(bulkLoadFile); + if (ingestDto == null) return; + + List associations = ingestDto.getConstructGenomicEntityAssociationIngestSet(); + if (associations == null) associations = new ArrayList<>(); + + + List associationIdsLoaded = new ArrayList<>(); + List associationIdsBefore = constructGenomicEntityAssociationService.getAssociationsByDataProvider(dataProvider); + associationIdsBefore.removeIf(Objects::isNull); + + bulkLoadFile.setRecordCount(associations.size() + bulkLoadFile.getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFile); + + BulkLoadFileHistory history = new BulkLoadFileHistory(associations.size()); + + runLoad(history, dataProvider, associations, associationIdsLoaded); + + if(cleanUp) runCleanup(constructGenomicEntityAssociationService, history, dataProvider.name(), associationIdsBefore, associationIdsLoaded, bulkLoadFile.getMd5Sum()); + + history.finishLoad(); + + trackHistory(history, bulkLoadFile); + } + + // Gets called from the API directly + public APIResponse runLoad(String dataProviderName, List associations) { + + List associationIdsLoaded = new ArrayList<>(); + + BulkLoadFileHistory history = new BulkLoadFileHistory(associations.size()); + BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(dataProviderName); + runLoad(history, dataProvider, associations, associationIdsLoaded); + history.finishLoad(); + + return new LoadHistoryResponce(history); + } + + public void runLoad(BulkLoadFileHistory history, BackendBulkDataProvider dataProvider, List associations, List idsAdded) { + + ProcessDisplayHelper ph = new ProcessDisplayHelper(2000); + ph.addDisplayHandler(loadProcessDisplayService); + ph.startProcess("ConstructGenomicEntityAssociation Update for: " + dataProvider.name(), associations.size()); + associations.forEach(associationDTO -> { + try { + ConstructGenomicEntityAssociation association = constructGenomicEntityAssociationService.upsert(associationDTO, dataProvider); + history.incrementCompleted(); + if(idsAdded != null) { + idsAdded.add(association.getId()); + } + } catch (ObjectUpdateException e) { + history.incrementFailed(); + addException(history, e.getData()); + } catch (Exception e) { + history.incrementFailed(); + addException(history, new ObjectUpdateExceptionData(associationDTO, e.getMessage(), e.getStackTrace())); + } + + ph.progressProcess(); + }); + ph.finishProcess(); + + } +} From f70c711d08f981dfe49d0f5872f1e94364250246 Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 14:33:37 +0100 Subject: [PATCH 47/76] Initial work on integration tests --- .../AgmDiseaseAnnotationExecutor.java | 3 - .../curation_api/base/BaseITCase.java | 42 ++ ...nstructGenomicEntityAssociationITCase.java | 516 ++++++++++++++++++ 3 files changed, 558 insertions(+), 3 deletions(-) create mode 100644 src/test/java/org/alliancegenome/curation_api/crud/controllers/associations/ConstructGenomicEntityAssociationITCase.java diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java index e62624d5b..1f63d3833 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java @@ -1,10 +1,8 @@ package org.alliancegenome.curation_api.jobs.executors; -import java.io.FileInputStream; import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.zip.GZIPInputStream; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; @@ -24,7 +22,6 @@ import org.alliancegenome.curation_api.services.AGMDiseaseAnnotationService; import org.alliancegenome.curation_api.services.DiseaseAnnotationService; import org.alliancegenome.curation_api.util.ProcessDisplayHelper; -import org.apache.commons.lang3.StringUtils; import lombok.extern.jbosslog.JBossLog; diff --git a/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java b/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java index d2bdc921b..986294140 100644 --- a/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java @@ -34,6 +34,7 @@ import org.alliancegenome.curation_api.model.entities.VocabularyTerm; import org.alliancegenome.curation_api.model.entities.VocabularyTermSet; import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGeneAssociation; +import org.alliancegenome.curation_api.model.entities.associations.constructAssociations.ConstructGenomicEntityAssociation; import org.alliancegenome.curation_api.model.entities.ontology.AnatomicalTerm; import org.alliancegenome.curation_api.model.entities.ontology.CHEBITerm; import org.alliancegenome.curation_api.model.entities.ontology.ChemicalTerm; @@ -47,6 +48,7 @@ import org.alliancegenome.curation_api.model.entities.ontology.ZECOTerm; import org.alliancegenome.curation_api.model.entities.ontology.ZFATerm; import org.alliancegenome.curation_api.model.entities.slotAnnotations.alleleSlotAnnotations.AlleleSymbolSlotAnnotation; +import org.alliancegenome.curation_api.model.entities.slotAnnotations.constructSlotAnnotations.ConstructSymbolSlotAnnotation; import org.alliancegenome.curation_api.model.entities.slotAnnotations.geneSlotAnnotations.GeneSymbolSlotAnnotation; import org.alliancegenome.curation_api.response.ObjectListResponse; import org.alliancegenome.curation_api.response.ObjectResponse; @@ -216,6 +218,30 @@ public ConditionRelation createConditionRelation(String handle, Reference refere return response.getEntity(); } + + public Construct createConstruct(String modEntityId, Boolean obsolete, VocabularyTerm symbolNameTerm) { + Construct construct = new Construct(); + construct.setModEntityId(modEntityId); + construct.setObsolete(obsolete); + + ConstructSymbolSlotAnnotation symbol = new ConstructSymbolSlotAnnotation(); + symbol.setNameType(symbolNameTerm); + symbol.setDisplayText(modEntityId); + symbol.setFormatText(modEntityId); + + construct.setConstructSymbol(symbol); + + ObjectResponse response = RestAssured.given(). + contentType("application/json"). + body(construct). + when(). + post("/api/construct"). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefConstruct()); + + return response.getEntity(); + } public DataProvider createDataProvider(String organizationAbbreviation, Boolean obsolete) { DataProvider dataProvider = new DataProvider(); @@ -656,6 +682,17 @@ public Construct getConstruct(String identifier) { return res.getEntity(); } + + public ConstructGenomicEntityAssociation getConstructGenomicEntityAssociation(Long constructId, String relationName, String genomicEntityCurie) { + ObjectResponse res = RestAssured.given(). + when(). + get("/api/allelegeneassociation/findBy" + "?constructId=" + constructId + "&relationName=" + relationName + "&genomicEntityCurie=" + genomicEntityCurie). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefConstructGenomicEntityAssociation()); + + return res.getEntity(); + } public ExperimentalCondition getExperimentalCondition(String conditionSummary) { ObjectResponse res = RestAssured.given(). @@ -763,6 +800,11 @@ public TypeRef> getObjectResponseTypeRefConstruct() { return new TypeRef>() { }; } + + private TypeRef> getObjectResponseTypeRefConstructGenomicEntityAssociation() { + return new TypeRef>() { + }; + } private TypeRef> getObjectResponseTypeRefCrossReference() { return new TypeRef>() { }; diff --git a/src/test/java/org/alliancegenome/curation_api/crud/controllers/associations/ConstructGenomicEntityAssociationITCase.java b/src/test/java/org/alliancegenome/curation_api/crud/controllers/associations/ConstructGenomicEntityAssociationITCase.java new file mode 100644 index 000000000..36050ca16 --- /dev/null +++ b/src/test/java/org/alliancegenome/curation_api/crud/controllers/associations/ConstructGenomicEntityAssociationITCase.java @@ -0,0 +1,516 @@ +package org.alliancegenome.curation_api.crud.controllers.associations; + +import static org.hamcrest.Matchers.aMapWithSize; +import static org.hamcrest.Matchers.hasKey; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; + +import java.util.List; + +import org.alliancegenome.curation_api.base.BaseITCase; +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.model.entities.Allele; +import org.alliancegenome.curation_api.model.entities.Construct; +import org.alliancegenome.curation_api.model.entities.Gene; +import org.alliancegenome.curation_api.model.entities.Note; +import org.alliancegenome.curation_api.model.entities.Reference; +import org.alliancegenome.curation_api.model.entities.Vocabulary; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.model.entities.associations.constructAssociations.ConstructGenomicEntityAssociation; +import org.alliancegenome.curation_api.model.entities.ontology.ECOTerm; +import org.alliancegenome.curation_api.resources.TestContainerResource; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestMethodOrder; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.RestAssured; + +@QuarkusIntegrationTest +@QuarkusTestResource(TestContainerResource.Initializer.class) +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +@Order(302) +public class ConstructGenomicEntityAssociationITCase extends BaseITCase { + + private Construct construct; + private Construct construct2; + private Construct obsoleteConstruct; + private Gene gene; + private Gene gene2; + private Gene obsoleteGene; + private VocabularyTerm relation; + private VocabularyTerm relation2; + private VocabularyTerm obsoleteRelation; + private Reference reference; + private Reference reference2; + private Reference obsoleteReference; + private VocabularyTerm noteType; + private VocabularyTerm noteType2; + private VocabularyTerm obsoleteNoteType; + private Note note; + private Note note2; + + private final String constructGenomicEntityAssociationGetEndpoint = "/api/constructgenomicentityassociation/findBy"; + private final String constructGetEndpoint = "/api/construct/"; + + private void loadRequiredEntities() { + Vocabulary nameTypeVocabulary = getVocabulary(VocabularyConstants.NAME_TYPE_VOCABULARY); + VocabularyTerm symbolNameType = getVocabularyTerm(nameTypeVocabulary, "nomenclature_symbol"); + construct = createConstruct("CGEA:Construct0001", false, symbolNameType); + construct2 = createConstruct("CGEA:Construct0002", false, symbolNameType); + obsoleteConstruct = createConstruct("CGEA:Construct0003", true, symbolNameType); + gene = createGene("CGEA:Gene0001", "NCBITaxon:6239", false, symbolNameType); + gene2 = createGene("CGEA:Gene0002", "NCBITaxon:6239", false, symbolNameType); + obsoleteGene = createGene("CGEA:Gene0003", "NCBITaxon:6239", true, symbolNameType); + Vocabulary relationVocabulary = getVocabulary(VocabularyConstants.ALLELE_RELATION_VOCABULARY); + relation = getVocabularyTerm(relationVocabulary, "is_construct_of"); + relation2 = getVocabularyTerm(relationVocabulary, "mutation_excludes"); + obsoleteRelation = addVocabularyTermToSet(VocabularyConstants.ALLELE_GENE_RELATION_VOCABULARY_TERM_SET, "is_obsolete", relationVocabulary, true); + reference = createReference("AGRKB:AGA0001", false); + reference2 = createReference("AGRKB:AGA0002", false); + obsoleteReference = createReference("AGRKB:AGA0003", true); + Vocabulary noteTypeVocabulary = getVocabulary(VocabularyConstants.NOTE_TYPE_VOCABULARY); + noteType = getVocabularyTerm(noteTypeVocabulary, "comment"); + noteType2 = getVocabularyTerm(noteTypeVocabulary, "remark"); + obsoleteNoteType = addVocabularyTermToSet(VocabularyConstants.ALLELE_GENOMIC_ENTITY_ASSOCIATION_NOTE_TYPES_VOCABULARY_TERM_SET, "obsolete_note_type", noteTypeVocabulary, true); + note = createNote(noteType, "AGA Test Note", false, reference); + note2 = createNote(noteType2, "AGA Test Note 2", false, reference2); + } + + @Test + @Order(1) + public void createValidConstructGenomicEntityAssociation() { + loadRequiredEntities(); + + ConstructGenomicEntityAssociation association = new ConstructGenomicEntityAssociation(); + association.setSubject(construct); + association.setObject(gene); + association.setRelation(relation); + association.setInternal(true); + association.setObsolete(true); + association.setRelatedNotes(List.of(note)); + association.setEvidence(List.of(reference)); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + post("/api/constructgeneassociation"). + then(). + statusCode(200); + + RestAssured.given(). + when(). + get(constructGenomicEntityAssociationGetEndpoint + "?constructId=" + construct.getId() + "&relationName=" + relation.getName() + "&genomicEntityCurie=" + gene.getCurie()). + then(). + statusCode(200). + body("entity.relation.name", is(relation.getName())). + body("entity.object.curie", is(gene.getCurie())). + body("entity.subject.curie", is(construct.getCurie())). + body("entity.evidence", hasSize(1)). + body("entity.evidence[0].curie", is(reference.getCurie())). + body("entity.internal", is(true)). + body("entity.obsolete", is(true)). + body("entity.createdBy.uniqueId", is("Local|Dev User|test@alliancegenome.org")). + body("entity.updatedBy.uniqueId", is("Local|Dev User|test@alliancegenome.org")). + body("entity.relatedNotes[0].internal", is(false)). + body("entity.relatedNotes[0].obsolete", is(false)). + body("entity.relatedNotes[0].updatedBy.uniqueId", is("Local|Dev User|test@alliancegenome.org")). + body("entity.relatedNotes[0].createdBy.uniqueId", is("Local|Dev User|test@alliancegenome.org")). + body("entity.relatedNotes[0].freeText", is(note.getFreeText())). + body("entity.relatedNotes[0].noteType.name", is(noteType.getName())). + body("entity.relatedNotes[0].references[0].curie", is(reference.getCurie())); + + RestAssured.given(). + when(). + get(constructGetEndpoint + construct.getId()). + then(). + statusCode(200). + body("entity.constructGeneAssociations", hasSize(1)). + body("entity.constructGeneAssociations[0].relation.name", is(relation.getName())). + body("entity.constructGeneAssociations[0].object.curie", is(gene.getCurie())). + body("entity.constructGeneAssociations[0].subject", not(hasKey("constructGeneAssociations"))); + } + + @Test + @Order(2) + public void editConstructGenomicEntityAssociation() { + ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct.getId(), relation.getName(), gene.getCurie()); + association.setSubject(construct2); + association.setRelation(relation2); + association.setObject(gene2); + association.setInternal(false); + association.setObsolete(false); + association.setEvidence(List.of(reference2)); + association.setRelatedNotes(List.of(note2)); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + put("/api/constructgeneassociation"). + then(). + statusCode(200); + + RestAssured.given(). + when(). + get(constructGenomicEntityAssociationGetEndpoint + "?constructId=" + construct2.getId() + "&relationName=" + relation2.getName() + "&genomicEntityCurie=" + gene2.getCurie()). + then(). + statusCode(200). + body("entity.relation.name", is(relation2.getName())). + body("entity.object.curie", is(gene2.getCurie())). + body("entity.subject.modEntityId", is(construct2.getModEntityId())). + body("entity.evidence", hasSize(1)). + body("entity.evidence[0].curie", is(reference2.getCurie())). + body("entity.internal", is(false)). + body("entity.obsolete", is(false)). + body("entity.createdBy.uniqueId", is("Local|Dev User|test@alliancegenome.org")). + body("entity.updatedBy.uniqueId", is("Local|Dev User|test@alliancegenome.org")). + body("entity.relatedNotes[0].internal", is(false)). + body("entity.relatedNotes[0].obsolete", is(false)). + body("entity.relatedNotes[0].updatedBy.uniqueId", is("Local|Dev User|test@alliancegenome.org")). + body("entity.relatedNotes[0].createdBy.uniqueId", is("Local|Dev User|test@alliancegenome.org")). + body("entity.relatedNotes[0].freeText", is(note2.getFreeText())). + body("entity.relatedNotes[0].noteType.name", is(noteType2.getName())). + body("entity.relatedNotes[0].references[0].curie", is(reference2.getCurie())); + } + + @Test + @Order(3) + public void createConstructGenomicEntityAssociationWithMissingRequiredFieldsLevel1() { + ConstructGenomicEntityAssociation association = new ConstructGenomicEntityAssociation(); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + post("/api/constructgeneassociation"). + then(). + statusCode(400). + body("errorMessages", is(aMapWithSize(3))). + body("errorMessages.subject", is(ValidationConstants.REQUIRED_MESSAGE)). + body("errorMessages.relation", is(ValidationConstants.REQUIRED_MESSAGE)). + body("errorMessages.object", is(ValidationConstants.REQUIRED_MESSAGE)); + } + + @Test + @Order(4) + public void createConstructGenomicEntityAssociationWithMissingRequiredFieldsLevel2() { + ConstructGenomicEntityAssociation association = new ConstructGenomicEntityAssociation(); + association.setSubject(construct2); + association.setRelation(relation); + association.setObject(gene); + + Note emptyNote = new Note(); + association.setRelatedNotes(List.of(emptyNote)); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + post("/api/constructgeneassociation"). + then(). + statusCode(400). + body("errorMessages", is(aMapWithSize(1))). + body("errorMessages.relatedNote", is(String.join(" | ", List.of( + "freeText - " + ValidationConstants.REQUIRED_MESSAGE, + "noteType - " + ValidationConstants.REQUIRED_MESSAGE)))); + } + + @Test + @Order(5) + public void createConstructGenomicEntityAssociationWithEmptyRequiredFieldsLevel2() { + ConstructGenomicEntityAssociation association = new ConstructGenomicEntityAssociation(); + association.setSubject(construct2); + association.setRelation(relation); + association.setObject(gene); + + Note invalidNote = new Note(); + invalidNote.setNoteType(noteType); + association.setRelatedNotes(List.of(invalidNote)); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + post("/api/constructgeneassociation"). + then(). + statusCode(400). + body("errorMessages", is(aMapWithSize(1))). + body("errorMessages.relatedNote", is("freeText - " + ValidationConstants.REQUIRED_MESSAGE)); + } + + @Test + @Order(6) + public void editConstructGenomicEntityAssociationWithMissingRequiredFieldsLevel1() { + ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct2.getId(), relation2.getName(), gene2.getCurie()); + association.setSubject(null); + association.setRelation(null); + association.setObject(null); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + put("/api/constructgeneassociation"). + then(). + statusCode(400). + body("errorMessages", is(aMapWithSize(3))). + body("errorMessages.subject", is(ValidationConstants.REQUIRED_MESSAGE)). + body("errorMessages.relation", is(ValidationConstants.REQUIRED_MESSAGE)). + body("errorMessages.object", is(ValidationConstants.REQUIRED_MESSAGE)); + } + + @Test + @Order(7) + public void editConstructGenomicEntityAssociationWithMissingRequiredFieldsLevel2() { + ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct2.getId(), relation2.getName(), gene2.getCurie()); + + Note invalidNote = association.getRelatedNote(); + invalidNote.setFreeText(null); + invalidNote.setNoteType(null); + association.setRelatedNotes(List.of(invalidNote)); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + put("/api/constructgeneassociation"). + then(). + statusCode(400). + body("errorMessages", is(aMapWithSize(1))). + body("errorMessages.relatedNote", is(String.join(" | ", List.of( + "freeText - " + ValidationConstants.REQUIRED_MESSAGE, + "noteType - " + ValidationConstants.REQUIRED_MESSAGE)))); + } + + @Test + @Order(8) + public void editConstructGenomicEntityAssociationWithEmptyRequiredFieldsLevel2() { + ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct2.getId(), relation2.getName(), gene2.getCurie()); + + Note invalidNote = association.getRelatedNote(); + invalidNote.setFreeText(""); + association.setRelatedNotes(List.of(invalidNote)); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + put("/api/constructgeneassociation"). + then(). + statusCode(400). + body("errorMessages", is(aMapWithSize(1))). + body("errorMessages.relatedNote", is("freeText - " + ValidationConstants.REQUIRED_MESSAGE)); + } + + @Test + @Order(9) + public void createConstructGenomicEntityAssociationWithInvalidFields() { + Allele nonPersistedAllele = new Allele(); + nonPersistedAllele.setCurie("NP:Allele01"); + Gene nonPersistedGene = new Gene(); + nonPersistedGene.setCurie("NP:Gene01"); + Reference nonPersistedReference = new Reference(); + nonPersistedReference.setCurie("AGRKB:Invalid"); + ECOTerm nonPersistedEcoTerm = new ECOTerm(); + nonPersistedEcoTerm.setCurie("ECO:Invalid"); + + Note invalidNote = new Note(); + invalidNote.setNoteType(relation); + invalidNote.setReferences(List.of(nonPersistedReference)); + invalidNote.setFreeText("Invalid"); + + ConstructGenomicEntityAssociation association = new ConstructGenomicEntityAssociation(); + association.setSubject(nonPersistedAllele); + association.setRelation(noteType); + association.setObject(nonPersistedGene); + association.setEvidence(List.of(nonPersistedReference)); + association.setRelatedNotes(List.of(invalidNote)); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + post("/api/constructgeneassociation"). + then(). + statusCode(400). + body("errorMessages", is(aMapWithSize(6))). + body("errorMessages.subject", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.relation", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.object", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.evidence", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.evidenceCode", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.relatedNote", is(String.join(" | ", List.of( + "noteType - " + ValidationConstants.INVALID_MESSAGE, + "references - " + ValidationConstants.INVALID_MESSAGE)))); + } + + @Test + @Order(9) + public void editConstructGenomicEntityAssociationWithInvalidFields() { + Allele nonPersistedAllele = new Allele(); + nonPersistedAllele.setCurie("NP:Allele01"); + Gene nonPersistedGene = new Gene(); + nonPersistedGene.setCurie("NP:Gene01"); + Reference nonPersistedReference = new Reference(); + nonPersistedReference.setCurie("AGRKB:Invalid"); + ECOTerm nonPersistedEcoTerm = new ECOTerm(); + nonPersistedEcoTerm.setCurie("ECO:Invalid"); + + Note invalidNote = new Note(); + invalidNote.setNoteType(relation); + invalidNote.setReferences(List.of(nonPersistedReference)); + invalidNote.setFreeText("Invalid"); + + ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct2.getId(), relation2.getName(), gene2.getCurie()); + association.setSubject(nonPersistedAllele); + association.setRelation(noteType); + association.setObject(nonPersistedGene); + association.setEvidence(List.of(nonPersistedReference)); + association.setRelatedNotes(List.of(invalidNote)); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + put("/api/constructgeneassociation"). + then(). + statusCode(400). + body("errorMessages", is(aMapWithSize(6))). + body("errorMessages.subject", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.relation", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.object", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.evidence", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.evidenceCode", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.relatedNote", is(String.join(" | ", List.of( + "noteType - " + ValidationConstants.INVALID_MESSAGE, + "references - " + ValidationConstants.INVALID_MESSAGE)))); + } + + @Test + @Order(10) + public void createConstructGenomicEntityAssociationWithObsoleteFields() { + ConstructGenomicEntityAssociation association = new ConstructGenomicEntityAssociation(); + + association.setSubject(obsoleteAllele); + association.setRelation(obsoleteRelation); + association.setObject(obsoleteGene); + association.setEvidence(List.of(obsoleteReference)); + + Note note = new Note(); + note.setFreeText("Obsolete note"); + note.setNoteType(obsoleteNoteType); + note.setReferences(List.of(obsoleteReference)); + + association.setRelatedNotes(List.of(note)); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + post("/api/constructgeneassociation"). + then(). + statusCode(400). + body("errorMessages", is(aMapWithSize(6))). + body("errorMessages.subject", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.relation", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.object", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.evidence", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.evidenceCode", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.relatedNote", is(String.join(" | ", List.of( + "noteType - " + ValidationConstants.OBSOLETE_MESSAGE, + "references - " + ValidationConstants.OBSOLETE_MESSAGE)))); + } + + @Test + @Order(11) + public void editConstructGenomicEntityAssociationWithObsoleteFields() { + ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct2.getId(), relation2.getName(), gene2.getCurie()); + + association.setSubject(obsoleteAllele); + association.setRelation(obsoleteRelation); + association.setObject(obsoleteGene); + association.setEvidence(List.of(obsoleteReference)); + + Note note = association.getRelatedNote(); + note.setNoteType(obsoleteNoteType); + note.setReferences(List.of(obsoleteReference)); + + association.setRelatedNotes(List.of(note)); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + put("/api/constructgeneassociation"). + then(). + statusCode(400). + body("errorMessages", is(aMapWithSize(6))). + body("errorMessages.subject", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.relation", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.object", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.evidence", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.evidenceCode", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.relatedNote", is(String.join(" | ", List.of( + "noteType - " + ValidationConstants.OBSOLETE_MESSAGE, + "references - " + ValidationConstants.OBSOLETE_MESSAGE)))); + } + + @Test + @Order(12) + public void editConstructGenomicEntityAssociationWithNullNonRequiredFieldsLevel2() { + ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct2.getId(), relation2.getName(), gene2.getCurie()); + + Note editedNote = association.getRelatedNote(); + editedNote.setReferences(null); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + put("/api/constructgeneassociation"). + then(). + statusCode(200); + + RestAssured.given(). + when(). + get(constructGenomicEntityAssociationGetEndpoint + "?constructId=" + construct2.getId() + "&relationName=" + relation2.getName() + "&genomicEntityCurie=" + gene2.getCurie()). + then(). + statusCode(200). + body("entity", hasKey("relatedNote")). + body("entity.relatedNote", not(hasKey("references"))); + } + + @Test + @Order(13) + public void editConstructGenomicEntityAssociationWithNullNonRequiredFieldsLevel1() { + ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct2.getId(), relation2.getName(), gene2.getCurie()); + + association.setEvidence(null); + association.setRelatedNotes(List.of(null)); + + RestAssured.given(). + contentType("application/json"). + body(association). + when(). + put("/api/constructgeneassociation"). + then(). + statusCode(200); + + RestAssured.given(). + when(). + get(constructGeneAssociationGetEndpoint + "?constructId=" + construct2.getId() + "&relationName=" + relation2.getName() + "&genomicEntityCurie=" + gene2.getCurie()). + then(). + statusCode(200). + body("entity", not(hasKey("evidence"))). + body("entity", not(hasKey("evidenceCode"))). + body("entity", not(hasKey("relatedNote"))); + } +} From dccab5b57431839c0b66cbbae7fc1460444b898c Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 15:11:49 +0100 Subject: [PATCH 48/76] UI fixes --- .../src/components/Editors/boolean/BooleanTableEditor.js | 4 ++-- .../cliapp/src/containers/variantsPage/VariantsTable.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/cliapp/src/components/Editors/boolean/BooleanTableEditor.js b/src/main/cliapp/src/components/Editors/boolean/BooleanTableEditor.js index f0c3ecf60..9ead9fda8 100644 --- a/src/main/cliapp/src/components/Editors/boolean/BooleanTableEditor.js +++ b/src/main/cliapp/src/components/Editors/boolean/BooleanTableEditor.js @@ -3,7 +3,7 @@ import { TrueFalseDropdown } from "../../TrueFalseDropDownSelector"; import { ErrorMessageComponent } from "../../Error/ErrorMessageComponent"; import { useControlledVocabularyService } from "../../../service/useControlledVocabularyService"; -export const BooleanTableEditor = ({ rowProps, errorMessagesRef, field}) => { +export const BooleanTableEditor = ({ rowProps, errorMessagesRef, field, showClear=true }) => { const booleanTerms = useControlledVocabularyService("generic_boolean_terms"); @@ -24,7 +24,7 @@ export const BooleanTableEditor = ({ rowProps, errorMessagesRef, field}) => { editorChange={editorChange} props={rowProps} field={field} - showClear={true} + showClear={showClear} /> diff --git a/src/main/cliapp/src/containers/variantsPage/VariantsTable.js b/src/main/cliapp/src/containers/variantsPage/VariantsTable.js index 7b07f27fd..dcfce87bb 100644 --- a/src/main/cliapp/src/containers/variantsPage/VariantsTable.js +++ b/src/main/cliapp/src/containers/variantsPage/VariantsTable.js @@ -270,7 +270,7 @@ export const VariantsTable = () => { filterConfig: FILTER_CONFIGS.internalFilterConfig, sortable: isEnabled, editor: (props) => ( - + ) }, { @@ -281,7 +281,7 @@ export const VariantsTable = () => { filterConfig: FILTER_CONFIGS.obsoleteFilterConfig, sortable: isEnabled, editor: (props) => ( - + ) } ]; @@ -311,7 +311,7 @@ export const VariantsTable = () => { defaultColumnNames={defaultColumnNames} initialTableState={initialTableState} isEditable={true} - hasDetails={true} + hasDetails={false} mutation={mutation} isEnabled={isEnabled} setIsEnabled={setIsEnabled} From 90f4b5765a203957547767be892b225ff4f2ca2b Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 16:46:11 +0100 Subject: [PATCH 49/76] Add migration --- ...GenomicEntityAssociationCrudInterface.java | 1 - .../ConstructGenomicEntityAssociation.java | 7 ++- ...d_construct_genomic_entity_association.sql | 48 ++++++++++++++ .../curation_api/base/BaseITCase.java | 2 +- ...nstructGenomicEntityAssociationITCase.java | 62 +++++++++---------- 5 files changed, 83 insertions(+), 37 deletions(-) create mode 100644 src/main/resources/db/migration/v0.27.0.8__add_construct_genomic_entity_association.sql diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudInterface.java index af8e8da1d..b4c509c6a 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/associations/constructAssociations/ConstructGenomicEntityAssociationCrudInterface.java @@ -12,7 +12,6 @@ import javax.ws.rs.core.MediaType; import org.alliancegenome.curation_api.interfaces.base.BaseIdCrudInterface; -import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGeneAssociation; import org.alliancegenome.curation_api.model.entities.associations.constructAssociations.ConstructGenomicEntityAssociation; import org.alliancegenome.curation_api.model.ingest.dto.associations.constructAssociations.ConstructGenomicEntityAssociationDTO; import org.alliancegenome.curation_api.response.APIResponse; 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 2a09d54f2..bc7466a37 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 @@ -4,6 +4,7 @@ import javax.persistence.Entity; import javax.persistence.Index; +import javax.persistence.JoinTable; import javax.persistence.ManyToOne; import javax.persistence.OneToOne; import javax.persistence.Table; @@ -39,7 +40,7 @@ @AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociation.class }) @Schema(name = "ConstructGenomicEntityAssociation", description = "POJO representing an association between a construct and a genomic entity") @Table(indexes = { - @Index(name = "constructgenomicentityassociation_subject_index", columnList = "subject_curie"), + @Index(name = "constructgenomicentityassociation_subject_index", columnList = "subject_id"), @Index(name = "constructgenomicentityassociation_object_index", columnList = "object_curie"), @Index(name = "constructgenomicentityassociation_relation_index", columnList = "relation_id") }) @@ -68,5 +69,9 @@ public class ConstructGenomicEntityAssociation extends EvidenceAssociation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @OneToOne @JsonView({ View.FieldsAndLists.class, View.ConstructView.class }) + @JoinTable(indexes = { + @Index(name = "cgeassociation_note_cgeassociation_id_index", columnList = "constructgenomicassociation_id"), + @Index(name = "cgeassociation_note_relatednotes_id_index", columnList = "relatedNotes_id") + }) private List relatedNotes; } diff --git a/src/main/resources/db/migration/v0.27.0.8__add_construct_genomic_entity_association.sql b/src/main/resources/db/migration/v0.27.0.8__add_construct_genomic_entity_association.sql new file mode 100644 index 000000000..9d31867d6 --- /dev/null +++ b/src/main/resources/db/migration/v0.27.0.8__add_construct_genomic_entity_association.sql @@ -0,0 +1,48 @@ +CREATE TABLE constructgenomicentityassociation ( + id bigint PRIMARY KEY, + subject_id bigint, + object_curie varchar(255), + relation_id bigint + ); + +ALTER TABLE constructgenomicentityassociation ADD CONSTRAINT constructgenomicentityassociation_id_fk FOREIGN KEY (id) REFERENCES association (id); +ALTER TABLE constructgenomicentityassociation ADD CONSTRAINT constructgenomicentityassociation_subject_id_fk FOREIGN KEY (subject_id) REFERENCES construct (id); +ALTER TABLE constructgenomicentityassociation ADD CONSTRAINT constructgenomicentityassociation_object_curie_fk FOREIGN KEY (object_curie) REFERENCES genomicentity (curie); +ALTER TABLE constructgenomicentityassociation ADD CONSTRAINT constructgenomicentityassociation_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm (id); + +CREATE INDEX constructgenomicentityassociation_subject_index ON constructgenomicentityassociation USING btree (subject_id); +CREATE INDEX constructgenomicentityassociation_object_index ON constructgenomicentityassociation USING btree (object_curie); +CREATE INDEX constructgenomicentityassociation_relation_index ON constructgenomicentityassociation USING btree (relation_id); + +CREATE TABLE constructgenomicentityassociation_aud ( + id bigint NOT NULL, + subject_id bigint, + object_curie varchar(255), + relation_id bigint, + rev integer NOT NULL, + PRIMARY KEY (id, rev) + ); + +ALTER TABLE constructgenomicentityassociation_aud ADD CONSTRAINT constructgenomicentityassociation_aud_id_rev_fk FOREIGN KEY (id, rev) REFERENCES evidenceassociation_aud (id, rev); + +CREATE TABLE constructgenomicentityassociation_note ( + constructgenomicentityassociation_id bigint, + relatednotes_id bigint +); + +ALTER TABLE constructgenomicentityassociation_note ADD CONSTRAINT cgeassociation_note_cgeassociation_id_fk FOREIGN KEY (constructgenomicentityassociation_id) REFERENCES constructgenomicentityassociation (id); +ALTER TABLE constructgenomicentityassociation_note ADD CONSTRAINT cgeassociation_note_relatednotes_id_fk FOREIGN KEY (relatednotes_id) REFERENCES note (id); + +CREATE INDEX cgeassociation_note_cgeassociation_id_index ON constructgenomicentityassociation_note USING btree (constructgenomicentityassociation_id); +CREATE INDEX cgeassociation_note_relatednotes_id_index ON constructgenomicentityassociation_note USING btree (relatednotes_id); + +CREATE TABLE constructgenomicentityassociation_note_aud ( + constructgenomicentityassociation_id bigint, + relatednotes_id bigint, + rev integer NOT NULL, + revtype smallint +); + +ALTER TABLE constructgenomicentityassociation_note_aud ADD PRIMARY KEY (constructgenomicentityassociation_id, relatednotes_id, rev); + +ALTER TABLE constructgenomicentityassociation_note_aud ADD CONSTRAINT constructgenomicentityassociation_note_aud_rev_fk FOREIGN KEY (rev) REFERENCES revinfo (rev); \ No newline at end of file diff --git a/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java b/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java index 986294140..60d7ca065 100644 --- a/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java @@ -684,7 +684,7 @@ public Construct getConstruct(String identifier) { } public ConstructGenomicEntityAssociation getConstructGenomicEntityAssociation(Long constructId, String relationName, String genomicEntityCurie) { - ObjectResponse res = RestAssured.given(). + ObjectResponse res = RestAssured.given(). when(). get("/api/allelegeneassociation/findBy" + "?constructId=" + constructId + "&relationName=" + relationName + "&genomicEntityCurie=" + genomicEntityCurie). then(). diff --git a/src/test/java/org/alliancegenome/curation_api/crud/controllers/associations/ConstructGenomicEntityAssociationITCase.java b/src/test/java/org/alliancegenome/curation_api/crud/controllers/associations/ConstructGenomicEntityAssociationITCase.java index 36050ca16..e394fe324 100644 --- a/src/test/java/org/alliancegenome/curation_api/crud/controllers/associations/ConstructGenomicEntityAssociationITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/crud/controllers/associations/ConstructGenomicEntityAssociationITCase.java @@ -11,7 +11,6 @@ import org.alliancegenome.curation_api.base.BaseITCase; import org.alliancegenome.curation_api.constants.ValidationConstants; import org.alliancegenome.curation_api.constants.VocabularyConstants; -import org.alliancegenome.curation_api.model.entities.Allele; import org.alliancegenome.curation_api.model.entities.Construct; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.Note; @@ -218,7 +217,7 @@ public void createConstructGenomicEntityAssociationWithMissingRequiredFieldsLeve then(). statusCode(400). body("errorMessages", is(aMapWithSize(1))). - body("errorMessages.relatedNote", is(String.join(" | ", List.of( + body("errorMessages.relatedNotes", is(String.join(" | ", List.of( "freeText - " + ValidationConstants.REQUIRED_MESSAGE, "noteType - " + ValidationConstants.REQUIRED_MESSAGE)))); } @@ -243,7 +242,7 @@ public void createConstructGenomicEntityAssociationWithEmptyRequiredFieldsLevel2 then(). statusCode(400). body("errorMessages", is(aMapWithSize(1))). - body("errorMessages.relatedNote", is("freeText - " + ValidationConstants.REQUIRED_MESSAGE)); + body("errorMessages.relatedNotes", is("freeText - " + ValidationConstants.REQUIRED_MESSAGE)); } @Test @@ -272,7 +271,7 @@ public void editConstructGenomicEntityAssociationWithMissingRequiredFieldsLevel1 public void editConstructGenomicEntityAssociationWithMissingRequiredFieldsLevel2() { ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct2.getId(), relation2.getName(), gene2.getCurie()); - Note invalidNote = association.getRelatedNote(); + Note invalidNote = association.getRelatedNotes().get(0); invalidNote.setFreeText(null); invalidNote.setNoteType(null); association.setRelatedNotes(List.of(invalidNote)); @@ -285,7 +284,7 @@ public void editConstructGenomicEntityAssociationWithMissingRequiredFieldsLevel2 then(). statusCode(400). body("errorMessages", is(aMapWithSize(1))). - body("errorMessages.relatedNote", is(String.join(" | ", List.of( + body("errorMessages.relatedNotes", is(String.join(" | ", List.of( "freeText - " + ValidationConstants.REQUIRED_MESSAGE, "noteType - " + ValidationConstants.REQUIRED_MESSAGE)))); } @@ -295,7 +294,7 @@ public void editConstructGenomicEntityAssociationWithMissingRequiredFieldsLevel2 public void editConstructGenomicEntityAssociationWithEmptyRequiredFieldsLevel2() { ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct2.getId(), relation2.getName(), gene2.getCurie()); - Note invalidNote = association.getRelatedNote(); + Note invalidNote = association.getRelatedNotes().get(0); invalidNote.setFreeText(""); association.setRelatedNotes(List.of(invalidNote)); @@ -307,14 +306,14 @@ public void editConstructGenomicEntityAssociationWithEmptyRequiredFieldsLevel2() then(). statusCode(400). body("errorMessages", is(aMapWithSize(1))). - body("errorMessages.relatedNote", is("freeText - " + ValidationConstants.REQUIRED_MESSAGE)); + body("errorMessages.relatedNotes", is("freeText - " + ValidationConstants.REQUIRED_MESSAGE)); } @Test @Order(9) public void createConstructGenomicEntityAssociationWithInvalidFields() { - Allele nonPersistedAllele = new Allele(); - nonPersistedAllele.setCurie("NP:Allele01"); + Construct nonPersistedConstruct = new Construct(); + nonPersistedConstruct.setCurie("NP:Construct01"); Gene nonPersistedGene = new Gene(); nonPersistedGene.setCurie("NP:Gene01"); Reference nonPersistedReference = new Reference(); @@ -328,7 +327,7 @@ public void createConstructGenomicEntityAssociationWithInvalidFields() { invalidNote.setFreeText("Invalid"); ConstructGenomicEntityAssociation association = new ConstructGenomicEntityAssociation(); - association.setSubject(nonPersistedAllele); + association.setSubject(nonPersistedConstruct); association.setRelation(noteType); association.setObject(nonPersistedGene); association.setEvidence(List.of(nonPersistedReference)); @@ -341,13 +340,12 @@ public void createConstructGenomicEntityAssociationWithInvalidFields() { post("/api/constructgeneassociation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(6))). + body("errorMessages", is(aMapWithSize(5))). body("errorMessages.subject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.object", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.evidence", is(ValidationConstants.INVALID_MESSAGE)). - body("errorMessages.evidenceCode", is(ValidationConstants.INVALID_MESSAGE)). - body("errorMessages.relatedNote", is(String.join(" | ", List.of( + body("errorMessages.relatedNotes", is(String.join(" | ", List.of( "noteType - " + ValidationConstants.INVALID_MESSAGE, "references - " + ValidationConstants.INVALID_MESSAGE)))); } @@ -355,8 +353,8 @@ public void createConstructGenomicEntityAssociationWithInvalidFields() { @Test @Order(9) public void editConstructGenomicEntityAssociationWithInvalidFields() { - Allele nonPersistedAllele = new Allele(); - nonPersistedAllele.setCurie("NP:Allele01"); + Construct nonPersistedConstruct = new Construct(); + nonPersistedConstruct.setCurie("NP:Construct01"); Gene nonPersistedGene = new Gene(); nonPersistedGene.setCurie("NP:Gene01"); Reference nonPersistedReference = new Reference(); @@ -370,7 +368,7 @@ public void editConstructGenomicEntityAssociationWithInvalidFields() { invalidNote.setFreeText("Invalid"); ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct2.getId(), relation2.getName(), gene2.getCurie()); - association.setSubject(nonPersistedAllele); + association.setSubject(nonPersistedConstruct); association.setRelation(noteType); association.setObject(nonPersistedGene); association.setEvidence(List.of(nonPersistedReference)); @@ -383,13 +381,12 @@ public void editConstructGenomicEntityAssociationWithInvalidFields() { put("/api/constructgeneassociation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(6))). + body("errorMessages", is(aMapWithSize(5))). body("errorMessages.subject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.object", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.evidence", is(ValidationConstants.INVALID_MESSAGE)). - body("errorMessages.evidenceCode", is(ValidationConstants.INVALID_MESSAGE)). - body("errorMessages.relatedNote", is(String.join(" | ", List.of( + body("errorMessages.relatedNotes", is(String.join(" | ", List.of( "noteType - " + ValidationConstants.INVALID_MESSAGE, "references - " + ValidationConstants.INVALID_MESSAGE)))); } @@ -399,7 +396,7 @@ public void editConstructGenomicEntityAssociationWithInvalidFields() { public void createConstructGenomicEntityAssociationWithObsoleteFields() { ConstructGenomicEntityAssociation association = new ConstructGenomicEntityAssociation(); - association.setSubject(obsoleteAllele); + association.setSubject(obsoleteConstruct); association.setRelation(obsoleteRelation); association.setObject(obsoleteGene); association.setEvidence(List.of(obsoleteReference)); @@ -418,13 +415,12 @@ public void createConstructGenomicEntityAssociationWithObsoleteFields() { post("/api/constructgeneassociation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(6))). + body("errorMessages", is(aMapWithSize(5))). body("errorMessages.subject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.object", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.evidence", is(ValidationConstants.OBSOLETE_MESSAGE)). - body("errorMessages.evidenceCode", is(ValidationConstants.OBSOLETE_MESSAGE)). - body("errorMessages.relatedNote", is(String.join(" | ", List.of( + body("errorMessages.relatedNotes", is(String.join(" | ", List.of( "noteType - " + ValidationConstants.OBSOLETE_MESSAGE, "references - " + ValidationConstants.OBSOLETE_MESSAGE)))); } @@ -434,12 +430,12 @@ public void createConstructGenomicEntityAssociationWithObsoleteFields() { public void editConstructGenomicEntityAssociationWithObsoleteFields() { ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct2.getId(), relation2.getName(), gene2.getCurie()); - association.setSubject(obsoleteAllele); + association.setSubject(obsoleteConstruct); association.setRelation(obsoleteRelation); association.setObject(obsoleteGene); association.setEvidence(List.of(obsoleteReference)); - Note note = association.getRelatedNote(); + Note note = association.getRelatedNotes().get(0); note.setNoteType(obsoleteNoteType); note.setReferences(List.of(obsoleteReference)); @@ -452,13 +448,12 @@ public void editConstructGenomicEntityAssociationWithObsoleteFields() { put("/api/constructgeneassociation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(6))). + body("errorMessages", is(aMapWithSize(5))). body("errorMessages.subject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.object", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.evidence", is(ValidationConstants.OBSOLETE_MESSAGE)). - body("errorMessages.evidenceCode", is(ValidationConstants.OBSOLETE_MESSAGE)). - body("errorMessages.relatedNote", is(String.join(" | ", List.of( + body("errorMessages.relatedNotes", is(String.join(" | ", List.of( "noteType - " + ValidationConstants.OBSOLETE_MESSAGE, "references - " + ValidationConstants.OBSOLETE_MESSAGE)))); } @@ -468,7 +463,7 @@ public void editConstructGenomicEntityAssociationWithObsoleteFields() { public void editConstructGenomicEntityAssociationWithNullNonRequiredFieldsLevel2() { ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct2.getId(), relation2.getName(), gene2.getCurie()); - Note editedNote = association.getRelatedNote(); + Note editedNote = association.getRelatedNotes().get(0); editedNote.setReferences(null); RestAssured.given(). @@ -484,8 +479,8 @@ public void editConstructGenomicEntityAssociationWithNullNonRequiredFieldsLevel2 get(constructGenomicEntityAssociationGetEndpoint + "?constructId=" + construct2.getId() + "&relationName=" + relation2.getName() + "&genomicEntityCurie=" + gene2.getCurie()). then(). statusCode(200). - body("entity", hasKey("relatedNote")). - body("entity.relatedNote", not(hasKey("references"))); + body("entity", hasKey("relatedNotes[0]")). + body("entity.relatedNotes[0]", not(hasKey("references"))); } @Test @@ -494,7 +489,7 @@ public void editConstructGenomicEntityAssociationWithNullNonRequiredFieldsLevel1 ConstructGenomicEntityAssociation association = getConstructGenomicEntityAssociation(construct2.getId(), relation2.getName(), gene2.getCurie()); association.setEvidence(null); - association.setRelatedNotes(List.of(null)); + association.setRelatedNotes(null); RestAssured.given(). contentType("application/json"). @@ -506,11 +501,10 @@ public void editConstructGenomicEntityAssociationWithNullNonRequiredFieldsLevel1 RestAssured.given(). when(). - get(constructGeneAssociationGetEndpoint + "?constructId=" + construct2.getId() + "&relationName=" + relation2.getName() + "&genomicEntityCurie=" + gene2.getCurie()). + get(constructGenomicEntityAssociationGetEndpoint + "?constructId=" + construct2.getId() + "&relationName=" + relation2.getName() + "&genomicEntityCurie=" + gene2.getCurie()). then(). statusCode(200). body("entity", not(hasKey("evidence"))). - body("entity", not(hasKey("evidenceCode"))). body("entity", not(hasKey("relatedNote"))); } } From 50fb4d9a9be591cba021d27a6e1b2676b02a15dc Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Fri, 13 Oct 2023 16:52:39 +0100 Subject: [PATCH 50/76] Give correct log message --- .../curation_api/jobs/executors/LoadFileExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java index 44f35eebb..2dc6276bd 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java @@ -181,7 +181,7 @@ public void runCleanup(DiseaseAnnotationService service, BulkLoadFileHistory his ph.startProcess("Deletion/deprecation of primary objects " + dataProviderName, curiesToRemove.size()); for (String curie : curiesToRemove) { try { - String loadDescription = dataProviderName + " association bulk load (" + md5sum + ")"; + String loadDescription = dataProviderName + " bulk load (" + md5sum + ")"; service.removeOrDeprecateNonUpdated(curie, loadDescription); history.incrementDeleted(); } catch (Exception e) { From b796d9d52ede8ef35454553f13c800486c6c7e50 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Thu, 12 Oct 2023 10:22:48 -0500 Subject: [PATCH 51/76] SCRUM-3353 make references a single table --- .../references/SingleReferenceFormEditor.js | 38 +++++++++++ .../references/SingleReferenceTableEditor.js | 25 ++++++++ .../Templates/CrossReferenceTemplate.js | 9 ++- .../Templates/ShortCitationTemplate.js | 26 ++++++++ .../allelesPage/AlleleDetailPage.js | 31 --------- .../referencesTable/ReferencesForm.js | 64 +++++++++++++++++-- .../referencesTable/ReferencesFormTable.js | 43 +++++++------ .../allelesPage/useAlleleReducer.js | 10 ++- .../src/containers/allelesPage/utils.js | 26 ++++++++ 9 files changed, 212 insertions(+), 60 deletions(-) create mode 100644 src/main/cliapp/src/components/Editors/references/SingleReferenceFormEditor.js create mode 100644 src/main/cliapp/src/components/Editors/references/SingleReferenceTableEditor.js create mode 100644 src/main/cliapp/src/components/Templates/ShortCitationTemplate.js create mode 100644 src/main/cliapp/src/containers/allelesPage/utils.js diff --git a/src/main/cliapp/src/components/Editors/references/SingleReferenceFormEditor.js b/src/main/cliapp/src/components/Editors/references/SingleReferenceFormEditor.js new file mode 100644 index 000000000..d3dd345ee --- /dev/null +++ b/src/main/cliapp/src/components/Editors/references/SingleReferenceFormEditor.js @@ -0,0 +1,38 @@ +import React from "react"; +import { AutocompleteFormEditor } from "../../Autocomplete/AutocompleteFormEditor"; +import { LiteratureAutocompleteTemplate } from "../../Autocomplete/LiteratureAutocompleteTemplate"; +import { FormErrorMessageComponent } from "../../Error/FormErrorMessageComponent"; +import { FormFieldWrapper } from "../../FormFieldWrapper"; +import { referenceSearch } from "./utils"; + +export const ReferencesFormEditor = ({ + onReferencesValueChange, + widgetColumnSize, + labelColumnSize, + fieldDetailsColumnSize, + errorMessages +}) => { + return ( + <> + + } + /> + } + errorField={} + additionalDataField={null} + /> + + ); +}; \ No newline at end of file diff --git a/src/main/cliapp/src/components/Editors/references/SingleReferenceTableEditor.js b/src/main/cliapp/src/components/Editors/references/SingleReferenceTableEditor.js new file mode 100644 index 000000000..abb0073f0 --- /dev/null +++ b/src/main/cliapp/src/components/Editors/references/SingleReferenceTableEditor.js @@ -0,0 +1,25 @@ +import React from "react"; +import { AutocompleteEditor } from "../../Autocomplete/AutocompleteEditor"; +import { LiteratureAutocompleteTemplate } from "../../Autocomplete/LiteratureAutocompleteTemplate"; +import { referenceSearch } from "./utils"; +import { DialogErrorMessageComponent } from "../../Error/DialogErrorMessageComponent"; + +export const SingleReferenceTableEditor = ({ props, errorMessages, onChange }) => { + return ( + <> + + } + onValueChangeHandler={onChange} + /> + + + ); +}; \ No newline at end of file diff --git a/src/main/cliapp/src/components/Templates/CrossReferenceTemplate.js b/src/main/cliapp/src/components/Templates/CrossReferenceTemplate.js index 80ce953c8..4586501be 100644 --- a/src/main/cliapp/src/components/Templates/CrossReferenceTemplate.js +++ b/src/main/cliapp/src/components/Templates/CrossReferenceTemplate.js @@ -5,15 +5,15 @@ export const CrossReferencesTemplate = ({ rowData }) => { const { crossReferences, curieField } = differentiateCrossReferences(rowData); - const sortedCrossReferences = crossReferences.sort((a, b) => (a[curieField] > b[curieField]) ? 1 : -1); + const sortedCrossReferences = crossReferences?.sort((a, b) => (a[curieField] > b[curieField]) ? 1 : -1); return (
    - {sortedCrossReferences.map((a, index) => + {sortedCrossReferences?.map((reference, index) =>
  • - {a[curieField]} + {reference[curieField]}
  • )} @@ -33,9 +33,8 @@ const differentiateCrossReferences = (reference) => { crossReferences = global.structuredClone(reference.crossReferences); curieField = "referencedCurie"; } else { - return; + return {}; } return {crossReferences, curieField}; - }; \ No newline at end of file diff --git a/src/main/cliapp/src/components/Templates/ShortCitationTemplate.js b/src/main/cliapp/src/components/Templates/ShortCitationTemplate.js new file mode 100644 index 000000000..20a1d4893 --- /dev/null +++ b/src/main/cliapp/src/components/Templates/ShortCitationTemplate.js @@ -0,0 +1,26 @@ +export const ShortCitationTemplate = ({ rowData }) => { + if (!rowData) return null; + + const shortCitation = differentiateShortCitation(rowData); + + + return ( +
    + {shortCitation} +
    + ); +}; + +const differentiateShortCitation = (reference) => { + let shortCitation; + + if (reference.short_citation) { + shortCitation = global.structuredClone(reference.short_citation); + } else if (reference.shortCitation) { + shortCitation = global.structuredClone(reference.shortCitation); + } else { + return {}; + } + + return shortCitation; +}; \ No newline at end of file diff --git a/src/main/cliapp/src/containers/allelesPage/AlleleDetailPage.js b/src/main/cliapp/src/containers/allelesPage/AlleleDetailPage.js index aff5d10cb..3face9746 100644 --- a/src/main/cliapp/src/containers/allelesPage/AlleleDetailPage.js +++ b/src/main/cliapp/src/containers/allelesPage/AlleleDetailPage.js @@ -8,7 +8,6 @@ import { AlleleService } from '../../service/AlleleService'; import ErrorBoundary from '../../components/Error/ErrorBoundary'; import { TaxonFormEditor } from '../../components/Editors/taxon/TaxonFormEditor'; import { useAlleleReducer } from './useAlleleReducer'; -import { ReferencesFormEditor } from '../../components/Editors/references/ReferencesFormEditor'; import { InCollectionFormEditor } from '../../components/Editors/inCollection/InCollectionFormEditor'; import { PageFooter } from './PageFooter'; import { BooleanFormEditor } from '../../components/Editors/boolean/BooleanFormEditor'; @@ -135,27 +134,6 @@ const { isLoading } = useQuery([curie], }) } - const onReferenceValueChange = (event) => { - if(event.value.length === 0){ - alleleDispatch({ - type: 'TOGGLE_TABLE', - entityType: 'references', - value: false, - }) - } else { - alleleDispatch({ - type: 'TOGGLE_TABLE', - entityType: 'references', - value: true, - })} - - alleleDispatch({ - type: 'EDIT', - field: 'references', - value: event.value, - }) - } - const onInCollectionValueChange = (event) => { let value = {}; if(typeof event.value === "object"){ @@ -312,15 +290,6 @@ const { isLoading } = useQuery([curie], - - { const tableRef = useRef(null); - const deletionHandler = (e, index) => { + // dispatch({type: 'EDIT', value: filterableReferences}); + + + + const createNewReferenceHandler = (e) => { + e.preventDefault(); + const dataKey = state.allele.references?.length; + //todo: add filter field in here + const newReference = { + dataKey: dataKey, + }; + + dispatch({ + type: "ADD_ROW", + row: newReference, + entityType: "references", + }); + }; + + + const referencesOnChangeHandler = (event, setFieldValue, props) => { + //updates value in table input box + setFieldValue(event.target.value); + //todo: add filter field in here + + if (typeof event.target.value === 'string') return; + const searchString = generateCrossRefSearchField(event.target.value); + + const newReference = { + ...event.target.value, + shortCitation: event.target.value.short_citation, + dataKey: props.rowIndex, + crossReferencesFilter: searchString + }; + console.log("in onChange", newReference); + + dispatch({ + type: 'REPLACE_ROW', + entityType: 'references', + index: props.rowIndex, + value: newReference + }); + }; + + const onRowEditChange = (e) => { + return null; + }; + + const deletionHandler = (e, index) => { e.preventDefault(); - dispatch({type: "DELETE_ROW", entityType: "references", index: index}); + dispatch({ type: "DELETE_ROW", entityType: "references", index: index }); + dispatch({ type: "UPDATE_TABLE_ERROR_MESSAGES", entityType: "references", errorMessages: [] }); }; return ( } tableName="" showTable={state.entityStates.references.show} - button={null} + button={ + + ); + } + } + }; + + const handleGenomicComponentsOpen = (event, rowData) => { + let _componentsData = {}; + _componentsData["originalComponents"] = rowData.constructGenomicEntityAssociations; + _componentsData["dialog"] = true; + setGenomicComponentsData(() => ({ + ..._componentsData + })); + }; + const columns = [ { field: "uniqueId", @@ -306,12 +358,19 @@ export const ConstructsTable = () => { body: secondaryIdsBodyTemplate }, { - field: "constructComponents.componentSymbol", - header: "Components", + field: "constructComponents.relation.name", + header: "Free Text Components", body: componentsTemplate, sortable: { isEnabled }, filterConfig: FILTER_CONFIGS.constructComponentsFilterConfig, }, + { + field: "constructGenomicEntityAssociations.relation.name", + header: "Component Associations", + body: genomicComponentsTemplate, + sortable: { isEnabled }, + filterConfig: FILTER_CONFIGS.constructGenomicComponentsFilterConfig, + }, { field: "references.primaryCrossReferenceCurie", header: "References", @@ -430,6 +489,12 @@ export const ConstructsTable = () => { errorMessagesMainRow={errorMessages} setErrorMessagesMainRow={setErrorMessages} /> + ); }; diff --git a/src/main/cliapp/src/containers/constructsPage/GenomicComponentsDialog.js b/src/main/cliapp/src/containers/constructsPage/GenomicComponentsDialog.js new file mode 100644 index 000000000..21fff1432 --- /dev/null +++ b/src/main/cliapp/src/containers/constructsPage/GenomicComponentsDialog.js @@ -0,0 +1,155 @@ +import React, { useRef, useState } from 'react'; +import { Dialog } from 'primereact/dialog'; +import { DataTable } from 'primereact/datatable'; +import { Column } from 'primereact/column'; +import { Tooltip } from 'primereact/tooltip'; +import { ColumnGroup } from 'primereact/columngroup'; +import { Row } from 'primereact/row'; +import { EllipsisTableCell } from '../../components/EllipsisTableCell'; +import { evidenceTemplate } from '../../components/EvidenceComponent'; +import { Button } from 'primereact/button'; +import { RelatedNotesDialog } from '../../components/RelatedNotesDialog'; + +export const GenomicComponentsDialog = ({ + originalComponentsData, + setOriginalComponentsData, + errorMessagesMainRow, + setErrorMessagesMainRow +}) => { + const { originalComponents, dialog } = originalComponentsData; + const [localComponents, setLocalComponents] = useState(null) ; + const tableRef = useRef(null); + + const [relatedNotesData, setRelatedNotesData] = useState({ + relatedNotes: [], + isInEdit: false, + dialog: false, + rowIndex: null, + mainRowProps: {}, + }); + + const showDialogHandler = () => { + let _localComponents = cloneComponents(originalComponents); + setLocalComponents(_localComponents); + }; + + const hideDialog = () => { + setOriginalComponentsData((originalComponentsData) => { + return { + ...originalComponentsData, + dialog: false, + }; + }); + let _localComponents = []; + setLocalComponents(_localComponents); + }; + + const cloneComponents = (clonableComponents) => { + let _clonableComponents = global.structuredClone(clonableComponents); + if(_clonableComponents) { + let counter = 0 ; + _clonableComponents.forEach((note) => { + note.dataKey = counter++; + }); + } else { + _clonableComponents = []; + }; + return _clonableComponents; + }; + + const internalTemplate = (rowData) => { + return {JSON.stringify(rowData.internal)}; + }; + + const obsoleteTemplate = (rowData) => { + return {JSON.stringify(rowData.obsolete)}; + }; + + const handleRelatedNotesOpen = (event, rowData, isInEdit) => { + let _relatedNotesData = {}; + _relatedNotesData["originalRelatedNotes"] = rowData.relatedNotes; + _relatedNotesData["dialog"] = true; + _relatedNotesData["isInEdit"] = isInEdit; + setRelatedNotesData(() => ({ + ..._relatedNotesData + })); + }; + + const relatedNotesTemplate = (rowData) => { + if (rowData?.relatedNotes) { + return ( + + ) + } + }; + + const componentTemplate = (rowData) => { + const componentDisplayValue = ""; + if (rowData.object.geneSymbol || rowData.object.alleleSymbol) { + let symbolValue = rowData.object.geneSymbol ? rowData.object.geneSymbol.displayText : rowData.object.alleleSymbol.displayText; + componentDisplayValue = symbolValue + ' (' + rowData.object.curie + ')'; + } else if (rowData.object.name) { + componentDisplayValue = rowData.object.name + ' (' + rowData.object.curie + ')'; + } else { + componentDisplayValue = rowData.object.curie; + } + return ( + <> +
    + +
    + + + ) + } + + let headerGroup = + + + + + + + + + + + + + ; + + return ( + <> +
    + +

    Component Associations

    + + + + + evidenceTemplate(rowData)}/> + + + + + + + +
    +
    + + + ); +}; diff --git a/src/main/cliapp/src/containers/dataLoadsPage/DataLoadsComponent.js b/src/main/cliapp/src/containers/dataLoadsPage/DataLoadsComponent.js index cdbaae24e..1412d8ddd 100644 --- a/src/main/cliapp/src/containers/dataLoadsPage/DataLoadsComponent.js +++ b/src/main/cliapp/src/containers/dataLoadsPage/DataLoadsComponent.js @@ -80,7 +80,8 @@ export const DataLoadsComponent = () => { ["AGM", ["AffectedGenomicModelDTO"]], ["VARIANT", ["VariantDTO"]], ["CONSTRUCT", ["ConstructDTO"]], - ["ALLELE_ASSOCIATION", ["AlleleGeneAssociationDTO"]] + ["ALLELE_ASSOCIATION", ["AlleleGeneAssociationDTO"]], + ["CONSTRUCT_ASSOCIATION", ["ConstructGenomiEntityAssociationDTO"]] ]); useQuery(['bulkloadtable'], diff --git a/src/main/cliapp/src/service/DataLoadService.js b/src/main/cliapp/src/service/DataLoadService.js index 442b25623..e70f77a08 100644 --- a/src/main/cliapp/src/service/DataLoadService.js +++ b/src/main/cliapp/src/service/DataLoadService.js @@ -72,7 +72,7 @@ export class DataLoadService extends BaseAuthService { const bulkLoadTypes = { BulkFMSLoad: ["MOLECULE", "ORTHOLOGY"], BulkURLLoad: ["ONTOLOGY", "GENE", "ALLELE", "AGM", "DISEASE_ANNOTATION", "RESOURCE_DESCRIPTOR"], - BulkManualLoad: ["FULL_INGEST", "DISEASE_ANNOTATION", "GENE_DISEASE_ANNOTATION", "ALLELE_DISEASE_ANNOTATION", "AGM_DISEASE_ANNOTATION", "GENE", "ALLELE", "AGM", "VARIANT", "CONSTRUCT", "ALLELE_ASSOCIATION"] + BulkManualLoad: ["FULL_INGEST", "DISEASE_ANNOTATION", "GENE_DISEASE_ANNOTATION", "ALLELE_DISEASE_ANNOTATION", "AGM_DISEASE_ANNOTATION", "GENE", "ALLELE", "AGM", "VARIANT", "CONSTRUCT", "ALLELE_ASSOCIATION", "CONSTRUCT_ASSOCIATION"] }; return bulkLoadTypes[loadType]; } From ec83a71c6005ad06dc568143be98aad6f8e9005c Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Mon, 16 Oct 2023 22:52:45 +0100 Subject: [PATCH 59/76] Fixes --- src/main/cliapp/src/constants/FilterFields.js | 4 +-- src/main/cliapp/src/constants/SortFields.js | 4 +-- .../constructsPage/ConstructsTable.js | 31 ++++++++++++++----- .../constructsPage/GenomicComponentsDialog.js | 6 ++-- .../constants/LinkMLSchemaConstants.java | 2 +- .../model/entities/Construct.java | 6 ++-- .../ConstructGenomicEntityAssociation.java | 2 +- .../model/ingest/dto/IngestDTO.java | 2 +- .../ConstructGenomicEntityAssociationDTO.java | 2 +- .../curation_api/services/AlleleService.java | 5 ++- ...structGenomicEntityAssociationService.java | 7 ++--- ...tGenomicEntityAssociationDTOValidator.java | 7 ++--- ...d_construct_genomic_entity_association.sql | 20 +++++++++++- 13 files changed, 63 insertions(+), 35 deletions(-) diff --git a/src/main/cliapp/src/constants/FilterFields.js b/src/main/cliapp/src/constants/FilterFields.js index dfee5cc1f..f90e5b9ef 100644 --- a/src/main/cliapp/src/constants/FilterFields.js +++ b/src/main/cliapp/src/constants/FilterFields.js @@ -142,11 +142,11 @@ export const FIELD_SETS = Object.freeze({ }, constructComponentsFieldSet: { filterName: "constructComponentsFilter", - fields: ["constructComponents.componentSymbol"], + fields: ["constructComponents.componentSymbol", "constructComponents.relation.name"], }, constructGenomicComponentsFieldSet: { filterName: "constructGenomicComponentsFilter", - fields: ["constructGenomicEntityAssociations.object.symbol", "constructGenomicEntityAssociations.object.name", "constructGenomicEntityAssociations.object.curie"], + fields: ["constructGenomicEntityAssociations.object.symbol", "constructGenomicEntityAssociations.object.name", "constructGenomicEntityAssociations.object.curie", "constructGenomicEntityAssociations.relation.name"], }, daConditionRelationsHandleFieldSet: { filterName: "daConditionRelationHandleFilter", diff --git a/src/main/cliapp/src/constants/SortFields.js b/src/main/cliapp/src/constants/SortFields.js index 5d76bf714..ddc7e0855 100644 --- a/src/main/cliapp/src/constants/SortFields.js +++ b/src/main/cliapp/src/constants/SortFields.js @@ -96,8 +96,8 @@ export const SORT_FIELDS = Object.freeze([ "synonyms.name", "secondaryIdentifiers", "taxonText", - "constructComponents.relation.name", - "constructGenomicEntityAssociations.relation.name", + "constructComponents.componentSymbol", + "constructGenomicEntityAssociations.object.symbol", "variantStatus.name", "variantType.name", "sourceGeneralConsequence.name" diff --git a/src/main/cliapp/src/containers/constructsPage/ConstructsTable.js b/src/main/cliapp/src/containers/constructsPage/ConstructsTable.js index 9182b4a1a..56bd100e8 100644 --- a/src/main/cliapp/src/containers/constructsPage/ConstructsTable.js +++ b/src/main/cliapp/src/containers/constructsPage/ConstructsTable.js @@ -4,6 +4,7 @@ import { EllipsisTableCell } from '../../components/EllipsisTableCell'; import { ListTableCell } from '../../components/ListTableCell'; import { internalTemplate, obsoleteTemplate } from '../../components/AuditedObjectComponent'; import { ComponentsDialog } from './ComponentsDialog'; +import { GenomicComponentsDialog } from './GenomicComponentsDialog'; import { SymbolDialog } from '../nameSlotAnnotations/dialogs/SymbolDialog'; import { FullNameDialog } from '../nameSlotAnnotations/dialogs/FullNameDialog'; import { SynonymsDialog } from '../nameSlotAnnotations/dialogs/SynonymsDialog'; @@ -228,7 +229,14 @@ export const ConstructsTable = () => { const componentSet = new Set(); for(var i = 0; i < rowData.constructComponents.length; i++){ if (rowData.constructComponents[i].componentSymbol && rowData.constructComponents[i].relation) { - componentSet.add(rowData.constructComponents[i].relation?.name + ': ' + rowData.constructComponents[i].componentSymbol); + let relationName = ""; + if (rowData.constructComponents[i]?.relation?.name) { + relationName = rowData.constructComponents[i].relation.name; + if (relationName.indexOf(' (RO:') !== -1) { + relationName = relationName.substring(0, relationName.indexOf(' (RO:')) + } + } + componentSet.add(relationName + ': ' + rowData.constructComponents[i].componentSymbol); } } if (componentSet.size > 0) { @@ -265,7 +273,7 @@ export const ConstructsTable = () => { if (rowData?.constructGenomicEntityAssociations) { const componentSet = new Set(); for(var i = 0; i < rowData.constructGenomicEntityAssociations.length; i++){ - const symbolValue = ""; + let symbolValue = ""; if (rowData.constructGenomicEntityAssociations[i]?.object.geneSymbol || rowData.constructGenomicEntityAssociations[i]?.object.alleleSymbol) { symbolValue = rowData.constructGenomicEntityAssociations[i].object.geneSymbol ? rowData.constructGenomicEntityAssociations[i].object.geneSymbol.displayText : rowData.constructGenomicEntityAssociations[i].object.alleleSymbol.displayText; } else if (rowData.constructGenomicEntityAssociations[i]?.object.name) { @@ -273,7 +281,14 @@ export const ConstructsTable = () => { } else { symbolValue = rowData.constructGenomicEntityAssociations[i].object.curie; } - componentSet.add(rowData.constructGenomicEntityAssociations[i]?.relation?.name + ': ' + symbolValue); + let relationName = ""; + if (rowData.constructGenomicEntityAssociations[i]?.relation?.name) { + relationName = rowData.constructGenomicEntityAssociations[i].relation.name; + if (relationName.indexOf(' (RO:') !== -1) { + relationName = relationName.substring(0, relationName.indexOf(' (RO:')) + } + } + componentSet.add(relationName + ': ' + symbolValue); } if (componentSet.size > 0) { const sortedComponents = Array.from(componentSet).sort(); @@ -287,7 +302,7 @@ export const ConstructsTable = () => { return ( <> @@ -358,14 +373,14 @@ export const ConstructsTable = () => { body: secondaryIdsBodyTemplate }, { - field: "constructComponents.relation.name", + field: "constructComponents.componentSymbol", header: "Free Text Components", body: componentsTemplate, sortable: { isEnabled }, filterConfig: FILTER_CONFIGS.constructComponentsFilterConfig, }, { - field: "constructGenomicEntityAssociations.relation.name", + field: "constructGenomicEntityAssociations.object.symbol", header: "Component Associations", body: genomicComponentsTemplate, sortable: { isEnabled }, @@ -490,8 +505,8 @@ export const ConstructsTable = () => { setErrorMessagesMainRow={setErrorMessages} /> diff --git a/src/main/cliapp/src/containers/constructsPage/GenomicComponentsDialog.js b/src/main/cliapp/src/containers/constructsPage/GenomicComponentsDialog.js index 21fff1432..33527d5bb 100644 --- a/src/main/cliapp/src/containers/constructsPage/GenomicComponentsDialog.js +++ b/src/main/cliapp/src/containers/constructsPage/GenomicComponentsDialog.js @@ -89,7 +89,7 @@ export const GenomicComponentsDialog = ({ }; const componentTemplate = (rowData) => { - const componentDisplayValue = ""; + let componentDisplayValue = ""; if (rowData.object.geneSymbol || rowData.object.alleleSymbol) { let symbolValue = rowData.object.geneSymbol ? rowData.object.geneSymbol.displayText : rowData.object.alleleSymbol.displayText; componentDisplayValue = symbolValue + ' (' + rowData.object.curie + ')'; @@ -113,11 +113,11 @@ export const GenomicComponentsDialog = ({ + - @@ -131,7 +131,7 @@ export const GenomicComponentsDialog = ({ - + evidenceTemplate(rowData)}/> diff --git a/src/main/java/org/alliancegenome/curation_api/constants/LinkMLSchemaConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/LinkMLSchemaConstants.java index 871c0d25f..5fcbbcfe5 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/LinkMLSchemaConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/LinkMLSchemaConstants.java @@ -2,7 +2,7 @@ public final class LinkMLSchemaConstants { - public static final String LATEST_RELEASE = "1.10.0"; + public static final String LATEST_RELEASE = "1.11.0"; public static final String MIN_ONTOLOGY_RELEASE = "1.2.4"; public static final String MAX_ONTOLOGY_RELEASE = LATEST_RELEASE; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Construct.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Construct.java index 90f9ab8a3..9e15faa3f 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Construct.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Construct.java @@ -74,14 +74,14 @@ public class Construct extends Reagent { }) private List references; - @IndexedEmbedded(includePaths = { "componentSymbol", "taxon.curie", "taxonText", "componentSymbol_keyword", "taxon.curie_keyword", "taxonText_keyword"}) + @IndexedEmbedded(includePaths = { "relation.name", "relation.name_keyword", "componentSymbol", "taxon.curie", "taxonText", "componentSymbol_keyword", "taxon.curie_keyword", "taxonText_keyword"}) @OneToMany(mappedBy = "singleConstruct", cascade = CascadeType.ALL) @JsonManagedReference @JsonView({ View.FieldsAndLists.class, View.ConstructView.class }) private List constructComponents; - @IndexedEmbedded(includePaths = {"object.curie", "object.name", "object.symbol", - "object.curie_keyword", "object.name_keyword", "object.symbol_keyword"}) + @IndexedEmbedded(includePaths = {"object.curie", "object.name", "object.symbol", "relation.name", + "object.curie_keyword", "object.name_keyword", "object.symbol_keyword", "relation.name_keyword"}) @OneToMany(mappedBy = "subject", cascade = CascadeType.ALL) @JsonView({ View.FieldsAndLists.class, View.ConstructView.class }) private List constructGenomicEntityAssociations; 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 ae3df1e38..7b40afe00 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 @@ -38,7 +38,7 @@ @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @ToString(callSuper = true) -@AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociation.class }) +@AGRCurationSchemaVersion(min = "1.11.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociation.class }) @Schema(name = "ConstructGenomicEntityAssociation", description = "POJO representing an association between a construct and a genomic entity") @Table(indexes = { @Index(name = "constructgenomicentityassociation_subject_index", columnList = "subject_id"), diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/IngestDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/IngestDTO.java index 2c2407c1e..87d682ae1 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/IngestDTO.java +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/IngestDTO.java @@ -61,7 +61,7 @@ public class IngestDTO { private List alleleGeneAssociationIngestSet; @JsonView({ View.FieldsAndLists.class }) - @JsonProperty("cosntruct_genomic_entity_association_ingest_set") + @JsonProperty("construct_genomic_entity_association_ingest_set") private List constructGenomicEntityAssociationIngestSet; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTO.java index 47ba3a4e7..a9bc8bcea 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTO.java +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTO.java @@ -16,7 +16,7 @@ @Setter @Getter -@AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociationDTO.class, NoteDTO.class }) +@AGRCurationSchemaVersion(min = "1.11.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociationDTO.class, NoteDTO.class }) public class ConstructGenomicEntityAssociationDTO extends EvidenceAssociationDTO { @JsonView({ View.FieldsOnly.class }) diff --git a/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java b/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java index c8c487cde..2885f8b2d 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java @@ -50,7 +50,6 @@ public class AlleleService extends BaseDTOCrudService notesToDelete = allele.getRelatedNotes(); - alleleDAO.remove(curie); if (CollectionUtils.isNotEmpty(notesToDelete)) - notesToDelete.forEach(note -> noteService.delete(note.getId())); + notesToDelete.forEach(note -> alleleDAO.deleteAttachedNote(note.getId())); + alleleDAO.remove(curie); } } else { log.error("Failed getting allele: " + curie); diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java index 82385ee23..98c19a46a 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java @@ -50,8 +50,6 @@ public class ConstructGenomicEntityAssociationService extends BaseAssociationDTO @Inject ConstructDAO constructDAO; @Inject - NoteService noteService; - @Inject GenomicEntityDAO genomicEntityDAO; @Inject PersonService personService; @@ -129,9 +127,10 @@ public ConstructGenomicEntityAssociation deprecateOrDeleteAssociation(Long id, B } List notesToDelete = association.getRelatedNotes(); - constructGenomicEntityAssociationDAO.remove(association.getId()); if (CollectionUtils.isNotEmpty(notesToDelete)) - notesToDelete.forEach(note -> noteService.delete(note.getId())); + notesToDelete.forEach(note -> constructGenomicEntityAssociationDAO.deleteAttachedNote(note.getId())); + constructGenomicEntityAssociationDAO.remove(association.getId()); + return null; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTOValidator.java index 322671922..9036063a4 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTOValidator.java @@ -33,8 +33,6 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import lombok.extern.jbosslog.JBossLog; -@JBossLog @RequestScoped public class ConstructGenomicEntityAssociationDTOValidator extends EvidenceAssociationDTOValidator { @@ -135,10 +133,9 @@ public ConstructGenomicEntityAssociation validateConstructGenomicEntityAssociati association.setRelatedNotes(null); } - if (assocResponse.hasErrors()) { - log.info(assocResponse.errorMessagesString()); + if (assocResponse.hasErrors()) throw new ObjectValidationException(dto, assocResponse.errorMessagesString()); - } + association = constructGenomicEntityAssociationDAO.persist(association); return association; diff --git a/src/main/resources/db/migration/v0.27.0.8__add_construct_genomic_entity_association.sql b/src/main/resources/db/migration/v0.27.0.8__add_construct_genomic_entity_association.sql index 9d31867d6..f824d8469 100644 --- a/src/main/resources/db/migration/v0.27.0.8__add_construct_genomic_entity_association.sql +++ b/src/main/resources/db/migration/v0.27.0.8__add_construct_genomic_entity_association.sql @@ -45,4 +45,22 @@ CREATE TABLE constructgenomicentityassociation_note_aud ( ALTER TABLE constructgenomicentityassociation_note_aud ADD PRIMARY KEY (constructgenomicentityassociation_id, relatednotes_id, rev); -ALTER TABLE constructgenomicentityassociation_note_aud ADD CONSTRAINT constructgenomicentityassociation_note_aud_rev_fk FOREIGN KEY (rev) REFERENCES revinfo (rev); \ No newline at end of file +ALTER TABLE constructgenomicentityassociation_note_aud ADD CONSTRAINT constructgenomicentityassociation_note_aud_rev_fk FOREIGN KEY (rev) REFERENCES revinfo (rev); + +CREATE TABLE tmp_vocab_link ( + vocabularytermsets_id bigint, + memberterms_id bigint); + +INSERT INTO tmp_vocab_link (memberterms_id) + SELECT id FROM vocabularyterm WHERE vocabulary_id = ( + SELECT id from vocabulary where vocabularylabel = 'construct_relation' + ); + +UPDATE tmp_vocab_link SET vocabularytermsets_id = subquery.id + FROM (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'construct_genomic_entity_relation') AS subquery + WHERE vocabularytermsets_id IS NULL; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) + SELECT vocabularytermsets_id, memberterms_id FROM tmp_vocab_link; + +DROP TABLE tmp_vocab_link; \ No newline at end of file From 00d1dd1ea863dc5cbb545e825122bed9bfa1f3bf Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Mon, 16 Oct 2023 23:36:37 +0100 Subject: [PATCH 60/76] Fix UI tests and add association test --- .../__tests__/ConstructsTable.test.js | 2 + .../constructsPage/mockData/mockData.js | 593 +++++++++++++++++- 2 files changed, 594 insertions(+), 1 deletion(-) diff --git a/src/main/cliapp/src/containers/constructsPage/__tests__/ConstructsTable.test.js b/src/main/cliapp/src/containers/constructsPage/__tests__/ConstructsTable.test.js index 17f285391..36c781d92 100644 --- a/src/main/cliapp/src/containers/constructsPage/__tests__/ConstructsTable.test.js +++ b/src/main/cliapp/src/containers/constructsPage/__tests__/ConstructsTable.test.js @@ -44,6 +44,7 @@ describe("", () => { const symbolTd = await result.findByText(/KP273/); const nameTd = await result.findByText(/King Potato 273/); const synonymTd = await result.findByText(/KPot273/); + const constructGenomicComponentTd = await result.findByText(/lin-17/i); await waitFor(() => { expect(modEntityTd).toBeInTheDocument(); @@ -55,6 +56,7 @@ describe("", () => { expect(dateUpdatedTd).toBeInTheDocument(); expect(dateCreatedTd).toBeInTheDocument(); expect(constructComponentTd).toBeInTheDocument(); + expect(constructGenomicComponentTd).toBeInTheDocument(); }); }); }); \ No newline at end of file diff --git a/src/main/cliapp/src/containers/constructsPage/mockData/mockData.js b/src/main/cliapp/src/containers/constructsPage/mockData/mockData.js index 9ef62fd1f..086c0cd94 100644 --- a/src/main/cliapp/src/containers/constructsPage/mockData/mockData.js +++ b/src/main/cliapp/src/containers/constructsPage/mockData/mockData.js @@ -178,7 +178,74 @@ export const data = { "name": "construct_component_note" } } - ] + ], + "relation": { + "createdBy": { + "dateCreated": "2022-05-03T18:33:16.445309Z", + "dateUpdated": "2022-05-03T18:33:16.445322Z", + "internal": false, + "obsolete": false, + "dbDateUpdated": "2023-05-17T12:55:33.687817Z", + "id": 7685810, + "uniqueId": "Chris|Grove|chris@wormbase.org", + "firstName": "Chris", + "lastName": "Grove", + "allianceMember": { + "internal": false, + "obsolete": false, + "id": 20308683, + "uniqueId": "WB", + "abbreviation": "WB", + "fullName": "WormBase", + "homepageResourceDescriptorPage": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-02-20T09:26:39.609757Z", + "dbDateUpdated": "2023-08-27T22:00:03.833696Z", + "id": 41750788, + "name": "homepage", + "urlTemplate": "https://www.wormbase.org/" + } + } + }, + "updatedBy": { + "dateCreated": "2022-05-03T18:33:16.445309Z", + "dateUpdated": "2022-05-03T18:33:16.445322Z", + "internal": false, + "obsolete": false, + "dbDateUpdated": "2023-05-17T12:55:33.687817Z", + "id": 7685810, + "uniqueId": "Chris|Grove|chris@wormbase.org", + "firstName": "Chris", + "lastName": "Grove", + "allianceMember": { + "internal": false, + "obsolete": false, + "id": 20308683, + "uniqueId": "WB", + "abbreviation": "WB", + "fullName": "WormBase", + "homepageResourceDescriptorPage": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-02-20T09:26:39.609757Z", + "dbDateUpdated": "2023-08-27T22:00:03.833696Z", + "id": 41750788, + "name": "homepage", + "urlTemplate": "https://www.wormbase.org/" + } + } + }, + "dateCreated": "2023-07-30T10:53:52.886357Z", + "dateUpdated": "2023-07-30T10:53:52.904425Z", + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-07-30T10:53:52.916444Z", + "dbDateUpdated": "2023-07-30T10:53:52.916445Z", + "id": 105723958, + "name": "is_regulated_by (RO:0002334)", + "definition": "Indicates that the construct is regulated by the indicated GenomicEntity" + } } ], "constructSymbol": { @@ -224,6 +291,530 @@ export const data = { "formatText": "KPot273", "displayText": "KPot273" } + ], + "constructGenomicEntityAssociations": [ + { + "internal": false, + "obsolete": false, + "id": 135641224, + "subject": { + "createdBy": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2022-09-08T13:13:22.467843+01:00", + "dbDateUpdated": "2022-09-08T13:13:22.467853+01:00", + "id": 10975049, + "uniqueId": "WB:curator" + }, + "updatedBy": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2022-09-08T13:13:22.467843+01:00", + "dbDateUpdated": "2022-09-08T13:13:22.467853+01:00", + "id": 10975049, + "uniqueId": "WB:curator" + }, + "dateCreated": "2010-01-02T00:00:00Z", + "dateUpdated": "2012-08-03T01:00:00+01:00", + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-21T17:51:29.459381+01:00", + "dbDateUpdated": "2023-09-21T22:32:31.311836+01:00", + "id": 133503943, + "uniqueId": "WBCnstr00000001", + "modEntityId": "WB:WBCnstr00000001", + "dataProvider": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-21T17:51:29.404006+01:00", + "dbDateUpdated": "2023-09-21T22:32:31.318449+01:00", + "id": 133503942, + "sourceOrganization": { + "internal": false, + "obsolete": false, + "id": 20308683, + "uniqueId": "WB", + "abbreviation": "WB", + "fullName": "WormBase", + "homepageResourceDescriptorPage": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-02-20T09:26:39.609757Z", + "dbDateUpdated": "2023-08-27T22:00:03.833696+01:00", + "id": 41750788, + "name": "homepage", + "urlTemplate": "https://www.wormbase.org/" + } + }, + "crossReference": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-21T17:51:29.385011+01:00", + "dbDateUpdated": "2023-09-21T22:32:31.316107+01:00", + "id": 133503941, + "referencedCurie": "WB:WBCnstr00000001", + "displayName": "WBCnstr00000001", + "resourceDescriptorPage": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-02-20T09:26:39.612125Z", + "dbDateUpdated": "2023-08-27T22:00:03.835967+01:00", + "id": 41750793, + "name": "construct", + "urlTemplate": "https://www.wormbase.org/db/get?name=[%s];class=Construct" + } + } + }, + "references": [ + { + "internal": false, + "obsolete": false, + "dbDateCreated": "2022-11-16T19:20:52.352997Z", + "dbDateUpdated": "2022-11-16T19:20:52.352997Z", + "curie": "AGRKB:101000000622406", + "crossReferences": [ + { + "internal": false, + "obsolete": false, + "id": 74148673, + "referencedCurie": "DOI:10.1038/nbt1305", + "displayName": "DOI:10.1038/nbt1305" + }, + { + "internal": false, + "obsolete": false, + "id": 73235497, + "referencedCurie": "WB:WBPaper00029359", + "displayName": "WB:WBPaper00029359" + }, + { + "internal": false, + "obsolete": false, + "id": 74148674, + "referencedCurie": "PMID:17486083", + "displayName": "PMID:17486083" + } + ] + } + ], + "constructComponents": [ + { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-21T22:32:31.43525+01:00", + "dbDateUpdated": "2023-09-21T22:32:31.435267+01:00", + "id": 133891213, + "evidence": [ + { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-21T17:58:44.347804+01:00", + "dbDateUpdated": "2023-09-21T17:58:44.347819+01:00", + "curie": "AGRKB:101000000628628", + "crossReferences": [ + { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-21T17:58:44.327516+01:00", + "dbDateUpdated": "2023-09-21T17:58:44.327526+01:00", + "id": 133530293, + "referencedCurie": "DOI:10.1093/glycob/cwt051", + "displayName": "DOI:10.1093/glycob/cwt051" + }, + { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-21T17:58:44.334878+01:00", + "dbDateUpdated": "2023-09-21T17:58:44.334886+01:00", + "id": 133530294, + "referencedCurie": "PMCID:PMC3766279", + "displayName": "PMCID:PMC3766279" + }, + { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-21T17:58:44.341117+01:00", + "dbDateUpdated": "2023-09-21T17:58:44.341125+01:00", + "id": 133530295, + "referencedCurie": "PMID:23836288", + "displayName": "PMID:23836288" + }, + { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-21T17:58:44.346638+01:00", + "dbDateUpdated": "2023-09-21T17:58:44.346645+01:00", + "id": 133530296, + "referencedCurie": "WB:WBPaper00042571", + "displayName": "WB:WBPaper00042571" + } + ], + "shortCitation": " (2013) Glycobiology 23(10):1142-51" + } + ], + "componentSymbol": "egl19", + "taxon": { + "internal": false, + "obsolete": false, + "curie": "NCBITaxon:6239", + "name": "Caenorhabditis elegans" + }, + "taxonText": "Caenorhabditis elegans", + "relatedNotes": [ + { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-21T22:32:31.413938+01:00", + "dbDateUpdated": "2023-09-21T22:32:31.41395+01:00", + "id": 133891212, + "freeText": "egl-19 test note", + "noteType": { + "internal": false, + "obsolete": false, + "id": 133503921, + "name": "construct_component_note" + } + } + ], + "relation": { + "createdBy": { + "dateCreated": "2022-05-03T18:33:16.445309Z", + "dateUpdated": "2022-05-03T18:33:16.445322Z", + "internal": false, + "obsolete": false, + "dbDateUpdated": "2023-05-17T12:55:33.687817Z", + "id": 7685810, + "uniqueId": "Chris|Grove|chris@wormbase.org", + "firstName": "Chris", + "lastName": "Grove", + "allianceMember": { + "internal": false, + "obsolete": false, + "id": 20308683, + "uniqueId": "WB", + "abbreviation": "WB", + "fullName": "WormBase", + "homepageResourceDescriptorPage": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-02-20T09:26:39.609757Z", + "dbDateUpdated": "2023-08-27T22:00:03.833696Z", + "id": 41750788, + "name": "homepage", + "urlTemplate": "https://www.wormbase.org/" + } + } + }, + "updatedBy": { + "dateCreated": "2022-05-03T18:33:16.445309Z", + "dateUpdated": "2022-05-03T18:33:16.445322Z", + "internal": false, + "obsolete": false, + "dbDateUpdated": "2023-05-17T12:55:33.687817Z", + "id": 7685810, + "uniqueId": "Chris|Grove|chris@wormbase.org", + "firstName": "Chris", + "lastName": "Grove", + "allianceMember": { + "internal": false, + "obsolete": false, + "id": 20308683, + "uniqueId": "WB", + "abbreviation": "WB", + "fullName": "WormBase", + "homepageResourceDescriptorPage": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-02-20T09:26:39.609757Z", + "dbDateUpdated": "2023-08-27T22:00:03.833696Z", + "id": 41750788, + "name": "homepage", + "urlTemplate": "https://www.wormbase.org/" + } + } + }, + "dateCreated": "2023-07-30T10:53:52.886357Z", + "dateUpdated": "2023-07-30T10:53:52.904425Z", + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-07-30T10:53:52.916444Z", + "dbDateUpdated": "2023-07-30T10:53:52.916445Z", + "id": 105723958, + "name": "is_regulated_by (RO:0002334)", + "definition": "Indicates that the construct is regulated by the indicated GenomicEntity" + } + } + ], + "constructSymbol": { + "internal": false, + "obsolete": false, + "id": 134095430, + "nameType": { + "internal": false, + "obsolete": false, + "id": 20308690, + "name": "nomenclature_symbol", + "definition": "A symbol for an object: e.g., pax6Leca2." + }, + "formatText": "KP273", + "displayText": "KP273" + }, + "constructFullName": { + "internal": false, + "obsolete": false, + "id": 13423325252, + "nameType": { + "internal": false, + "obsolete": false, + "id": 20308691, + "name": "full_name", + "definition": "The full length name of an entity: e.g., broad angular dumpy." + }, + "formatText": "King Potato 273", + "displayText": "King Potato 273" + }, + "constructSynonyms": [ + { + "internal": false, + "obsolete": false, + "id": 134024230, + "nameType": { + "internal": false, + "obsolete": false, + "id": 20308692, + "name": "systematic_name", + "definition": "A systematic name: e.g., CG48891." + }, + "formatText": "KPot273", + "displayText": "KPot273" + } + ] + }, + "relation": { + "createdBy": { + "dateCreated": "2022-05-03T18:33:16.445309+01:00", + "dateUpdated": "2022-05-03T18:33:16.445322+01:00", + "internal": false, + "obsolete": false, + "dbDateUpdated": "2023-05-17T12:55:33.687817+01:00", + "id": 7685810, + "uniqueId": "Chris|Grove|chris@wormbase.org", + "firstName": "Chris", + "lastName": "Grove", + "allianceMember": { + "internal": false, + "obsolete": false, + "id": 20308683, + "uniqueId": "WB", + "abbreviation": "WB", + "fullName": "WormBase", + "homepageResourceDescriptorPage": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-02-20T09:26:39.609757Z", + "dbDateUpdated": "2023-08-27T22:00:03.833696+01:00", + "id": 41750788, + "name": "homepage", + "urlTemplate": "https://www.wormbase.org/" + } + } + }, + "updatedBy": { + "dateCreated": "2022-05-03T18:33:16.445309+01:00", + "dateUpdated": "2022-05-03T18:33:16.445322+01:00", + "internal": false, + "obsolete": false, + "dbDateUpdated": "2023-05-17T12:55:33.687817+01:00", + "id": 7685810, + "uniqueId": "Chris|Grove|chris@wormbase.org", + "firstName": "Chris", + "lastName": "Grove", + "allianceMember": { + "internal": false, + "obsolete": false, + "id": 20308683, + "uniqueId": "WB", + "abbreviation": "WB", + "fullName": "WormBase", + "homepageResourceDescriptorPage": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-02-20T09:26:39.609757Z", + "dbDateUpdated": "2023-08-27T22:00:03.833696+01:00", + "id": 41750788, + "name": "homepage", + "urlTemplate": "https://www.wormbase.org/" + } + } + }, + "dateCreated": "2023-07-30T10:53:26.803825+01:00", + "dateUpdated": "2023-07-30T10:53:26.811841+01:00", + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-07-30T10:53:26.819368+01:00", + "dbDateUpdated": "2023-07-30T10:53:26.819369+01:00", + "id": 105723956, + "name": "expresses (RO:0002292)", + "definition": "Indicates that the construct expresses the indicated GenomicEntity" + }, + "object": { + "type": "Gene", + "createdBy": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2022-09-08T13:13:22.467843+01:00", + "dbDateUpdated": "2022-09-08T13:13:22.467853+01:00", + "id": 10975049, + "uniqueId": "WB:curator" + }, + "updatedBy": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2022-09-08T13:13:22.467843+01:00", + "dbDateUpdated": "2022-09-08T13:13:22.467853+01:00", + "id": 10975049, + "uniqueId": "WB:curator" + }, + "internal": false, + "obsolete": false, + "dbDateUpdated": "2023-10-12T22:30:58.367879+01:00", + "curie": "WB:WBGene00003006", + "taxon": { + "internal": false, + "obsolete": false, + "curie": "NCBITaxon:6239", + "name": "Caenorhabditis elegans" + }, + "dataProvider": { + "internal": false, + "obsolete": false, + "dbDateUpdated": "2023-10-12T22:30:58.367101+01:00", + "id": 75346028, + "sourceOrganization": { + "internal": false, + "obsolete": false, + "id": 20308683, + "uniqueId": "WB", + "abbreviation": "WB", + "fullName": "WormBase", + "homepageResourceDescriptorPage": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-02-20T09:26:39.609757Z", + "dbDateUpdated": "2023-08-27T22:00:03.833696+01:00", + "id": 41750788, + "name": "homepage", + "urlTemplate": "https://www.wormbase.org/" + } + }, + "crossReference": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-06-06T19:44:24.155299+01:00", + "dbDateUpdated": "2023-06-06T19:44:24.1553+01:00", + "id": 86350879, + "referencedCurie": "WB:WBGene00003006", + "displayName": "WBGene00003006", + "resourceDescriptorPage": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-02-20T09:26:39.602562Z", + "dbDateUpdated": "2023-08-27T22:00:03.827167+01:00", + "id": 41750773, + "name": "gene", + "urlTemplate": "https://www.wormbase.org/db/get?name=[%s];class=Gene" + } + } + }, + "geneType": { + "internal": false, + "obsolete": false, + "dbDateUpdated": "2023-02-19T22:00:41.015903Z", + "curie": "SO:0001217", + "name": "protein_coding_gene", + "namespace": "sequence", + "definition": "A gene that codes for an RNA that can be translated into a protein.", + "subsets": [ + "Alliance_of_Genome_Resources" + ], + "synonyms": [ + { + "internal": false, + "obsolete": false, + "id": 12304001, + "name": "protein coding gene" + } + ] + }, + "geneSymbol": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-01-31T00:25:55.907119Z", + "dbDateUpdated": "2023-10-12T22:30:58.36953+01:00", + "id": 27221468, + "nameType": { + "internal": false, + "obsolete": false, + "id": 20308690, + "name": "nomenclature_symbol", + "definition": "A symbol for an object: e.g., pax6Leca2." + }, + "formatText": "lin-17", + "displayText": "lin-17" + }, + "geneFullName": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-01-31T00:25:55.907825Z", + "dbDateUpdated": "2023-10-12T22:30:58.368456+01:00", + "id": 27221469, + "nameType": { + "internal": false, + "obsolete": false, + "id": 20308691, + "name": "full_name", + "definition": "The full length name of an entity: e.g., broad angular dumpy." + }, + "formatText": "abnormal cell LINeage 17", + "displayText": "abnormal cell LINeage 17" + }, + "geneSystematicName": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-01-31T00:25:55.9083Z", + "dbDateUpdated": "2023-10-12T22:30:58.371706+01:00", + "id": 27221470, + "nameType": { + "internal": false, + "obsolete": false, + "id": 20308692, + "name": "systematic_name", + "definition": "A systematic name: e.g., CG48891." + }, + "formatText": "Y71F9B.5", + "displayText": "Y71F9B.5" + }, + "geneSynonyms": [ + { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-01-31T00:25:55.908787Z", + "dbDateUpdated": "2023-10-12T22:30:58.37056+01:00", + "id": 27221471, + "nameType": { + "internal": false, + "obsolete": false, + "id": 20308697, + "name": "unspecified", + "definition": "Unclassified name" + }, + "formatText": "CELE_Y71F9B.5", + "displayText": "CELE_Y71F9B.5" + } + ] + } + + } ] } ], From 7053c158d0141b5c261f8aabc2a048827f7e0001 Mon Sep 17 00:00:00 2001 From: markquintontulloch Date: Mon, 16 Oct 2023 23:52:08 +0100 Subject: [PATCH 61/76] Add basic variant table UI tests --- .../__tests__/VariantsTable.test.js | 60 ++++ .../variantsPage/mockData/mockData.js | 272 ++++++++++++++++++ 2 files changed, 332 insertions(+) create mode 100644 src/main/cliapp/src/containers/variantsPage/__tests__/VariantsTable.test.js create mode 100644 src/main/cliapp/src/containers/variantsPage/mockData/mockData.js diff --git a/src/main/cliapp/src/containers/variantsPage/__tests__/VariantsTable.test.js b/src/main/cliapp/src/containers/variantsPage/__tests__/VariantsTable.test.js new file mode 100644 index 000000000..2fe01e339 --- /dev/null +++ b/src/main/cliapp/src/containers/variantsPage/__tests__/VariantsTable.test.js @@ -0,0 +1,60 @@ +import React from "react"; +import { BrowserRouter } from "react-router-dom/cjs/react-router-dom"; +import { waitFor } from "@testing-library/react"; +import { renderWithClient } from '../../../tools/jest/utils'; +import { VariantsTable } from "../VariantsTable"; +import { setLocalStorage } from "../../../tools/jest/setupTests"; +import { setupSettingsHandler, setupFindHandler, setupSearchHandler, setupSaveSettingsHandler } from "../../../tools/jest/commonMswhandlers"; +import { data } from "../mockData/mockData.js"; +import 'core-js/features/structured-clone'; + +describe("", () => { + beforeEach(() => { + setupFindHandler(); + setupSettingsHandler(); + setupSaveSettingsHandler(); + setupSearchHandler(data); + }); + + it("Renders without crashing", async () => { + let result = await renderWithClient(); + + await waitFor(() => { + expect(result); + }); + + }); + + it("Contains Correct Table Name", async () => { + let result = await renderWithClient(); + + const tableTitle = await result.findByText(/Variants Table/i); + expect(tableTitle).toBeInTheDocument(); + }); + + it("Contains Correct Table Data", async () => { + let result = await renderWithClient(); + + const curieTd = await result.findByText(/WB:WBVarTest0002/i); + const taxonTd = await result.findByText(/Caenorhabditis elegans/i); + const updatedByTd = await result.findByText(/VARIANTTEST:Person0002/i); + const createdByTd = await result.findByText(/VARIANTTEST:Person0001/i); + const dateUpdatedTd = await result.findByText(/2022-03-10T22:10:12Z/i); + const dateCreatedTd = await result.findByText(/2022-03-09T22:10:12Z/i); + const variantTypeTd = await result.findByText(/SNP/i); + const variantStatusTd = await result.findByText(/dead/i); + const sourceGeneralConsequenceTd = await result.findByText(/point_mutation/i); + + await waitFor(() => { + expect(curieTd).toBeInTheDocument(); + expect(taxonTd).toBeInTheDocument(); + expect(dateUpdatedTd).toBeInTheDocument(); + expect(dateCreatedTd).toBeInTheDocument(); + expect(updatedByTd).toBeInTheDocument(); + expect(createdByTd).toBeInTheDocument(); + expect(variantTypeTd).toBeInTheDocument(); + expect(variantStatusTd).toBeInTheDocument(); + expect(sourceGeneralConsequenceTd).toBeInTheDocument(); + }); + }); +}); \ No newline at end of file diff --git a/src/main/cliapp/src/containers/variantsPage/mockData/mockData.js b/src/main/cliapp/src/containers/variantsPage/mockData/mockData.js new file mode 100644 index 000000000..0e41bd790 --- /dev/null +++ b/src/main/cliapp/src/containers/variantsPage/mockData/mockData.js @@ -0,0 +1,272 @@ + +export const data = { + "results": [ + { + "type": "Variant", + "createdBy": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-10-12T13:35:18.190972+01:00", + "dbDateUpdated": "2023-10-12T13:35:18.190991+01:00", + "id": 135134336, + "uniqueId": "VARIANTTEST:Person0001" + }, + "updatedBy": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-10-12T13:35:18.245745+01:00", + "dbDateUpdated": "2023-10-12T13:35:18.245759+01:00", + "id": 135134337, + "uniqueId": "VARIANTTEST:Person0002" + }, + "dateCreated": "2022-03-09T22:10:12Z", + "dateUpdated": "2022-03-10T22:10:12Z", + "internal": true, + "obsolete": false, + "dbDateCreated": "2023-10-12T13:36:42.837428+01:00", + "dbDateUpdated": "2023-10-12T13:43:19.34603+01:00", + "curie": "WB:WBVarTest0002", + "taxon": { + "internal": false, + "obsolete": false, + "curie": "NCBITaxon:6239", + "name": "Caenorhabditis elegans" + }, + "dataProvider": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-10-12T13:36:42.79796+01:00", + "dbDateUpdated": "2023-10-12T13:36:42.797972+01:00", + "id": 135134369, + "sourceOrganization": { + "internal": false, + "obsolete": false, + "id": 20308683, + "uniqueId": "WB", + "abbreviation": "WB", + "fullName": "WormBase", + "homepageResourceDescriptorPage": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-02-20T09:26:39.609757Z", + "dbDateUpdated": "2023-08-27T22:00:03.833696+01:00", + "id": 41750788, + "name": "homepage", + "urlTemplate": "https://www.wormbase.org/" + } + } + }, + "variantType": { + "internal": false, + "obsolete": false, + "dbDateUpdated": "2023-02-19T22:00:17.970568Z", + "curie": "SO:0000694", + "name": "SNP", + "namespace": "sequence", + "definition": "SNPs are single base pair positions in genomic DNA at which different sequence alternatives exist in normal individuals in some population(s), wherein the least frequent variant has an abundance of 1% or greater." + }, + "variantStatus": { + "createdBy": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-07T09:16:24.627371+01:00", + "dbDateUpdated": "2023-09-07T09:16:24.627423+01:00", + "id": 133503891, + "uniqueId": "Local|Dev User|test@alliancegenome.org", + "firstName": "Local", + "lastName": "Dev User" + }, + "updatedBy": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-07T09:16:24.627371+01:00", + "dbDateUpdated": "2023-09-07T09:16:24.627423+01:00", + "id": 133503891, + "uniqueId": "Local|Dev User|test@alliancegenome.org", + "firstName": "Local", + "lastName": "Dev User" + }, + "dateCreated": "2023-10-12T13:22:16.592841+01:00", + "dateUpdated": "2023-10-12T13:22:16.603352+01:00", + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-10-12T13:22:16.613471+01:00", + "dbDateUpdated": "2023-10-12T13:22:16.613484+01:00", + "id": 135134309, + "name": "dead" + }, + "sourceGeneralConsequence": { + "internal": false, + "obsolete": false, + "dbDateUpdated": "2023-02-19T22:00:13.701218Z", + "curie": "SO:1000008", + "name": "point_mutation", + "namespace": "sequence", + "definition": "A single nucleotide change which has occurred at the same position of a corresponding nucleotide in a reference sequence." + }, + "relatedNotes": [ + { + "createdBy": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-10-12T13:35:18.190972+01:00", + "dbDateUpdated": "2023-10-12T13:35:18.190991+01:00", + "id": 135134336, + "uniqueId": "VARIANTTEST:Person0001" + }, + "updatedBy": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-10-12T13:35:18.245745+01:00", + "dbDateUpdated": "2023-10-12T13:35:18.245759+01:00", + "id": 135134337, + "uniqueId": "VARIANTTEST:Person0002" + }, + "dateCreated": "2022-03-09T22:10:12Z", + "dateUpdated": "2022-03-10T22:10:12Z", + "internal": false, + "obsolete": true, + "dbDateCreated": "2023-10-12T18:19:09.279238+01:00", + "dbDateUpdated": "2023-10-12T18:19:09.279251+01:00", + "id": 135134459, + "freeText": "Test note 2", + "noteType": { + "internal": false, + "obsolete": false, + "id": 88139193, + "name": "comment", + "definition": "general comment" + }, + "references": [ + { + "updatedBy": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-07T09:16:24.627371+01:00", + "dbDateUpdated": "2023-09-07T09:16:24.627423+01:00", + "id": 133503891, + "uniqueId": "Local|Dev User|test@alliancegenome.org", + "firstName": "Local", + "lastName": "Dev User" + }, + "dateUpdated": "2023-10-12T14:12:55.123893+01:00", + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-10-12T13:36:42.627017+01:00", + "dbDateUpdated": "2023-10-12T14:12:55.125203+01:00", + "curie": "AGRKB:101000000394981", + "crossReferences": [ + { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-10-12T13:36:42.62545+01:00", + "dbDateUpdated": "2023-10-12T13:36:42.625465+01:00", + "id": 135134366, + "referencedCurie": "PMID:29874341", + "displayName": "PMID:29874341" + }, + { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-10-12T13:36:42.608326+01:00", + "dbDateUpdated": "2023-10-12T13:36:42.608342+01:00", + "id": 135134365, + "referencedCurie": "PMCID:PMC5877110", + "displayName": "PMCID:PMC5877110" + } + ], + "shortCitation": " (2018) Int J Clin Exp Pathol 11(3):1837" + }, + { + "updatedBy": { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-09-07T09:16:24.627371+01:00", + "dbDateUpdated": "2023-09-07T09:16:24.627423+01:00", + "id": 133503891, + "uniqueId": "Local|Dev User|test@alliancegenome.org", + "firstName": "Local", + "lastName": "Dev User" + }, + "dateUpdated": "2023-10-12T14:12:55.131206+01:00", + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-10-12T13:36:42.448927+01:00", + "dbDateUpdated": "2023-10-12T14:12:55.14434+01:00", + "curie": "AGRKB:101000000392843", + "crossReferences": [ + { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-10-12T13:36:42.447767+01:00", + "dbDateUpdated": "2023-10-12T13:36:42.447777+01:00", + "id": 135134364, + "referencedCurie": "PMID:26330574", + "displayName": "PMID:26330574" + }, + { + "internal": false, + "obsolete": false, + "dbDateCreated": "2023-10-12T13:36:42.427509+01:00", + "dbDateUpdated": "2023-10-12T13:36:42.42752+01:00", + "id": 135134363, + "referencedCurie": "PMCID:PMC4561500", + "displayName": "PMCID:PMC4561500" + } + ], + "shortCitation": " (2015) Genome Res 25(9):1410.2" + } + ] + } + ] + } + ], + "totalResults": 1, + "returnedRecords": 1 +} + + +export const mockSettingsData = { + "page": 0, + "first": 0, + "rows": 50, + "multiSortMeta": [], + "selectedColumnNames": [ + "Curie", + "Taxon", + "Variant Type", + "Variant Status", + "Related Notes", + "Source General Consequence", + "Data Provider", + "Updated By", + "Date Updated", + "Created By", + "Date Created", + "Internal", + "Obsolete" + ], + "filters": {}, + "tableKeyName": "Variants", + "tableSettingsKeyName": "VariantsTableSettings" +}; + +export const termData = { + "generic_boolean_terms": { + "id": 23323, + "name": "generic_boolean_terms", + "displayName": "generic_boolean_terms", + "terms": [ + { + id: 213423, + name: true, + text: "true" + }, { + id: 3428828, + name: false, + text: "false" + } + ] + } +}; + From 4763be9228c1a6498bea9d1926a322b443543cb7 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Fri, 13 Oct 2023 12:25:48 -0500 Subject: [PATCH 62/76] SCRUM-3353 remove select column --- .../allelesPage/referencesTable/ReferencesFormTable.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/main/cliapp/src/containers/allelesPage/referencesTable/ReferencesFormTable.js b/src/main/cliapp/src/containers/allelesPage/referencesTable/ReferencesFormTable.js index 35dc74c9e..90c1d427e 100644 --- a/src/main/cliapp/src/containers/allelesPage/referencesTable/ReferencesFormTable.js +++ b/src/main/cliapp/src/containers/allelesPage/referencesTable/ReferencesFormTable.js @@ -3,15 +3,12 @@ import { Column } from 'primereact/column'; import { DeleteAction } from '../../../components/Actions/DeletionAction'; import { CrossReferencesTemplate } from '../../../components/Templates/CrossReferenceTemplate'; import { ShortCitationTemplate } from '../../../components/Templates/ShortCitationTemplate'; -import { SingleReferenceTableEditor } from '../../../components/Editors/references/SingleReferenceTableEditor'; export const ReferencesFormTable = ({ references, editingRows, onRowEditChange, - errorMessages, tableRef, - referencesOnChangeHandler, deletionHandler, }) => { @@ -24,13 +21,6 @@ export const ReferencesFormTable = ({ > } header="Action" className='max-w-4rem' bodyClassName="text-center" frozen /> - { - return ; - }} header="Select" /> } filter filterField='crossReferencesFilter' filterMatchMode='contains' showFilterMenu={false} /> From c879e61a615edc8a84c617aca578a4c4254ba837 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Fri, 13 Oct 2023 12:45:02 -0500 Subject: [PATCH 63/76] SCRUM-3353 add single reference below table --- .../references/SingleReferenceFormEditor.js | 2 +- .../referencesTable/ReferencesForm.js | 29 ++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/main/cliapp/src/components/Editors/references/SingleReferenceFormEditor.js b/src/main/cliapp/src/components/Editors/references/SingleReferenceFormEditor.js index d3dd345ee..0daa7115a 100644 --- a/src/main/cliapp/src/components/Editors/references/SingleReferenceFormEditor.js +++ b/src/main/cliapp/src/components/Editors/references/SingleReferenceFormEditor.js @@ -5,7 +5,7 @@ import { FormErrorMessageComponent } from "../../Error/FormErrorMessageComponent import { FormFieldWrapper } from "../../FormFieldWrapper"; import { referenceSearch } from "./utils"; -export const ReferencesFormEditor = ({ +export const SingleReferenceFormEditor = ({ onReferencesValueChange, widgetColumnSize, labelColumnSize, diff --git a/src/main/cliapp/src/containers/allelesPage/referencesTable/ReferencesForm.js b/src/main/cliapp/src/containers/allelesPage/referencesTable/ReferencesForm.js index 9a735adba..b9b5b49ac 100644 --- a/src/main/cliapp/src/containers/allelesPage/referencesTable/ReferencesForm.js +++ b/src/main/cliapp/src/containers/allelesPage/referencesTable/ReferencesForm.js @@ -3,18 +3,15 @@ import { FormTableWrapper } from "../../../components/FormTableWrapper"; import { ReferencesFormTable } from "./ReferencesFormTable"; import { useRef } from "react"; import { generateCrossRefSearchField } from "../utils"; +import { SingleReferenceFormEditor } from "../../../components/Editors/references/SingleReferenceFormEditor"; export const ReferencesForm = ({ state, dispatch }) => { const tableRef = useRef(null); - // dispatch({type: 'EDIT', value: filterableReferences}); - - - const createNewReferenceHandler = (e) => { e.preventDefault(); const dataKey = state.allele.references?.length; - //todo: add filter field in here + const newReference = { dataKey: dataKey, }; @@ -30,7 +27,6 @@ export const ReferencesForm = ({ state, dispatch }) => { const referencesOnChangeHandler = (event, setFieldValue, props) => { //updates value in table input box setFieldValue(event.target.value); - //todo: add filter field in here if (typeof event.target.value === 'string') return; const searchString = generateCrossRefSearchField(event.target.value); @@ -76,7 +72,24 @@ export const ReferencesForm = ({ state, dispatch }) => { } tableName="" showTable={state.entityStates.references.show} - button={
    diff --git a/src/main/cliapp/src/components/Editors/references/SingleReferenceFormEditor.js b/src/main/cliapp/src/components/Editors/references/SingleReferenceFormEditor.js index 23149beb2..564a68c00 100644 --- a/src/main/cliapp/src/components/Editors/references/SingleReferenceFormEditor.js +++ b/src/main/cliapp/src/components/Editors/references/SingleReferenceFormEditor.js @@ -1,39 +1,27 @@ import React from "react"; import { LiteratureAutocompleteTemplate } from "../../Autocomplete/LiteratureAutocompleteTemplate"; import { FormErrorMessageComponent } from "../../Error/FormErrorMessageComponent"; -import { FormFieldWrapper } from "../../FormFieldWrapper"; import { referenceSearch } from "./utils"; import { AutocompleteFormEditor } from "../../Autocomplete/AutocompleteFormEditor"; export const SingleReferenceFormEditor = ({ reference, onReferenceValueChange, - widgetColumnSize, - labelColumnSize, - fieldDetailsColumnSize, errorMessages }) => { return ( <> - - } - /> - } - errorField={} - additionalDataField={null} + + } /> + ); }; \ No newline at end of file diff --git a/src/main/cliapp/src/components/FormTableWrapper.js b/src/main/cliapp/src/components/FormTableWrapper.js index c9b200ed5..8b66350e5 100644 --- a/src/main/cliapp/src/components/FormTableWrapper.js +++ b/src/main/cliapp/src/components/FormTableWrapper.js @@ -3,6 +3,7 @@ export const FormTableWrapper = ({ tableName, showTable, button, + includeField=false, }) => { return (
    @@ -11,7 +12,7 @@ export const FormTableWrapper = ({
    {showTable && table} -
    +
    {button}
    diff --git a/src/main/cliapp/src/containers/allelesPage/referencesTable/NewReferenceField..js b/src/main/cliapp/src/containers/allelesPage/referencesTable/NewReferenceField..js index 2f6c7b114..9d9ed4b2c 100644 --- a/src/main/cliapp/src/containers/allelesPage/referencesTable/NewReferenceField..js +++ b/src/main/cliapp/src/containers/allelesPage/referencesTable/NewReferenceField..js @@ -2,6 +2,7 @@ import { useState } from "react"; import { Button } from "primereact/button"; import { generateCrossRefSearchField } from "../utils"; import { SingleReferenceFormEditor } from "../../../components/Editors/references/SingleReferenceFormEditor"; +import { Splitter, SplitterPanel } from "primereact/splitter"; export const NewReferenceField = ({ state, dispatch }) => { const [reference, setReference] = useState(null); @@ -51,12 +52,16 @@ export const NewReferenceField = ({ state, dispatch }) => { setReference(event.target.value); }; return ( - <> - -