use of annis.examplequeries.ExampleQuery in project ANNIS by korpling.
the class ListExampleQueriesHelper method mapRow.
@Override
public ExampleQuery mapRow(ResultSet rs, int i) throws SQLException {
ExampleQuery exampleQuery = new ExampleQuery();
exampleQuery.setType(rs.getString("type"));
exampleQuery.setUsedOperators(rs.getString("used_ops"));
exampleQuery.setExampleQuery(rs.getString("example_query"));
exampleQuery.setDescription(rs.getString("description"));
exampleQuery.setCorpusName(rs.getString("corpus_name"));
return exampleQuery;
}
use of annis.examplequeries.ExampleQuery in project ANNIS by korpling.
the class AbstractAutoQuery method getExampleQuery.
@Override
public ExampleQuery getExampleQuery() {
ExampleQuery exampleQuery = new ExampleQuery();
exampleQuery.setNodes(getNodes());
exampleQuery.setType(getType());
exampleQuery.setDescription(getDescription());
exampleQuery.setUsedOperators(getOperators());
exampleQuery.setExampleQuery(getFinalAQLQuery());
return exampleQuery;
}
use of annis.examplequeries.ExampleQuery in project ANNIS by korpling.
the class QueriesGenerator method generateQuery.
private void generateQuery(QueryBuilder queryBuilder) {
try {
// retrieve the aql query for analyzing purposes
String aql = queryBuilder.getAQL();
// set some necessary extensions for generating complete sql
QueryData queryData = getQueryDao().parseAQL(aql, this.corpusIds);
queryData.addExtension(queryBuilder.getLimitOffsetQueryData());
// retrieve the salt project to analyze
List<Match> matches = getQueryDao().find(queryData);
if (matches.isEmpty()) {
return;
}
QueryData matchQueryData = GraphHelper.createQueryData(new MatchGroup(matches), queryDao);
matchQueryData.addExtension(queryBuilder.getAnnotateQueryData());
SaltProject saltProject = getQueryDao().graph(matchQueryData);
queryBuilder.analyzingQuery(saltProject);
// set the corpus name
ExampleQuery exampleQuery = queryBuilder.getExampleQuery();
exampleQuery.setCorpusName(corpusName);
// copy the example query to the database
if (exampleQuery.getExampleQuery() != null && !"".equals(exampleQuery.getExampleQuery())) {
if (getTableInsertSelect().containsKey("example_queries")) {
Object[] values = new Object[] { exampleQuery.getExampleQuery(), exampleQuery.getDescription(), exampleQuery.getType() == null ? "" : exampleQuery.getType(), exampleQuery.getNodes(), "{}", corpusIds.get(0) };
int[] argTypes = new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.VARCHAR, Types.INTEGER };
getJdbcTemplate().update("INSERT INTO example_queries(" + getTableInsertSelect().get("example_queries") + ") VALUES(?, ?, ?, ?, ?::text[], ?)", values, argTypes);
log.info("generated example query: {}", exampleQuery.getExampleQuery());
}
} else {
log.warn("could not generating auto query with {}", queryBuilder.getClass().getName());
}
} catch (Exception ex) {
log.warn("Cannot generate example query", ex);
}
}
Aggregations