use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class ObservationController method getObservationsBySubmissionIdAndSubjuectId.
/*
* For a given submission, tier is decided so there is point of further
* specifiying tier.
*/
@Transactional
@RequestMapping(value = "bySubmissionAndSubject", method = { RequestMethod.GET, RequestMethod.POST }, headers = "Accept=application/json")
public ResponseEntity<String> getObservationsBySubmissionIdAndSubjuectId(@RequestParam("submissionId") Integer submissionId, @RequestParam("subjectId") Integer subjectId, @RequestParam(value = "role", required = false, defaultValue = "") String role) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
String summaryTemplate = null;
Set<Observation> observations = new HashSet<Observation>();
Subject subject = dashboardDao.getEntityById(Subject.class, subjectId);
for (ObservedSubject observedSubject : dashboardDao.findObservedSubjectBySubject(subject)) {
Observation observation = observedSubject.getObservation();
Submission submission = observation.getSubmission();
if (!submission.getId().equals(submissionId)) {
continue;
} else if (summaryTemplate == null) {
summaryTemplate = submission.getObservationTemplate().getObservationSummary();
}
String subjectRole = observedSubject.getObservedSubjectRole().getSubjectRole().getDisplayName();
if ((role.equals("") || role.equals(subjectRole))) {
observations.add(observation);
}
}
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 getOneObservationsPerSubmissionByECOTerm.
@Transactional
@RequestMapping(value = "onePerSubmissionByEcoTerm", method = { RequestMethod.GET, RequestMethod.POST }, headers = "Accept=application/json")
public ResponseEntity<String> getOneObservationsPerSubmissionByECOTerm(@RequestParam("ecocode") String ecocode, @RequestParam(value = "tier", required = false, defaultValue = "0") Integer tier) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
Map<Observation, BigInteger> observationAndCount = dashboardDao.getOneObservationPerSubmissionByEcoCode(ecocode, tier);
List<ObservationWithCount> list = new ArrayList<ObservationWithCount>();
for (Observation observation : observationAndCount.keySet()) {
list.add(new ObservationWithCount(observation, observationAndCount.get(observation).intValue()));
}
JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new DateTransformer(), Date.class);
return new ResponseEntity<String>(jsonSerializer.serialize(list), headers, HttpStatus.OK);
}
Aggregations