Skip to content

Commit

Permalink
SCRUM-4667 fix review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
cmpich committed Jan 24, 2025
1 parent a6769dc commit c831a30
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,6 @@ public class AffectedGenomicModel extends GenomicEntity {
@OneToMany(mappedBy = "agmAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonView({View.FieldsAndLists.class, View.AffectedGenomicModelDetailView.class})
private List<AgmAlleleAssociation> components;
@IndexedEmbedded(includePaths = {
"agmAssociationSubject.name",
"agmAssociationSubject.name_keyword",
"agmAssociationSubject.synonyms",
"agmAssociationSubject.synonyms_keyword",
"agmAssociationSubject.secondaryIdentifiers",
"agmAssociationSubject.secondaryIdentifiers_keyword"
})
@OneToMany(mappedBy = "agmAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonView({View.FieldsAndLists.class, View.AffectedGenomicModelDetailView.class})
private List<AgmAgmAssociation> agmAgmAssociations;

@IndexedEmbedded(includePaths = {
"agmAgmAssociationObject.name",
"agmAgmAssociationObject.name_keyword",
Expand All @@ -113,8 +101,8 @@ public class AffectedGenomicModel extends GenomicEntity {
"agmAgmAssociationObject.secondaryIdentifiers",
"agmAgmAssociationObject.secondaryIdentifiers_keyword"
})
@OneToMany(mappedBy = "agmAgmAssociationObject", cascade = CascadeType.ALL, orphanRemoval = true)
@OneToMany(mappedBy = "agmAssociationSubject", 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"})
@JsonIgnoreProperties({"parentalPopulations", "agmSequenceTargetingReagentAssociations"})
private AffectedGenomicModel agmAgmAssociationObject;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -145,10 +145,10 @@ private void addAssociationToAgm(AgmAgmAssociation association) {

private void addAssociationToStr(AgmAgmAssociation association) {
AffectedGenomicModel str = association.getAgmAgmAssociationObject();
List<AgmAgmAssociation> currentAssociations = str.getAgmAgmAssociations();
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
@@ -0,0 +1,4 @@
drop INDEX agmagmassociation_agmassocobject_in;
ALTER TABLE public.agmagmassociation DROP CONSTRAINT agmstrassociation_agmassociationobject_fk;
CREATE INDEX agmagmassociation_agmassocobject_in ON public.agmagmassociation USING btree (agmAgmAssociationObject_id);
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
Expand Up @@ -26,8 +26,12 @@ public class AgmAgmAssociationBulkUploadITCase extends BaseITCase {

private AffectedGenomicModel agmSubject;
private AffectedGenomicModel agmObject;
private AffectedGenomicModel agmSubject2;
private AffectedGenomicModel agmObject2;
private String agmSubjectCurie = "AMGTEST:AffectedGenomicModel0010";
private String agmObjectCurie = "AMGTEST:AffectedGenomicModel0020";
private String agmSubjectCurie2 = "AMGTEST:AffectedGenomicModel00102";
private String agmObjectCurie2 = "AMGTEST:AffectedGenomicModel00202";
private String relationName = "has_parental_population";

@BeforeEach
Expand Down Expand Up @@ -55,14 +59,15 @@ 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();
System.out.println(s);
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.agmAgmAssociationObject.primaryExternalId", is(agmObjectCurie)).
body("entity.agmAssociationSubject.primaryExternalId", is(agmSubjectCurie)).
body("entity.internal", is(false)).
body("entity.obsolete", is(false)).
Expand All @@ -76,35 +81,26 @@ 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("agmAgmAssociationObject")));
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().
when().
get(agmAgmAssociationGetEndpoint + "?agmSubjectId=" + agmSubject.getId() + "&relationName=" + relationName + "&agmObjectId=" + agmObject.getId()).
get(agmAgmAssociationGetEndpoint + "?agmSubjectId=" + agmSubject2.getId() + "&relationName=" + relationName + "&agmObjectId=" + agmObject2.getId()).
then().
statusCode(200).
body("entity.relation.name", is(relationName)).
body("entity.agmAgmAssociationObject.primaryExternalId", is(agmObjectCurie)).
body("entity.agmAssociationSubject.primaryExternalId", is(agmSubjectCurie)).
body("entity.agmAssociationSubject.primaryExternalId", is(agmSubjectCurie2)).
body("entity.internal", is(true)).
body("entity.obsolete", is(true)).
body("entity.createdBy.uniqueId", is("AGMTEST:Person0001")).
Expand All @@ -115,17 +111,10 @@ public void agmAgmAssociationBulkUploadUpdateCheckFields() throws Exception {

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

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

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
{
"agm_subject_identifier": "AMGTEST:AffectedGenomicModel0010",
"agm_subject_identifier": "AMGTEST:AffectedGenomicModel00102",
"relation_name": "has_parental_population",
"agm_object_identifier": "AMGTEST:AffectedGenomicModel0020",
"agm_object_identifier": "AMGTEST:AffectedGenomicModel00202",
"internal": true,
"obsolete": true,
"created_by_curie": "AGMTEST:Person0001",
Expand Down

0 comments on commit c831a30

Please sign in to comment.