Example usage for java.lang Helper.AnnotationListType Helper.AnnotationListType

List of usage examples for java.lang Helper.AnnotationListType Helper.AnnotationListType

Introduction

In this page you can find the example usage for java.lang Helper.AnnotationListType Helper.AnnotationListType.

Prototype

Helper.AnnotationListType

Source Link

Usage

From source file:annis.gui.docbrowser.DocBrowserTable.java

/**
 * Retrieves date from the cache or from the annis rest service for a specific
 * document./* w ww  .jav  a2s  .com*/
 *
 * @param document The document the data are fetched for.
 * @return The a list of meta data. Can be empty but never null.
 */
private List<Annotation> getDocMetaData(String document) {
    // lookup up meta data in the cache
    if (!docMetaDataCache.containsKey(docBrowserPanel.getCorpus())) {
        // get the metadata for the corpus
        WebResource res = Helper.getAnnisWebResource();
        res = res.path("meta/corpus/").path(urlPathEscape.escape(docBrowserPanel.getCorpus())).path("closure");

        Map<String, List<Annotation>> metaDataMap = new HashMap<>();

        // create a document -> metadata map
        for (Annotation a : res.get(new Helper.AnnotationListType())) {
            if (a.getAnnotationPath() != null && !a.getAnnotationPath().isEmpty()
                    && a.getType().equals("DOCUMENT")) {
                String docName = a.getAnnotationPath().get(0);
                if (!metaDataMap.containsKey(docName)) {
                    metaDataMap.put(docName, new ArrayList<Annotation>());
                }
                metaDataMap.get(docName).add(a);
            }
        }
        docMetaDataCache.put(docBrowserPanel.getCorpus(), metaDataMap);
    }

    if (docMetaDataCache.get(docBrowserPanel.getCorpus()).containsKey(document)) {
        return docMetaDataCache.get(docBrowserPanel.getCorpus()).get(document);
    } else {
        return new ArrayList<Annotation>();
    }
}