From a07a9bd94dfcaacaf060f3371a00f9f2f2b2d7fc Mon Sep 17 00:00:00 2001 From: Newatia Date: Sat, 16 Mar 2024 22:45:56 -0400 Subject: [PATCH 1/3] added fields and validation --- .../models/InvitroAssayInformation.java | 9 ++++++++- .../validators/RequiredFieldNonNullValidator.java | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/models/InvitroAssayInformation.java b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/models/InvitroAssayInformation.java index 8ef4ea4..3edc6b3 100644 --- a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/models/InvitroAssayInformation.java +++ b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/models/InvitroAssayInformation.java @@ -37,6 +37,10 @@ public class InvitroAssayInformation extends InvitroPharmacologyCommanData { @Column(name="ASSAY_ID") public String assayId; + @Indexable(suggest = true, facet=true, name= "Assay Set", sortable = true) + @Column(name="ASSAY_SET", length=1000) + public String assaySet; + @Indexable(suggest = true, facet=true, name= "External Assay ID", sortable = true) @Column(name="EXTERNAL_ASSAY_ID") public String externalAssayId; @@ -52,13 +56,16 @@ public class InvitroAssayInformation extends InvitroPharmacologyCommanData { public String externalAssayReferenceUrl; @Indexable(suggest = true, facet=true, name= "Assay Title", sortable = true) - @Column(name="ASSAY_TITLE") + @Column(name="ASSAY_TITLE", length=1000) public String assayTitle; @Indexable(suggest = true, facet=true, name= "Assay Format", sortable = true) @Column(name="ASSAY_FORMAT") public String assayFormat; + @Column(name = "ASSAY_MODE") + public String assayMode; + @Indexable(suggest = true, facet=true, name= "Bioassay Type", sortable = true) @Column(name="BIOASSAY_TYPE") public String bioassayType; diff --git a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/validators/RequiredFieldNonNullValidator.java b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/validators/RequiredFieldNonNullValidator.java index 7383870..d7ed601 100644 --- a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/validators/RequiredFieldNonNullValidator.java +++ b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/validators/RequiredFieldNonNullValidator.java @@ -17,6 +17,10 @@ public boolean supports(InvitroAssayInformation newValue, InvitroAssayInformatio @Override public void validate(InvitroAssayInformation objnew, InvitroAssayInformation objold, ValidatorCallback callback) { + if (objnew.assaySet == null || objnew.assaySet.isEmpty()) { + callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("Assay Set is required.")); + } + if ((objnew.externalAssayId == null) || (objnew.externalAssayId.isEmpty())) { callback.addMessage(GinasProcessingMessage.ERROR_MESSAGE("External Assay ID is required")); } From a89b84c47f6f5f5caecab22d26883e8077471353 Mon Sep 17 00:00:00 2001 From: Newatia Date: Tue, 19 Mar 2024 11:52:28 -0400 Subject: [PATCH 2/3] added new table --- .../InvitroPharmacologyController.java | 20 ++++++-- .../models/InvitroAssayInformation.java | 7 +++ .../models/InvitroAssaySet.java | 47 +++++++++++++++++++ .../InvitroPharmacologyRepository.java | 6 +++ .../InvitroPharmacologyEntityService.java | 14 +++++- 5 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/models/InvitroAssaySet.java diff --git a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/controllers/InvitroPharmacologyController.java b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/controllers/InvitroPharmacologyController.java index 2063e1f..ab224ab 100644 --- a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/controllers/InvitroPharmacologyController.java +++ b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/controllers/InvitroPharmacologyController.java @@ -116,9 +116,16 @@ public ResponseEntity findAllAssays() throws Exception { return new ResponseEntity(list, HttpStatus.OK); } - @GetGsrsRestApiMapping("/allTestAgents") - public ResponseEntity findAllTestAgents() throws Exception { - List list = invitroPharmacologyEntityService.findAllTestAgents(); + @GetGsrsRestApiMapping("/assaysByAssaySets/{assaySet}") + public ResponseEntity findAllAssysByAssaySet(@PathVariable("assaySet") String assaySet) throws Exception { + List list = invitroPharmacologyEntityService.findAllAssysByAssaySet(assaySet); + + return new ResponseEntity(list, HttpStatus.OK); + } + + @GetGsrsRestApiMapping("/allAssaySets") + public ResponseEntity findAllAssaySets() throws Exception { + List list = invitroPharmacologyEntityService.findAllAssaySets(); return new ResponseEntity(list, HttpStatus.OK); } @@ -130,6 +137,13 @@ public ResponseEntity findAllReferences() throws Exception { return new ResponseEntity(list, HttpStatus.OK); } + @GetGsrsRestApiMapping("/allTestAgents") + public ResponseEntity findAllTestAgents() throws Exception { + List list = invitroPharmacologyEntityService.findAllTestAgents(); + + return new ResponseEntity(list, HttpStatus.OK); + } + @GetGsrsRestApiMapping("/assaytargetunii/{assayTargetUnii}") public ResponseEntity findAssayByTargetNameApprovalId(@PathVariable("assayTargetUnii") String assayTargetUnii) throws Exception { List list = invitroPharmacologyEntityService.findAssayByTargetNameApprovalId(assayTargetUnii); diff --git a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/models/InvitroAssayInformation.java b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/models/InvitroAssayInformation.java index 3edc6b3..ef1d964 100644 --- a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/models/InvitroAssayInformation.java +++ b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/models/InvitroAssayInformation.java @@ -157,4 +157,11 @@ public void setInvitroAssayScreenings(List invitroAssaySc } } + // Many To Many, InvitroAssaySet + @ToString.Exclude + @LazyCollection(LazyCollectionOption.FALSE) + @ManyToMany(fetch = FetchType.LAZY, cascade= CascadeType.ALL) + @JoinTable(name="GSRS_INVITRO_ASSAY_SET_DET", joinColumns = @JoinColumn(name = "INVITRO_ASSAY_INFO_ID "), + inverseJoinColumns = @JoinColumn(name = "INVITRO_ASSAY_SET_ID")) + public List invitroAssaySets = new ArrayList<>(); } diff --git a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/models/InvitroAssaySet.java b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/models/InvitroAssaySet.java new file mode 100644 index 0000000..f600df2 --- /dev/null +++ b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/models/InvitroAssaySet.java @@ -0,0 +1,47 @@ +package gov.hhs.gsrs.invitropharmacology.models; + +import ix.core.SingleParent; +import ix.core.models.Indexable; +import ix.core.models.IndexableRoot; +import ix.core.models.ParentReference; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; + +import javax.persistence.*; + +import java.util.Date; +import java.util.ArrayList; +import java.util.List; + +@SingleParent +@Data +@Entity +@Table(name="GSRS_INVITRO_ASSAY_SET") +public class InvitroAssaySet extends InvitroPharmacologyCommanData { + + @Id + @SequenceGenerator(name="invitroAssaySetSeq", sequenceName="GSRS_INVITRO_ASSAY_SET_SEQ",allocationSize=1) + @GeneratedValue(strategy = GenerationType.AUTO, generator = "invitroAssaySetSeq") + @Column(name="ID") + public Long id; + + @Indexable(suggest = true, facet=true, name= "Assay Set", sortable = true) + @Column(name="ASSAY_SET") + public String assaySet; + + public InvitroAssaySet () {} + + // Many To Many, InvitroAssayInformation + @JsonIgnore + @ManyToMany(fetch = FetchType.EAGER, cascade= CascadeType.ALL) + @JoinTable(name="GSRS_INVITRO_ASSAY_SET_DET", joinColumns = @JoinColumn(name = "INVITRO_ASSAY_SET_ID"), + inverseJoinColumns = @JoinColumn(name = "INVITRO_ASSAY_INFO_ID")) + public List invitroAssayInformations = new ArrayList<>(); +} diff --git a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/repositories/InvitroPharmacologyRepository.java b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/repositories/InvitroPharmacologyRepository.java index af113d8..7f42996 100644 --- a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/repositories/InvitroPharmacologyRepository.java +++ b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/repositories/InvitroPharmacologyRepository.java @@ -31,9 +31,15 @@ public interface InvitroPharmacologyRepository extends GsrsVersionedRepository findAssayByTestAgent(String targetName); + @Query("select a from InvitroAssayInformation a JOIN a.invitroAssaySets s where s.assaySet = ?1") + List findAllAssysByAssaySet(String assaySet); + @Query("select a from InvitroAssayInformation a") List findAllAssays(); + @Query("select a from InvitroAssaySet a") + List findAllAssaySets(); + @Query("select a from InvitroReference a") List findAllReferences(); diff --git a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/services/InvitroPharmacologyEntityService.java b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/services/InvitroPharmacologyEntityService.java index c4e1ee6..45a9859 100644 --- a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/services/InvitroPharmacologyEntityService.java +++ b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/services/InvitroPharmacologyEntityService.java @@ -158,8 +158,13 @@ public List findAllAssays() { return list; } - public List findAllTestAgents() { - List list = repository.findAllTestAgents(); + public List findAllAssysByAssaySet(String assaySet) { + List list = repository.findAllAssysByAssaySet(assaySet); + return list; + } + + public List findAllAssaySets() { + List list = repository.findAllAssaySets(); return list; } @@ -168,6 +173,11 @@ public List findAllReferences() { return list; } + public List findAllTestAgents() { + List list = repository.findAllTestAgents(); + return list; + } + public List findAssayByTargetNameApprovalId(String assayTargetUnii) { List list = repository.findAssayByTargetNameApprovalId(assayTargetUnii); return list; From 1b9c26e910bc70c33b5572ba6c613add538ca287 Mon Sep 17 00:00:00 2001 From: Newatia Date: Tue, 19 Mar 2024 14:26:02 -0400 Subject: [PATCH 3/3] added actuator health and print statments --- .../InvitroPharmacologyController.java | 15 +++++++++++++++ .../InvitroPharmacologyEntityService.java | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/controllers/InvitroPharmacologyController.java b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/controllers/InvitroPharmacologyController.java index ab224ab..46de513 100644 --- a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/controllers/InvitroPharmacologyController.java +++ b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/controllers/InvitroPharmacologyController.java @@ -37,6 +37,9 @@ import org.springframework.web.bind.annotation.RequestParam; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.web.bind.annotation.GetMapping; + +import lombok.extern.slf4j.Slf4j; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; @@ -50,6 +53,9 @@ import java.util.Optional; import java.util.stream.Stream; +import net.minidev.json.JSONObject; + +@Slf4j @ExposesResourceFor(InvitroAssayInformation.class) @GsrsRestApiController(context = InvitroPharmacologyEntityService.CONTEXT, idHelper = IdHelpers.NUMBER) public class InvitroPharmacologyController extends EtagLegacySearchEntityController { @@ -102,6 +108,13 @@ protected Stream filterStream(Stream checkHealth() throws Exception { + JSONObject status = new JSONObject(); + status.put("status", "UP"); + return new ResponseEntity(status, HttpStatus.OK); + } + @GetGsrsRestApiMapping("/assay/{id}/screenings") public ResponseEntity findAllScreeningsByAssayId(@PathVariable("id") Long assayId) throws Exception { List list = invitroPharmacologyEntityService.findAllScreeningsByAssayId(assayId); @@ -111,6 +124,8 @@ public ResponseEntity findAllScreeningsByAssayId(@PathVariable("id") Lon @GetGsrsRestApiMapping("/allAssays") public ResponseEntity findAllAssays() throws Exception { + System.out.println("********** Controller: Inside findAllAssays() ********************"); + log.error("********** ********** Controller: Inside findAllAssays() ******************** "); List list = invitroPharmacologyEntityService.findAllAssays(); return new ResponseEntity(list, HttpStatus.OK); diff --git a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/services/InvitroPharmacologyEntityService.java b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/services/InvitroPharmacologyEntityService.java index 45a9859..6568acd 100644 --- a/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/services/InvitroPharmacologyEntityService.java +++ b/gsrs-module-invitro-pharmacology-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/invitropharmacology/services/InvitroPharmacologyEntityService.java @@ -17,11 +17,14 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; + import java.io.IOException; import java.util.List; import java.util.Optional; import java.util.UUID; +@Slf4j @Service public class InvitroPharmacologyEntityService extends AbstractGsrsEntityService { public static final String CONTEXT = "invitropharmacology"; @@ -126,11 +129,14 @@ public long count() { @Override public Optional get(Long id) { + System.out.println("********** Inside get(Long id) " + id); + log.error("********** Inside get(Long id) " + id); return repository.findById(id); } @Override public Optional flexLookup(String someKindOfId) { + System.out.println("********** Inside flexLookup(String someKindOfId) " + someKindOfId); if (someKindOfId == null){ return Optional.empty(); } @@ -154,6 +160,8 @@ public List findAllScreeningsByAssayId(Long id) { } public List findAllAssays() { + System.out.println("********** Inside findAllAssays() ********************"); + log.error("********** Inside findAllAssays() ******************** "); List list = repository.findAllAssays(); return list; }