use of annis.model.Annotation in project ANNIS by korpling.
the class TimeHelper method getNextEndTime.
private String getNextEndTime(AnnisNode rightNode) {
int offset = getOffset(rightNode);
String time = null;
for (long i = offset + 1; i < token.size(); i++) {
for (Annotation anno : token.get((int) i).getNodeAnnotations()) {
if ("time".equals(anno.getName())) {
time = anno.getValue();
break;
}
}
String startTime = getStartTime(time);
String endTime = getEndTime(time);
if (startTime != null && !"undefined".equals(startTime)) {
return startTime;
}
if (endTime != null && !"undefined".equals(endTime)) {
return endTime;
}
}
return "undefined";
}
use of annis.model.Annotation in project ANNIS by korpling.
the class AomAnnotateSqlGeneratorTest method shouldMapEmptyAnnotation.
@Test
public void shouldMapEmptyAnnotation() throws SQLException {
// given
String table = uniqueString();
stubDefaultAnnotation(table);
given(resultSet.wasNull()).willReturn(true);
// when
Annotation actual = generator.mapAnnotation(resultSet, tableAccessStrategy, table);
// then
assertThat(actual, is(nullValue()));
}
use of annis.model.Annotation in project ANNIS by korpling.
the class ListCorpusAnnotationsSqlHelper method mapRow.
@Override
public Annotation mapRow(ResultSet rs, int rowNum) throws SQLException {
String namespace = rs.getString("namespace");
String name = rs.getString("name");
String value = rs.getString("value");
String type = rs.getString("type");
String corpusName = rs.getString("corpus_name");
int pre = rs.getInt("corpus_pre");
return new Annotation(namespace, name, value, type, corpusName, pre);
}
use of annis.model.Annotation in project ANNIS by korpling.
the class ListDocumentsAnnotationsSqlHelper method mapRow.
@Override
public Annotation mapRow(ResultSet rs, int rowNum) throws SQLException {
Integer pre = rs.getInt("pre");
String corpusName = rs.getString("corpus_name");
String type = rs.getString("type");
String namespace = rs.getString("namespace");
String name = rs.getString("name");
String value = rs.getString("value");
Array annotationPathArray = rs.getArray("path_name");
List<String> annotationPath = new LinkedList<>();
if (annotationPathArray.getBaseType() == Types.VARCHAR) {
annotationPath = Arrays.asList((String[]) annotationPathArray.getArray());
}
return new Annotation(namespace, name, value, type, corpusName, pre, annotationPath);
}
use of annis.model.Annotation in project ANNIS by korpling.
the class TestQueryDaoImpl method listCorpusAnnotations.
@SuppressWarnings("unchecked")
@Test
public void listCorpusAnnotations() {
// stub JdbcTemplate to return a list of Annotation
final List<Annotation> ANNOTATIONS = mock(List.class);
when(jdbcTemplate.query(anyString(), any(RowMapper.class))).thenReturn(ANNOTATIONS);
// stub SQL query
final String ID = "toplevelcorpus";
when(listCorpusAnnotationsHelper.createSqlQuery(anyString(), anyString(), anyBoolean())).thenReturn(SQL);
// call and test
assertThat(queryDao.listCorpusAnnotations(ID), is(ANNOTATIONS));
verify(listCorpusAnnotationsHelper).createSqlQuery(ID, ID, true);
verify(jdbcTemplate).query(SQL, listCorpusAnnotationsHelper);
}
Aggregations