Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCRUM-4667 make AgmAgmAssociation live under the general AgmAssociati… #1816

Merged
merged 14 commits into from
Feb 7, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ public void process(BulkLoadFileHistory bulkLoadFileHistory, Boolean cleanUp) th
if (loadType == AGM_ASSOCIATION || loadType == FULL_INGEST) {
agmStrAssociationExecutor.execLoad(bulkLoadFileHistory, cleanUp);
agmAlleleAssociationExecutor.execLoad(bulkLoadFileHistory, cleanUp);
}
if (loadType == AGM_AGM_ASSOCIATION || loadType == FULL_INGEST) {
agmAgmAssociationExecutor.execLoad(bulkLoadFileHistory, cleanUp);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@Entity
@Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true)
@ToString(exclude = {"agmDiseaseAnnotations", "agmPhenotypeAnnotations", "constructGenomicEntityAssociations", "agmSecondaryIds", "agmSequenceTargetingReagentAssociations", "components"}, callSuper = true)
@ToString(exclude = {"agmDiseaseAnnotations", "agmPhenotypeAnnotations", "constructGenomicEntityAssociations", "agmSecondaryIds", "agmSequenceTargetingReagentAssociations", "components", "parentalPopulations"}, callSuper = true)
@Schema(name = "AffectedGenomicModel", description = "POJO that represents the AGM")
@AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = {GenomicEntity.class}, partial = true)
public class AffectedGenomicModel extends GenomicEntity {
Expand Down Expand Up @@ -98,27 +98,15 @@ public class AffectedGenomicModel extends GenomicEntity {
private List<AgmAlleleAssociation> components;

@IndexedEmbedded(includePaths = {
"agmAssociationSubject.name",
"agmAssociationSubject.name_keyword",
"agmAssociationSubject.synonyms",
"agmAssociationSubject.synonyms_keyword",
"agmAssociationSubject.secondaryIdentifiers",
"agmAssociationSubject.secondaryIdentifiers_keyword"
"agmAgmAssociationObject.name",
"agmAgmAssociationObject.name_keyword",
"agmAgmAssociationObject.synonyms",
"agmAgmAssociationObject.synonyms_keyword",
"agmAgmAssociationObject.secondaryIdentifiers",
"agmAgmAssociationObject.secondaryIdentifiers_keyword"
})
@OneToMany(mappedBy = "agmAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonView({View.FieldsAndLists.class, View.AffectedGenomicModelDetailView.class})
private List<AgmAgmAssociation> agmAgmAssociations;

@IndexedEmbedded(includePaths = {
"agmAssociationObject.name",
"agmAssociationObject.name_keyword",
"agmAssociationObject.synonyms",
"agmAssociationObject.synonyms_keyword",
"agmAssociationObject.secondaryIdentifiers",
"agmAssociationObject.secondaryIdentifiers_keyword"
})
@OneToMany(mappedBy = "agmAssociationObject", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonView({View.FieldsAndLists.class, View.AffectedGenomicModelDetailView.class})
private List<AgmAgmAssociation> agmAgmObjectAssociations;
private List<AgmAgmAssociation> parentalPopulations;

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public class AgmAgmAssociation extends Association {

@IndexedEmbedded(includePaths = {
"curie", "name", "curie_keyword", "name_keyword",
"primaryExternalId", "perimaryExternalId_keyword", "modInternalId", "modInternalId_keyword"})
"primaryExternalId", "primaryExternalId_keyword", "modInternalId", "modInternalId_keyword"})
@ManyToOne
@JsonView({View.FieldsOnly.class})
@JsonIgnoreProperties({"agmAgmAssociations", "agmAgmObjectAssociations", "agmSequenceTargetingReagentAssociations"})
@JsonIgnoreProperties({"parentalPopulations", "agmSequenceTargetingReagentAssociations"})
@Fetch(FetchMode.JOIN)
private AffectedGenomicModel agmAssociationSubject;

Expand All @@ -56,10 +56,10 @@ public class AgmAgmAssociation extends Association {
@JsonView({View.FieldsOnly.class})
private VocabularyTerm relation;

@IndexedEmbedded(includePaths = {"name", "synonyms", "secondaryIdentifiers"})
@IndexedEmbedded(includePaths = {"name", "synonyms"})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@ManyToOne
@JsonView({View.FieldsOnly.class})
@JsonIgnoreProperties({"agmAgmAssociations", "agmAgmObjectAssociations", "agmSequenceTargetingReagentAssociations"})
private AffectedGenomicModel agmAssociationObject;
@JsonIgnoreProperties({"parentalPopulations", "agmSequenceTargetingReagentAssociations"})
private AffectedGenomicModel agmAgmAssociationObject;
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ObjectResponse<AgmAgmAssociation> getAssociation(Long agmId, String relat
Map<String, Object> params = new HashMap<>();
params.put("agmAssociationSubject.id", agmId);
params.put("relation.name", relationName);
params.put("agmAssociationObject.id", strId);
params.put("agmAgmAssociationObject.id", strId);

SearchResponse<AgmAgmAssociation> resp = agmAgmAssociationDAO.findByParams(params);
if (resp != null && resp.getSingleResult() != null) {
Expand All @@ -127,10 +127,10 @@ public ObjectResponse<AgmAgmAssociation> getAssociation(Long agmId, String relat

private void addAssociationToAgm(AgmAgmAssociation association) {
AffectedGenomicModel agm = association.getAgmAssociationSubject();
List<AgmAgmAssociation> currentAssociations = agm.getAgmAgmAssociations();
List<AgmAgmAssociation> currentAssociations = agm.getParentalPopulations();
if (currentAssociations == null) {
currentAssociations = new ArrayList<>();
agm.setAgmAgmAssociations(currentAssociations);
agm.setParentalPopulations(currentAssociations);
}

List<Long> currentAssociationIds = new ArrayList<>();
Expand All @@ -144,11 +144,11 @@ private void addAssociationToAgm(AgmAgmAssociation association) {
}

private void addAssociationToStr(AgmAgmAssociation association) {
AffectedGenomicModel str = association.getAgmAssociationObject();
List<AgmAgmAssociation> currentAssociations = str.getAgmAgmAssociations();
AffectedGenomicModel str = association.getAgmAgmAssociationObject();
List<AgmAgmAssociation> currentAssociations = str.getParentalPopulations();
if (currentAssociations == null) {
currentAssociations = new ArrayList<>();
str.setAgmAgmAssociations(currentAssociations);
str.setParentalPopulations(currentAssociations);
}

List<Long> currentAssociationIds = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public AgmAgmAssociation validateAgmAgmAssociationDTO(AgmAgmAssociationDTO dto,

params.put("agmAssociationSubject.id", subjectIds.get(0));
params.put("relation.name", dto.getRelationName());
params.put("agmAssociationObject.id", objectIds.get(0));
params.put("agmAgmAssociationObject.id", objectIds.get(0));

SearchResponse<AgmAgmAssociation> searchResponse = agmAgmAssociationDAO.findByParams(params);
if (searchResponse != null && searchResponse.getResults().size() == 1) {
Expand All @@ -84,15 +84,15 @@ public AgmAgmAssociation validateAgmAgmAssociationDTO(AgmAgmAssociationDTO dto,
}
}

if (association.getAgmAssociationObject() == null && !StringUtils.isBlank(dto.getAgmObjectIdentifier())) {
if (association.getAgmAgmAssociationObject() == null && !StringUtils.isBlank(dto.getAgmObjectIdentifier())) {

AffectedGenomicModel object = agmService.findByIdentifierString(dto.getAgmObjectIdentifier());
if (object == null) {
response.addErrorMessage("agm_object_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getAgmObjectIdentifier() + ")");
} else if (beDataProvider != null && !object.getDataProvider().getAbbreviation().equals(beDataProvider.sourceOrganization)) {
response.addErrorMessage("agm_object_identifier", ValidationConstants.INVALID_MESSAGE + " for " + beDataProvider.name() + " load (" + dto.getAgmObjectIdentifier() + ")");
} else {
association.setAgmAssociationObject(object);
association.setAgmAgmAssociationObject(object);
}
}
association = validateAuditedObjectDTO(association, dto);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ALTER TABLE agmagmassociation
add column
agmAgmAssociationObject_id bigint
;

cmpich marked this conversation as resolved.
Show resolved Hide resolved
alter table agmagmassociation
DROP agmassociationobject_id
;

delete
from bulkscheduledload
where id in (SELECT id
FROM bulkload
WHERE backendbulkloadtype = 'AGM_AGM_ASSOCIATION');

delete
from bulkmanualload
where id in (SELECT id
FROM bulkload
WHERE backendbulkloadtype = 'AGM_AGM_ASSOCIATION');

delete
from bulkload
WHERE group_id in (select id from bulkloadgroup where name = 'Direct (LinkML) AGM AGM Association Loads');

delete
from bulkloadgroup
where name = 'Direct (LinkML) AGM AGM Association Loads';


cmpich marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CREATE INDEX agmagmassociation_agmassocobject_in ON public.agmagmassociation USING btree (agmAgmAssociationObject_id);
oblodgett marked this conversation as resolved.
Show resolved Hide resolved
ALTER TABLE ONLY public.agmagmassociation ADD CONSTRAINT agmagmassociation_agmassociationobject_fk FOREIGN KEY (agmAgmAssociationObject_id) REFERENCES public.affectedgenomicmodel(id);
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--alter TABLE agmagmassociation ADD COLUMN agmAgmAssociationObject_id bigint;
--alter TABLE agmagmassociation drop agmAssociationObject_id;

CREATE INDEX AgmAgmAssociation_agmAssociationSubject_index ON public.agmagmassociation USING btree (agmassociationsubject_id);
CREATE INDEX AgmAgmAssociation_AgmAgmAssociationObject_index ON public.agmagmassociation USING btree (agmAgmAssociationObject_id);

drop index agmagmassociation_agmassocobject_in;
drop index agmagmassociation_agmassocsubject_in;

ALTER TABLE agmagmassociation DROP CONSTRAINT agmstrassociation_agmassocsubject_fk;
ALTER TABLE agmagmassociation DROP CONSTRAINT agmagmassociation_agmassociationobject_fk;
ALTER TABLE agmagmassociation DROP CONSTRAINT agmstrassociation_createdby_fk;
ALTER TABLE agmagmassociation DROP CONSTRAINT agmstrassociation_relation_fk;
ALTER TABLE agmagmassociation DROP CONSTRAINT agmstrassociation_updatedby_fk;

ALTER TABLE agmagmassociation ADD CONSTRAINT agmagmassociation_agmagmassociationobject_id_fk FOREIGN KEY (agmAgmAssociationObject_id) REFERENCES affectedgenomicmodel(id);
ALTER TABLE agmagmassociation ADD CONSTRAINT agmagmassociation_agmassociationsubject_id_fk FOREIGN KEY (agmassociationsubject_id) REFERENCES affectedgenomicmodel(id);

ALTER TABLE ONLY public.agmagmassociation ADD CONSTRAINT agmagmassociation_relation_fk FOREIGN KEY (relation_id) REFERENCES public.vocabularyterm(id);
ALTER TABLE ONLY public.agmagmassociation ADD CONSTRAINT agmagmassociation_updatedby_fk FOREIGN KEY (updatedby_id) REFERENCES public.person(id);
ALTER TABLE ONLY public.agmagmassociation ADD CONSTRAINT agmagmassociation_createdby_fk FOREIGN KEY (createdby_id) REFERENCES public.person(id);
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public void agmAgmAssociationBulkUploadCheckFields() throws Exception {
loadRequiredEntities();

checkSuccessfulBulkLoad(agmAgmAssociationBulkPostEndpoint, agmAgmAssociationTestFilePath + "AF_01_all_fields.json");


String s = agmAgmAssociationGetEndpoint + "?agmSubjectId=" + agmSubject.getId() + "&relationName=" + relationName + "&agmObjectId=" + agmObject.getId();
RestAssured.given().
when().
get(agmAgmAssociationGetEndpoint + "?agmSubjectId=" + agmSubject.getId() + "&relationName=" + relationName + "&agmObjectId=" + agmObject.getId()).
get(s).
then().
statusCode(200).
body("entity.relation.name", is(relationName)).
body("entity.agmAssociationObject.primaryExternalId", is(agmObjectCurie)).
body("entity.agmAssociationSubject.primaryExternalId", is(agmSubjectCurie)).
body("entity.internal", is(false)).
body("entity.obsolete", is(false)).
Expand All @@ -76,25 +76,16 @@ public void agmAgmAssociationBulkUploadCheckFields() throws Exception {
get(agmGetEndpoint + agmSubjectCurie).
then().
statusCode(200).
body("entity.agmAgmAssociations", hasSize(1)).
body("entity.agmAgmAssociations[0].relation.name", is(relationName)).
body("entity.agmAgmAssociations[0].agmAssociationSubject.primaryExternalId", is(agmSubjectCurie)).
body("entity.agmAgmAssociations[0].agmAssociationSubject", not(hasKey("agmAssociationObject")));
body("entity.parentalPopulations", hasSize(1)).
body("entity.parentalPopulations[0].relation.name", is(relationName)).
body("entity.parentalPopulations[0].agmAssociationSubject.primaryExternalId", is(agmSubjectCurie)).
body("entity.parentalPopulations[0].agmAssociationSubject", not(hasKey("agmAgmAssociationObject")));

RestAssured.given().
when().
get(agmGetEndpoint + agmObjectCurie).
then().
statusCode(200).
body("entity.agmAgmObjectAssociations", hasSize(1)).
body("entity.agmAgmObjectAssociations[0].relation.name", is(relationName)).
body("entity.agmAgmObjectAssociations[0].agmAssociationSubject.primaryExternalId", is(agmSubjectCurie)).
body("entity.agmAgmObjectAssociations[0].agmAgmAssociationObject", not(hasKey("agmAgmAssociations")));
}

@Test
@Order(2)
public void agmAgmAssociationBulkUploadUpdateCheckFields() throws Exception {

checkSuccessfulBulkLoad(agmAgmAssociationBulkPostEndpoint, agmAgmAssociationTestFilePath + "UD_01_update_all_except_default_fields.json");

RestAssured.given().
Expand All @@ -103,7 +94,6 @@ public void agmAgmAssociationBulkUploadUpdateCheckFields() throws Exception {
then().
statusCode(200).
body("entity.relation.name", is(relationName)).
body("entity.agmAgmAssociationObject.primaryExternalId", is(agmObjectCurie)).
body("entity.agmAssociationSubject.primaryExternalId", is(agmSubjectCurie)).
body("entity.internal", is(true)).
body("entity.obsolete", is(true)).
Expand All @@ -118,14 +108,7 @@ public void agmAgmAssociationBulkUploadUpdateCheckFields() throws Exception {
get(agmGetEndpoint + agmSubjectCurie).
then().
statusCode(200).
body("entity.agmSequenceTargetingReagentAssociations", hasSize(1));

RestAssured.given().
when().
get(agmGetEndpoint + agmObjectCurie).
then().
statusCode(200).
body("entity.agmSequenceTargetingReagentAssociations", hasSize(1));
body("entity.parentalPopulations", hasSize(1));
}

@Test
Expand Down
Loading