use of annis.sqlgen.MatrixQueryData in project ANNIS by korpling.
the class QueryServiceImpl method matrix.
/**
* Get result as matrix in WEKA (ARFF) format.
* @param query
* @param rawCorpusNames
* @param rawMetaKeys
* @param rawCsv
* @return
*/
@GET
@Path("search/matrix")
@Produces("text/plain")
public StreamingOutput matrix(@QueryParam("q") final String query, @QueryParam("corpora") final String rawCorpusNames, @QueryParam("metakeys") String rawMetaKeys, @DefaultValue("false") @QueryParam("csv") String rawCsv) {
requiredParameter(query, "q", "AnnisQL query");
requiredParameter(rawCorpusNames, "corpora", "comma separated list of corpus names");
final boolean outputCsv = Boolean.parseBoolean(rawCsv);
Subject user = SecurityUtils.getSubject();
List<String> corpusNames = splitCorpusNamesFromRaw(rawCorpusNames);
for (String c : corpusNames) {
user.checkPermission("query:matrix:" + c);
}
final QueryData data = queryDataFromParameters(query, rawCorpusNames);
MatrixQueryData ext = new MatrixQueryData();
if (rawMetaKeys != null) {
ext.setMetaKeys(splitMatrixKeysFromRaw(rawMetaKeys));
}
if (ext.getMetaKeys() != null && ext.getMetaKeys().isEmpty()) {
ext.setMetaKeys(null);
}
data.addExtension(ext);
StreamingOutput result = new StreamingOutput() {
@Override
public void write(OutputStream output) throws IOException, WebApplicationException {
long start = new Date().getTime();
queryDao.matrix(data, outputCsv, output);
long end = new Date().getTime();
logQuery("MATRIX", query, splitCorpusNamesFromRaw(rawCorpusNames), end - start);
}
};
return result;
}
Aggregations