Search in sources :

Example 1 with PagedResultQuery

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);
    }
}
Also used : PagedResultQuery(annis.gui.objects.PagedResultQuery) SaltProject(org.corpus_tools.salt.common.SaltProject) SingleResultFetchJob(annis.gui.resultfetch.SingleResultFetchJob)

Example 2 with PagedResultQuery

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);
    }
}
Also used : Window(com.vaadin.ui.Window) DisplayedResultQuery(annis.gui.objects.DisplayedResultQuery) PagedResultQuery(annis.gui.objects.PagedResultQuery) Query(annis.gui.objects.Query) Matcher(java.util.regex.Matcher) AnnisCorpus(annis.service.objects.AnnisCorpus) WebResource(com.sun.jersey.api.client.WebResource) LinkedList(java.util.LinkedList) PagedResultQuery(annis.gui.objects.PagedResultQuery) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

PagedResultQuery (annis.gui.objects.PagedResultQuery)2 DisplayedResultQuery (annis.gui.objects.DisplayedResultQuery)1 Query (annis.gui.objects.Query)1 SingleResultFetchJob (annis.gui.resultfetch.SingleResultFetchJob)1 AnnisCorpus (annis.service.objects.AnnisCorpus)1 WebResource (com.sun.jersey.api.client.WebResource)1 Window (com.vaadin.ui.Window)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 Matcher (java.util.regex.Matcher)1 SaltProject (org.corpus_tools.salt.common.SaltProject)1