use of annis.service.objects.MatchGroup in project ANNIS by korpling.
the class QueryDaoImpl method graph.
@Override
@Transactional(readOnly = true)
public SaltProject graph(QueryData data) {
SaltProject p = executeQueryFunction(data, graphSqlGenerator, saltAnnotateExtractor);
List<MatchGroup> matchGroupExt = data.getExtensions(MatchGroup.class);
SaltAnnotateExtractor.addMatchInformation(p, matchGroupExt.get(0));
return p;
}
use of annis.service.objects.MatchGroup 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