use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class OntologySearchController method searchExtraSubmissions.
@RequestMapping(value = "extra-submissions", method = { RequestMethod.GET }, headers = "Accept=application/json")
public ResponseEntity<String> searchExtraSubmissions(@RequestParam("subject-name") String subjectName) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
try {
List<SubmissionResult> submission_result = dashboardDao.getSubmissionsForSubjectName(subjectName).stream().map(submission -> {
ObservationTemplate template = submission.getObservationTemplate();
return new SearchResults.SubmissionResult(submission.getStableURL(), submission.getSubmissionDate(), template.getDescription(), template.getTier(), template.getSubmissionCenter().getDisplayName(), submission.getId(), dashboardDao.findObservationsBySubmission(submission).size(), template.getIsSubmissionStory());
}).collect(Collectors.toList());
JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new DateTransformer(), Date.class);
return new ResponseEntity<String>(jsonSerializer.deepSerialize(submission_result), headers, HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity<String>(headers, HttpStatus.NOT_FOUND);
}
}
use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class OntologySearchController method ontologySearch.
@RequestMapping(method = { RequestMethod.GET }, headers = "Accept=application/json")
public ResponseEntity<String> ontologySearch(@RequestParam("terms") String terms) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
SearchResults ontologyResult = dashboardDao.ontologySearch(terms.replaceAll("`", "'"));
log.debug("number of subject results from ontology search " + ontologyResult.numberOfSubjects());
JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new DateTransformer(), Date.class);
return new ResponseEntity<String>(jsonSerializer.deepSerialize(ontologyResult), headers, HttpStatus.OK);
}
use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class SearchController method getSearchResultsInJson.
@Transactional
@RequestMapping(value = "{keyword}", method = { RequestMethod.GET, RequestMethod.POST }, headers = "Accept=application/json")
public ResponseEntity<String> getSearchResultsInJson(@PathVariable String keyword) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
// This is to prevent unnecessary server loads
if (keyword.length() < 2)
return new ResponseEntity<String>(headers, HttpStatus.BAD_REQUEST);
keyword = keyword.replaceAll("`", "'");
SearchResults results = dashboardDao.search(keyword);
log.debug("number of subject results from search " + results.numberOfSubjects());
JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new DateTransformer(), Date.class);
return new ResponseEntity<String>(jsonSerializer.deepSerialize(results), headers, HttpStatus.OK);
}
use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class ObservationController method getObservationsBySubmissionIdAndEcoTerm.
@Transactional
@RequestMapping(value = "bySubmissionAndEcoTerm", method = { RequestMethod.GET, RequestMethod.POST }, headers = "Accept=application/json")
public ResponseEntity<String> getObservationsBySubmissionIdAndEcoTerm(@RequestParam("submissionId") Integer submissionId, @RequestParam("ecocode") String ecocode) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
String summaryTemplate = dashboardDao.getEntityById(Submission.class, submissionId).getObservationTemplate().getObservationSummary();
List<Observation> observations = dashboardDao.getObservationsForSubmissionAndEcoCode(submissionId, ecocode);
List<ObservationWithSummary> list = new ArrayList<ObservationWithSummary>();
for (Observation observation : observations) {
String expanded = dashboardDao.expandSummary(observation.getId(), summaryTemplate) + " (<a class='button-link' href='#" + observation.getStableURL() + "'>details »</a>)";
list.add(new ObservationWithSummary(observation, expanded));
}
JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new DateTransformer(), Date.class);
return new ResponseEntity<String>(jsonSerializer.serialize(list), headers, HttpStatus.OK);
}
use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class ObservationController method getObservationsBySubmissionId.
@Transactional
@RequestMapping(value = "bySubmission", method = { RequestMethod.GET, RequestMethod.POST }, headers = "Accept=application/json")
public ResponseEntity<String> getObservationsBySubmissionId(@RequestParam("submissionId") Integer submissionId, @RequestParam(value = "getAll", required = false, defaultValue = "false") Boolean getAll) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
List<? extends DashboardEntity> entities = getBySubmissionId(submissionId);
if (!getAll && entities.size() > getMaxNumberOfEntities()) {
entities = entities.subList(0, getMaxNumberOfEntities());
}
JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new DateTransformer(), Date.class);
return new ResponseEntity<String>(jsonSerializer.serialize(entities), headers, HttpStatus.OK);
}
Aggregations