use of org.nextprot.api.rdf.domain.OWLAnnotation in project nextprot-api by calipho-sib.
the class SchemaDaoImpl method findAllAnnotation.
@Override
public List<OWLAnnotation> findAllAnnotation() {
// get description for annotations that exist in db
AnnotationCategory[] cats = AnnotationCategory.values();
List<Long> typeIds = new ArrayList<Long>();
for (AnnotationCategory cat : cats) typeIds.add(new Long(cat.getDbId()));
SqlParameterSource params = new MapSqlParameterSource("typeIds", typeIds);
List<NameDescr> nds = new NamedParameterJdbcTemplate(dsLocator.getDataSource()).query(sqlDictionary.getSQLQuery("schema-instantiated-annotation-list"), params, new ParameterizedRowMapper<NameDescr>() {
@Override
public NameDescr mapRow(ResultSet rs, int row) throws SQLException {
NameDescr nd = new NameDescr(rs.getString("cv_name"), rs.getString("description"));
// System.out.println("rs.cv_name=" + nd.name + " description="+ nd.descr);
return nd;
}
});
// inject descriptions found in db into the OWLAnnotationCategory enum values
for (NameDescr nd : nds) {
AnnotationCategory m = AnnotationCategory.getByDbAnnotationTypeName(nd.name);
// System.out.println("before descr: " + m.toString());
m.setDescription(nd.descr);
// System.out.println("after descr: " + m.toString());
// AnnotationCategory.getByDbAnnotationTypeName(nd.name).setDescription(nd.descr);
}
// encapsulate OWLAnnotationCategory into OWLAnnotation to be compatible with the rest
List<OWLAnnotation> annotations = new ArrayList<OWLAnnotation>();
for (AnnotationCategory cat : AnnotationCategory.values()) {
annotations.add(new OWLAnnotation(cat));
}
return annotations;
}
Aggregations