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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations