use of annis.gui.objects.PagedResultQuery in project ANNIS by korpling.
the class QueryController method changeContext.
public void changeContext(PagedResultQuery originalQuery, Match match, long offset, int newContext, final VisualizerContextChanger visCtxChange, boolean left) {
try {
final PagedResultQuery newQuery = (PagedResultQuery) originalQuery.clone();
if (left) {
newQuery.setLeftContext(newContext);
} else {
newQuery.setRightContext(newContext);
}
newQuery.setOffset(offset);
Background.runWithCallback(new SingleResultFetchJob(match, newQuery), new FutureCallback<SaltProject>() {
@Override
public void onSuccess(SaltProject result) {
visCtxChange.updateResult(result, newQuery);
}
@Override
public void onFailure(Throwable t) {
ExceptionDialog.show(t, "Could not extend context.");
}
});
} catch (CloneNotSupportedException ex) {
log.error("Can't clone the query", ex);
}
}
use of annis.gui.objects.PagedResultQuery in project ANNIS by korpling.
the class SearchView method evaluateCitation.
public void evaluateCitation(String relativeUri) {
Matcher m = citationPattern.matcher(relativeUri);
if (m.matches()) {
// AQL
String aql = "";
if (m.group(1) != null) {
aql = m.group(1);
}
// CIDS
Set<String> selectedCorpora = new HashSet<>();
if (m.group(2) != null) {
String[] cids = m.group(2).split(",");
selectedCorpora.addAll(Arrays.asList(cids));
}
// filter by actually avaible user corpora in order not to get any exception later
WebResource res = Helper.getAnnisWebResource();
List<AnnisCorpus> userCorpora = res.path("query").path("corpora").get(new AnnisCorpusListType());
LinkedList<String> userCorporaStrings = new LinkedList<>();
for (AnnisCorpus c : userCorpora) {
userCorporaStrings.add(c.getName());
}
selectedCorpora.retainAll(userCorporaStrings);
// CLEFT and CRIGHT
if (m.group(4) != null && m.group(6) != null) {
int cleft = 0;
int cright = 0;
try {
cleft = Integer.parseInt(m.group(4));
cright = Integer.parseInt(m.group(6));
} catch (NumberFormatException ex) {
log.error("could not parse context value", ex);
}
ui.getQueryController().setQuery(new PagedResultQuery(cleft, cright, 0, 10, null, aql, selectedCorpora));
} else {
ui.getQueryController().setQuery(new Query(aql, selectedCorpora));
}
// remove all currently openend sub-windows
Set<Window> all = new HashSet<>(ui.getWindows());
for (Window w : all) {
ui.removeWindow(w);
}
} else {
Notification.show("Invalid citation", Notification.Type.WARNING_MESSAGE);
}
}
Aggregations