use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class SummaryController method getSummary.
@Transactional
@RequestMapping(method = { RequestMethod.GET }, headers = "Accept=application/json")
public ResponseEntity<String> getSummary() {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
List<Summary> summary = dashboardDao.getOverallSummary();
JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new SimpleDateTransformer(), Date.class).transform(new ExcludeTransformer(), void.class);
String json = "{}";
try {
json = jsonSerializer.exclude("class").exclude("submissions.class").deepSerialize(summary.toArray(new Summary[0]));
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity<String>(headers, HttpStatus.NOT_FOUND);
}
log.debug("get summary");
return new ResponseEntity<String>(json, headers, HttpStatus.OK);
}
use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class CentersAPI method getCenters.
@Transactional
@RequestMapping(method = { RequestMethod.GET }, headers = "Accept=application/json")
public ResponseEntity<String> getCenters() {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
List<SubmissionCenter> centers = dashboardDao.findEntities(SubmissionCenter.class);
APICenter[] apiCenters = new APICenter[centers.size()];
int centerIndex = 0;
for (SubmissionCenter center : centers) {
List<Submission> submissions = dashboardDao.findSubmissionBySubmissionCenter(center);
String[] ss = submissions.stream().map(x -> x.getStableURL()).toArray(String[]::new);
// design flaw
String pi = submissions.get(0).getObservationTemplate().getPrincipalInvestigator();
apiCenters[centerIndex++] = new APICenter(center, pi, ss);
}
log.debug("ready to serialize");
JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new SimpleDateTransformer(), Date.class).transform(new ExcludeTransformer(), void.class);
String json = "{}";
try {
json = jsonSerializer.exclude("class").exclude("submissions.class").deepSerialize(apiCenters);
} catch (Exception e) {
e.printStackTrace();
return new ResponseEntity<String>(headers, HttpStatus.NOT_FOUND);
}
return new ResponseEntity<String>(json, headers, HttpStatus.OK);
}
use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class CountController method getSearchResultsInJson.
@Transactional
@RequestMapping(value = "{type}", method = { RequestMethod.GET, RequestMethod.POST }, headers = "Accept=application/json")
public ResponseEntity<String> getSearchResultsInJson(@PathVariable String type, @RequestParam("filterBy") Integer filterBy) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
List<? extends DashboardEntity> entities = webServiceUtil.getDashboardEntities(type, filterBy);
JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new DateTransformer(), Date.class);
return new ResponseEntity<String>(jsonSerializer.serialize(entities.size()), headers, HttpStatus.OK);
}
use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class EcoController method browse.
@Transactional
@RequestMapping(value = "browse", method = { RequestMethod.GET, RequestMethod.POST }, headers = "Accept=application/json")
public ResponseEntity<String> browse() {
final HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
final List<EcoBrowse> list = dashboardDao.getEcoBrowse();
log.debug("number of ECO terms " + list.size());
Collections.sort(list, new Comparator<EcoBrowse>() {
@Override
public int compare(final EcoBrowse o1, final EcoBrowse o2) {
return o2.getNumberOfSubmissions() - o1.getNumberOfSubmissions();
}
});
final JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new DateTransformer(), Date.class);
return new ResponseEntity<String>(jsonSerializer.deepSerialize(list), headers, HttpStatus.OK);
}
use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class EcoController method term.
@Transactional
@RequestMapping(value = "term/{id}", method = { RequestMethod.GET, RequestMethod.POST }, headers = "Accept=application/json")
public ResponseEntity<String> term(@PathVariable final String id) {
log.debug("request received by EcoController for " + id);
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
final ECOTerm ecoterm = dashboardDao.getEntityByStableURL("eco", "eco/" + id);
log.debug(ecoterm);
final JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new DateTransformer(), Date.class);
return new ResponseEntity<String>(jsonSerializer.deepSerialize(ecoterm), headers, HttpStatus.OK);
}
Aggregations