Search in sources :

Example 1 with CorpusConfigMap

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

the class QueryDaoImpl method getCorpusConfigurations.

@Override
public CorpusConfigMap getCorpusConfigurations() {
    List<AnnisCorpus> annisCorpora = listCorpora();
    CorpusConfigMap cConfigs = new CorpusConfigMap();
    if (annisCorpora != null) {
        for (AnnisCorpus c : annisCorpora) {
            try {
                Properties p = getCorpusConfiguration(c.getName());
                if (p != null) {
                    CorpusConfig corpusConfig = new CorpusConfig();
                    corpusConfig.setConfig(p);
                    cConfigs.put(c.getName(), corpusConfig);
                }
            } catch (FileNotFoundException ex) {
                log.error("no corpus.properties found for {}", c.getName());
            }
        }
    }
    return cConfigs;
}
Also used : AnnisCorpus(annis.service.objects.AnnisCorpus) CorpusConfigMap(annis.service.objects.CorpusConfigMap) FileNotFoundException(java.io.FileNotFoundException) Properties(java.util.Properties) CorpusConfig(annis.service.objects.CorpusConfig)

Example 2 with CorpusConfigMap

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

the class Helper method getCorpusConfigs.

/**
 * Loads the all available corpus configurations.
 *
 * @return A {@link CorpusConfigMap} object, which wraps a Map of
 * {@link Properties} objects. The keys to the properties are the corpus
 * names. A Properties object stores the corpus configuration as simple
 * key-value pairs. The Map includes also the default corpus configuration.
 */
public static CorpusConfigMap getCorpusConfigs() {
    CorpusConfigMap corpusConfigurations = null;
    try {
        corpusConfigurations = Helper.getAnnisWebResource().path("query").path("corpora").path("config").get(CorpusConfigMap.class);
    } catch (UniformInterfaceException | ClientHandlerException ex) {
        UI.getCurrent().access(new Runnable() {

            @Override
            public void run() {
                if (!AnnisBaseUI.handleCommonError(ex, "get corpus configurations")) {
                    new Notification(ERROR_MESSAGE_CORPUS_PROPS_HEADER, ERROR_MESSAGE_CORPUS_PROPS, Notification.Type.WARNING_MESSAGE, true).show(Page.getCurrent());
                }
            }
        });
    }
    if (corpusConfigurations == null) {
        corpusConfigurations = new CorpusConfigMap();
    }
    corpusConfigurations.put(DEFAULT_CONFIG, getDefaultCorpusConfig());
    return corpusConfigurations;
}
Also used : ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) CorpusConfigMap(annis.service.objects.CorpusConfigMap) Notification(com.vaadin.ui.Notification)

Example 3 with CorpusConfigMap

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

the class Helper method getCorpusConfigs.

/**
 * Loads the available corpus configurations for a list of specific corpora.
 *
 * @param corpora A Set of corpora names.
 * @return A {@link CorpusConfigMap} object, which wraps a Map of
 * {@link Properties} objects. The keys to the properties are the corpus
 * names. A Properties object stores the corpus configuration as simple
 * key-value pairs. The map includes the default configuration.
 */
public static CorpusConfigMap getCorpusConfigs(Set<String> corpora) {
    CorpusConfigMap corpusConfigurations = new CorpusConfigMap();
    for (String corpus : corpora) {
        corpusConfigurations.put(corpus, getCorpusConfig(corpus));
    }
    corpusConfigurations.put(DEFAULT_CONFIG, getDefaultCorpusConfig());
    return corpusConfigurations;
}
Also used : CorpusConfigMap(annis.service.objects.CorpusConfigMap)

Example 4 with CorpusConfigMap

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

the class QueryServiceImpl method corpusConfigs.

@GET
@Path("corpora/config")
@Produces("application/xml")
public CorpusConfigMap corpusConfigs() {
    CorpusConfigMap corpusConfigs = queryDao.getCorpusConfigurations();
    CorpusConfigMap result = new CorpusConfigMap();
    Subject user = SecurityUtils.getSubject();
    if (corpusConfigs != null) {
        for (String c : corpusConfigs.getCorpusConfigs().keySet()) {
            if (user.isPermitted("query:*:" + c)) {
                result.put(c, corpusConfigs.get(c));
            }
        }
    }
    return result;
}
Also used : CorpusConfigMap(annis.service.objects.CorpusConfigMap) Subject(org.apache.shiro.subject.Subject) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

CorpusConfigMap (annis.service.objects.CorpusConfigMap)4 AnnisCorpus (annis.service.objects.AnnisCorpus)1 CorpusConfig (annis.service.objects.CorpusConfig)1 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)1 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)1 Notification (com.vaadin.ui.Notification)1 FileNotFoundException (java.io.FileNotFoundException)1 Properties (java.util.Properties)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Subject (org.apache.shiro.subject.Subject)1