Skip to content

Commit

Permalink
Merge pull request #3 from ncats/archUpdate
Browse files Browse the repository at this point in the history
added actuator health and print statements
  • Loading branch information
ChemMitch authored Mar 19, 2024
2 parents 515b68b + 1b9c26e commit 03e1a56
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<InvitroPharmacologyController, InvitroAssayInformation, Long> {
Expand Down Expand Up @@ -102,6 +108,13 @@ protected Stream<InvitroAssayInformation> filterStream(Stream<InvitroAssayInform
return stream;
}

@GetGsrsRestApiMapping("/actuator/health")
public ResponseEntity<Object> checkHealth() throws Exception {
JSONObject status = new JSONObject();
status.put("status", "UP");
return new ResponseEntity(status, HttpStatus.OK);
}

@GetGsrsRestApiMapping("/assay/{id}/screenings")
public ResponseEntity<String> findAllScreeningsByAssayId(@PathVariable("id") Long assayId) throws Exception {
List<InvitroAssayInformation> list = invitroPharmacologyEntityService.findAllScreeningsByAssayId(assayId);
Expand All @@ -111,14 +124,23 @@ public ResponseEntity<String> findAllScreeningsByAssayId(@PathVariable("id") Lon

@GetGsrsRestApiMapping("/allAssays")
public ResponseEntity<String> findAllAssays() throws Exception {
System.out.println("********** Controller: Inside findAllAssays() ********************");
log.error("********** ********** Controller: Inside findAllAssays() ******************** ");
List<InvitroAssayInformation> list = invitroPharmacologyEntityService.findAllAssays();

return new ResponseEntity(list, HttpStatus.OK);
}

@GetGsrsRestApiMapping("/allTestAgents")
public ResponseEntity<String> findAllTestAgents() throws Exception {
List<InvitroTestAgent> list = invitroPharmacologyEntityService.findAllTestAgents();
@GetGsrsRestApiMapping("/assaysByAssaySets/{assaySet}")
public ResponseEntity<String> findAllAssysByAssaySet(@PathVariable("assaySet") String assaySet) throws Exception {
List<InvitroAssayInformation> list = invitroPharmacologyEntityService.findAllAssysByAssaySet(assaySet);

return new ResponseEntity(list, HttpStatus.OK);
}

@GetGsrsRestApiMapping("/allAssaySets")
public ResponseEntity<String> findAllAssaySets() throws Exception {
List<InvitroAssaySet> list = invitroPharmacologyEntityService.findAllAssaySets();

return new ResponseEntity(list, HttpStatus.OK);
}
Expand All @@ -130,6 +152,13 @@ public ResponseEntity<String> findAllReferences() throws Exception {
return new ResponseEntity(list, HttpStatus.OK);
}

@GetGsrsRestApiMapping("/allTestAgents")
public ResponseEntity<String> findAllTestAgents() throws Exception {
List<InvitroTestAgent> list = invitroPharmacologyEntityService.findAllTestAgents();

return new ResponseEntity(list, HttpStatus.OK);
}

@GetGsrsRestApiMapping("/assaytargetunii/{assayTargetUnii}")
public ResponseEntity<String> findAssayByTargetNameApprovalId(@PathVariable("assayTargetUnii") String assayTargetUnii) throws Exception {
List<InvitroAssayInformation> list = invitroPharmacologyEntityService.findAssayByTargetNameApprovalId(assayTargetUnii);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -150,4 +157,11 @@ public void setInvitroAssayScreenings(List<InvitroAssayScreening> 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<InvitroAssaySet> invitroAssaySets = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -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<InvitroAssayInformation> invitroAssayInformations = new ArrayList<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ public interface InvitroPharmacologyRepository extends GsrsVersionedRepository<I
@Query("select a from InvitroAssayInformation a JOIN a.invitroAssayScreenings s JOIN s.invitroTestAgent ta WHERE ta.testAgent = ?1")
List<InvitroAssayInformation> findAssayByTestAgent(String targetName);

@Query("select a from InvitroAssayInformation a JOIN a.invitroAssaySets s where s.assaySet = ?1")
List<InvitroAssayInformation> findAllAssysByAssaySet(String assaySet);

@Query("select a from InvitroAssayInformation a")
List<InvitroAssayInformation> findAllAssays();

@Query("select a from InvitroAssaySet a")
List<InvitroAssaySet> findAllAssaySets();

@Query("select a from InvitroReference a")
List<InvitroReference> findAllReferences();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<InvitroAssayInformation, Long> {
public static final String CONTEXT = "invitropharmacology";
Expand Down Expand Up @@ -126,11 +129,14 @@ public long count() {

@Override
public Optional<InvitroAssayInformation> 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<InvitroAssayInformation> flexLookup(String someKindOfId) {
System.out.println("********** Inside flexLookup(String someKindOfId) " + someKindOfId);
if (someKindOfId == null){
return Optional.empty();
}
Expand All @@ -154,12 +160,19 @@ public List<InvitroAssayInformation> findAllScreeningsByAssayId(Long id) {
}

public List<InvitroAssayInformation> findAllAssays() {
System.out.println("********** Inside findAllAssays() ********************");
log.error("********** Inside findAllAssays() ******************** ");
List<InvitroAssayInformation> list = repository.findAllAssays();
return list;
}

public List<InvitroTestAgent> findAllTestAgents() {
List<InvitroTestAgent> list = repository.findAllTestAgents();
public List<InvitroAssayInformation> findAllAssysByAssaySet(String assaySet) {
List<InvitroAssayInformation> list = repository.findAllAssysByAssaySet(assaySet);
return list;
}

public List<InvitroAssaySet> findAllAssaySets() {
List<InvitroAssaySet> list = repository.findAllAssaySets();
return list;
}

Expand All @@ -168,6 +181,11 @@ public List<InvitroReference> findAllReferences() {
return list;
}

public List<InvitroTestAgent> findAllTestAgents() {
List<InvitroTestAgent> list = repository.findAllTestAgents();
return list;
}

public List<InvitroAssayInformation> findAssayByTargetNameApprovalId(String assayTargetUnii) {
List<InvitroAssayInformation> list = repository.findAssayByTargetNameApprovalId(assayTargetUnii);
return list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand Down

0 comments on commit 03e1a56

Please sign in to comment.