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