use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class FindProteinFromGeneController method browseByCharacter.
@Transactional
@RequestMapping(value = "{id}", method = { RequestMethod.GET, RequestMethod.POST }, headers = "Accept=application/json")
public ResponseEntity<String> browseByCharacter(@PathVariable Integer id) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
Gene gene = dashboardDao.getEntityById(Gene.class, id);
List<Protein> proteinByGene = dashboardDao.findProteinByGene(gene);
JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new DateTransformer(), Date.class);
return new ResponseEntity<String>(jsonSerializer.deepSerialize(proteinByGene), headers, HttpStatus.OK);
}
use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class ListController method getSimilarSubmissionsInJson.
@Transactional
@RequestMapping(value = "similar/{submissionId}", method = { RequestMethod.GET, RequestMethod.POST }, headers = "Accept=application/json")
public ResponseEntity<String> getSimilarSubmissionsInJson(@PathVariable Integer submissionId) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new DateTransformer(), Date.class);
List<Submission> submissions = webServiceUtil.getSimilarSubmissions(submissionId);
return new ResponseEntity<String>(jsonSerializer.serialize(submissions), headers, HttpStatus.OK);
}
use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class ExploreController method browseByKeyword.
@Transactional
@RequestMapping(value = "{roles}", method = { RequestMethod.GET, RequestMethod.POST }, headers = "Accept=application/json")
public ResponseEntity<String> browseByKeyword(@PathVariable String roles) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
List<SubjectWithSummaries> entities = new ArrayList<SubjectWithSummaries>();
for (String s : roles.split(",")) {
String role = s.trim().toLowerCase();
entities.addAll(getWebServiceUtil().exploreSubjects(role));
}
Collections.sort(entities, new Comparator<SubjectWithSummaries>() {
@Override
public int compare(SubjectWithSummaries o1, SubjectWithSummaries o2) {
int i = o2.getScore() - o1.getScore();
if (i == 0) {
int j = o2.getMaxTier() - o1.getMaxTier();
if (j == 0) {
return o2.getNumberOfObservations() - o1.getNumberOfObservations();
} else {
return j;
}
} else {
return i;
}
}
});
JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new DateTransformer(), Date.class);
return new ResponseEntity<String>(jsonSerializer.deepSerialize(entities), headers, HttpStatus.OK);
}
use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class JSONController method getGeneInJson.
/*
* gene needs a separate method because it asks for different number of
* parameters
*/
@Transactional
@RequestMapping(value = "{type}/{species}/{symbol}", method = { RequestMethod.GET, RequestMethod.POST }, headers = "Accept=application/json")
public ResponseEntity<String> getGeneInJson(@PathVariable String type, @PathVariable String species, @PathVariable String symbol) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
if (!type.equalsIgnoreCase("gene")) {
log.info("query with wrong type");
return new ResponseEntity<String>(headers, HttpStatus.NOT_FOUND);
}
List<Gene> genes = dashboardDao.findGenesBySymbol(symbol);
Gene gene = null;
for (Gene g : genes) {
if (g.getOrganism().getDisplayName().toLowerCase().startsWith(species)) {
gene = g;
break;
}
}
if (gene == null) {
return new ResponseEntity<String>(headers, HttpStatus.NOT_FOUND);
} else {
JSONSerializer jsonSerializer = new JSONSerializer().transform(new ImplTransformer(), Class.class).transform(new DateTransformer(), Date.class);
return new ResponseEntity<String>(jsonSerializer.deepSerialize(gene), headers, HttpStatus.OK);
}
}
use of gov.nih.nci.ctd2.dashboard.util.ImplTransformer in project nci-ctd2-dashboard by CBIIT.
the class ObservationController method getOneObservationsPerSubmission.
@Transactional
@RequestMapping(value = "onePerSubmissionBySubject", method = { RequestMethod.GET, RequestMethod.POST }, headers = "Accept=application/json")
public ResponseEntity<String> getOneObservationsPerSubmission(@RequestParam("subjectId") Integer subjectId, @RequestParam(value = "role", required = false, defaultValue = "") String role, @RequestParam(value = "tier", required = false, defaultValue = "0") Integer tier) {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/json; charset=utf-8");
List<ObservationWithCount> list = null;
if (tier > 0 || role.trim().length() > 0) {
list = onePerSubmissionBySubjectId(subjectId, role, tier);
} else {
Map<Observation, BigInteger> observationAndCount = dashboardDao.getOneObservationPerSubmission(subjectId);
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