use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.
the class TerminologyDaoImpl method findTerminologyByAccession.
@Override
// SHOULD USE findTermByAccessionAndTerminology
@Cacheable("terminology-by-accession")
public CvTerm findTerminologyByAccession(String accession) {
Set<String> acs = new HashSet<>();
acs.add(accession);
SqlParameterSource params = new MapSqlParameterSource("accessions", acs);
List<CvTerm> terms = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("terminology-by-acs"), params, new DbTermRowMapper());
if (terms.size() == 0)
return null;
else if (terms.size() > 1) {
throw new NextProtException("Found " + terms.size() + " terms that corresponds to the same accession. Use the method findTerminologyByAccessionForTerminology (accession, terminology) instead");
}
return terms.get(0);
}
use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.
the class TermController method getAncestorGraph.
@ApiMethod(path = "/term/{term}/ancestor-graph", verb = ApiVerb.GET, description = "Get the ancestor graph of the given term", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/term/{term}/ancestor-graph", method = { RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, CvTermGraph.View> getAncestorGraph(@ApiPathParam(name = "term", description = "The accession of the cv term", allowedvalues = { "TS-0079" }) @PathVariable("term") String term) {
CvTerm cvTerm = terminologyService.findCvTermByAccession(term);
CvTermGraph graph = cvTermGraphService.findCvTermGraph(TerminologyCv.getTerminologyOf(cvTerm.getOntology()));
return Collections.singletonMap("ancestor-graph", graph.calcAncestorSubgraph(cvTerm.getId().intValue()).toView());
}
use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.
the class TermController method getDescendantGraph.
@ApiMethod(path = "/term/{term}/descendant-graph", verb = ApiVerb.GET, description = "Get the descendant graph of the given term", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/term/{term}/descendant-graph", method = { RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, CvTermGraph.View> getDescendantGraph(@ApiPathParam(name = "term", description = "The accession of the cv term", allowedvalues = { "TS-0079" }) @PathVariable("term") String term) {
CvTerm cvTerm = terminologyService.findCvTermByAccession(term);
CvTermGraph graph = cvTermGraphService.findCvTermGraph(TerminologyCv.getTerminologyOf(cvTerm.getOntology()));
return Collections.singletonMap("descendant-graph", graph.calcDescendantSubgraph(cvTerm.getId().intValue()).toView());
}
use of org.nextprot.api.core.domain.CvTerm in project nextprot-api by calipho-sib.
the class SeoTagsServiceImpl method getTermSeoTags.
@Override
public SeoTags getTermSeoTags(String url) {
String[] urlElements = RelativeUrlUtils.getPathElements(url);
String ac = urlElements[1];
// default subpage
String subpage = "proteins";
if (urlElements.length > 2)
subpage = urlElements[2];
String prettySubpage = getPrettyName(subpage);
CvTerm term = terminologyService.findCvTermByAccession(ac);
String title = term.getAccession() + " - " + getPrettyName(term.getName()) + " - " + prettySubpage;
String h1 = title;
// TODO: NullPointerException below
String descr = term.getOntology() + " " + term.getAccession() + " - " + term.getName() + " - " + prettySubpage;
return new SeoTags(title, descr, h1);
}
Aggregations