Search in sources :

Example 11 with AnnisAttribute

use of annis.service.objects.AnnisAttribute in project ANNIS by korpling.

the class FlatQueryBuilder method getAvailableAnnotationLevels.

public Collection<String> getAvailableAnnotationLevels(String meta) {
    Collection<String> result = new TreeSet<>();
    WebResource service = Helper.getAnnisWebResource();
    // get current corpus selection
    Set<String> corpusSelection = cp.getState().getSelectedCorpora().getValue();
    if (service != null) {
        try {
            List<AnnisAttribute> atts = new LinkedList<>();
            for (String corpus : corpusSelection) {
                atts.addAll(service.path("query").path("corpora").path(corpus).path("annotations").queryParam("fetchvalues", "true").queryParam("onlymostfrequentvalues", "false").get(new GenericType<List<AnnisAttribute>>() {
                }));
            }
            for (AnnisAttribute a : atts) {
                if (a.getType() == AnnisAttribute.Type.node) {
                    String aa = killNamespace(a.getName());
                    if (aa.equals(meta)) {
                        result.addAll(a.getValueSet());
                    }
                }
            }
        } catch (ClientHandlerException ex) {
            log.error(null, ex);
        } catch (UniformInterfaceException ex) {
            log.error(null, ex);
        }
    }
    return result;
}
Also used : ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) GenericType(com.sun.jersey.api.client.GenericType) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) TreeSet(java.util.TreeSet) AnnisAttribute(annis.service.objects.AnnisAttribute) WebResource(com.sun.jersey.api.client.WebResource) LinkedList(java.util.LinkedList)

Example 12 with AnnisAttribute

use of annis.service.objects.AnnisAttribute in project ANNIS by korpling.

the class FlatQueryBuilder method getAvailableMetaLevels.

public Set<String> getAvailableMetaLevels(String meta) {
    Set<String> result = new TreeSet<>();
    WebResource service = Helper.getAnnisWebResource();
    // get current corpus selection
    Set<String> corpusSelection = cp.getState().getSelectedCorpora().getValue();
    if (service != null) {
        try {
            List<AnnisAttribute> atts = new LinkedList<>();
            for (String corpus : corpusSelection) {
                atts.addAll(service.path("query").path("corpora").path(corpus).path("annotations").queryParam("fetchvalues", "true").queryParam("onlymostfrequentvalues", "false").get(new GenericType<List<AnnisAttribute>>() {
                }));
            }
            for (AnnisAttribute a : atts) {
                if (a.getType() == AnnisAttribute.Type.meta) {
                    String aa = killNamespace(a.getName());
                    if (aa.equals(meta)) {
                        result.addAll(a.getValueSet());
                    }
                }
            }
        } catch (ClientHandlerException ex) {
            log.error(null, ex);
        } catch (UniformInterfaceException ex) {
            log.error(null, ex);
        }
    }
    return result;
}
Also used : ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) GenericType(com.sun.jersey.api.client.GenericType) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) TreeSet(java.util.TreeSet) AnnisAttribute(annis.service.objects.AnnisAttribute) WebResource(com.sun.jersey.api.client.WebResource) LinkedList(java.util.LinkedList)

Example 13 with AnnisAttribute

use of annis.service.objects.AnnisAttribute in project ANNIS by korpling.

the class CorpusBrowserPanel method fetchAnnos.

private List<AnnisAttribute> fetchAnnos(String toplevelCorpus) {
    Collection<AnnisAttribute> result = new ArrayList<>();
    try {
        WebResource service = Helper.getAnnisWebResource();
        if (service != null) {
            WebResource query = service.path("query").path("corpora").path(urlPathEscape.escape(toplevelCorpus)).path("annotations").queryParam("fetchvalues", "true").queryParam("onlymostfrequentvalues", "true");
            result = query.get(new AnnisAttributeListType());
        }
    } catch (UniformInterfaceException | ClientHandlerException ex) {
        log.error(null, ex);
        if (!AnnisBaseUI.handleCommonError(ex, "fetch example annotations")) {
            Notification.show("Remote exception: " + ex.getLocalizedMessage(), Notification.Type.WARNING_MESSAGE);
        }
    }
    return new LinkedList<>(result);
}
Also used : ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) AnnisAttribute(annis.service.objects.AnnisAttribute) ArrayList(java.util.ArrayList) WebResource(com.sun.jersey.api.client.WebResource) LinkedList(java.util.LinkedList)

Example 14 with AnnisAttribute

use of annis.service.objects.AnnisAttribute in project ANNIS by korpling.

the class FrequencyQueryPanel method getAvailableMetaNames.

public Set<String> getAvailableMetaNames() {
    Set<String> result = new TreeSet<>();
    WebResource service = Helper.getAnnisWebResource();
    // get current corpus selection
    Set<String> corpusSelection = state.getSelectedCorpora().getValue();
    if (service != null) {
        try {
            List<AnnisAttribute> atts = new LinkedList<>();
            for (String corpus : corpusSelection) {
                atts.addAll(service.path("query").path("corpora").path(corpus).path("annotations").get(new GenericType<List<AnnisAttribute>>() {
                }));
            }
            for (AnnisAttribute a : atts) {
                if (a.getType() == AnnisAttribute.Type.meta) {
                    result.add(a.getName());
                }
            }
        } catch (ClientHandlerException | UniformInterfaceException ex) {
            log.error(null, ex);
        }
    }
    return result;
}
Also used : ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) GenericType(com.sun.jersey.api.client.GenericType) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) TreeSet(java.util.TreeSet) AnnisAttribute(annis.service.objects.AnnisAttribute) WebResource(com.sun.jersey.api.client.WebResource) LinkedList(java.util.LinkedList)

Example 15 with AnnisAttribute

use of annis.service.objects.AnnisAttribute in project ANNIS by korpling.

the class TigerQueryBuilderCanvas method getAvailableAnnotationNames.

public Set<String> getAvailableAnnotationNames() {
    Set<String> result = new TreeSet<>();
    WebResource service = Helper.getAnnisWebResource();
    // get current corpus selection
    Set<String> corpusSelection = controller.getState().getSelectedCorpora().getValue();
    if (service != null && corpusSelection != null) {
        try {
            List<AnnisAttribute> atts = new LinkedList<>();
            for (String corpus : corpusSelection) {
                atts.addAll(service.path("query").path("corpora").path(corpus).path("annotations").queryParam("fetchvalues", "false").queryParam("onlymostfrequentvalues", "true").get(new AnnisAttributeListType()));
            }
            for (AnnisAttribute a : atts) {
                if (a.getType() == AnnisAttribute.Type.node) {
                    result.add(a.getName());
                }
            }
        } catch (UniformInterfaceException | ClientHandlerException ex) {
            log.error(null, ex);
        }
    }
    return result;
}
Also used : ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) TreeSet(java.util.TreeSet) AnnisAttribute(annis.service.objects.AnnisAttribute) WebResource(com.sun.jersey.api.client.WebResource) LinkedList(java.util.LinkedList)

Aggregations

AnnisAttribute (annis.service.objects.AnnisAttribute)15 LinkedList (java.util.LinkedList)10 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)9 WebResource (com.sun.jersey.api.client.WebResource)9 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)7 TreeSet (java.util.TreeSet)7 GenericType (com.sun.jersey.api.client.GenericType)5 AnnisQLSemanticsException (annis.exceptions.AnnisQLSemanticsException)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 AnnisCorpusAccessException (annis.exceptions.AnnisCorpusAccessException)2 AnnisQLSyntaxException (annis.exceptions.AnnisQLSyntaxException)2 QueryNode (annis.model.QueryNode)2 Match (annis.service.objects.Match)2 MatchGroup (annis.service.objects.MatchGroup)2 SubgraphFilter (annis.service.objects.SubgraphFilter)2 Stopwatch (com.google.common.base.Stopwatch)2 BufferedReader (java.io.BufferedReader)2