use of annis.service.objects.AnnisCorpus in project ANNIS by korpling.
the class CorpusListPanel method initCorpusBrowser.
public void initCorpusBrowser(String topLevelCorpusName, final Button l) {
AnnisCorpus c = ui.getQueryState().getAvailableCorpora().getItem(topLevelCorpusName).getBean();
MetaDataPanel meta = new MetaDataPanel(c.getName());
CorpusBrowserPanel browse = new CorpusBrowserPanel(c, ui.getQueryController());
GridLayout infoLayout = new GridLayout(2, 2);
infoLayout.setSizeFull();
String corpusURL = Helper.generateCorpusLink(Sets.newHashSet(topLevelCorpusName));
Label lblLink = new Label("Link to corpus: <a href=\"" + corpusURL + "\">" + corpusURL + "</a>", ContentMode.HTML);
lblLink.setHeight("-1px");
lblLink.setWidth("-1px");
infoLayout.addComponent(meta, 0, 0);
infoLayout.addComponent(browse, 1, 0);
infoLayout.addComponent(lblLink, 0, 1, 1, 1);
infoLayout.setRowExpandRatio(0, 1.0f);
infoLayout.setColumnExpandRatio(0, 0.5f);
infoLayout.setColumnExpandRatio(1, 0.5f);
infoLayout.setComponentAlignment(lblLink, Alignment.MIDDLE_CENTER);
Window window = new Window("Corpus information for " + c.getName() + " (ID: " + c.getId() + ")", infoLayout);
window.setWidth(70, Unit.EM);
window.setHeight(45, Unit.EM);
window.setResizable(true);
window.setModal(false);
window.setResizeLazy(true);
window.addCloseListener(new Window.CloseListener() {
@Override
public void windowClose(Window.CloseEvent e) {
l.setEnabled(true);
}
});
UI.getCurrent().addWindow(window);
window.center();
}
use of annis.service.objects.AnnisCorpus in project ANNIS by korpling.
the class CorpusListPanel method getCorpusListFromServer.
private List<AnnisCorpus> getCorpusListFromServer() {
List<AnnisCorpus> result = new LinkedList<>();
try {
WebResource rootRes = Helper.getAnnisWebResource();
result = rootRes.path("query").path("corpora").get(new AnnisCorpusListType());
return result;
} catch (ClientHandlerException ex) {
log.error(null, ex);
Notification.show("Service not available: " + ex.getLocalizedMessage(), Notification.Type.TRAY_NOTIFICATION);
} catch (UniformInterfaceException ex) {
if (ex.getResponse().getStatus() == Response.Status.UNAUTHORIZED.getStatusCode()) {
Notification.show("You are not authorized to get the corpus list.", ex.getMessage(), Notification.Type.WARNING_MESSAGE);
} else if (ex.getResponse().getStatus() == Response.Status.FORBIDDEN.getStatusCode()) {
Notification.show("Your account has expired.", ex.getMessage(), Notification.Type.WARNING_MESSAGE);
return result;
} else {
log.error(null, ex);
if (!AnnisBaseUI.handleCommonError(ex, "get corpus list")) {
Notification.show("Remote exception: " + ex.getLocalizedMessage(), Notification.Type.TRAY_NOTIFICATION);
}
}
}
return null;
}
use of annis.service.objects.AnnisCorpus in project ANNIS by korpling.
the class TestListCorpusHelper method mapRow.
@Test
public void mapRow() throws SQLException {
// stub a result set to return a single row
ResultSet resultSet = mock(ResultSet.class);
when(resultSet.getLong("id")).thenReturn(ID1);
when(resultSet.getString("name")).thenReturn(NAME1);
when(resultSet.getInt("text")).thenReturn(TEXT_COUNT1);
when(resultSet.getInt("tokens")).thenReturn(TOKEN_COUNT1);
// call and test
AnnisCorpus annisCorpus = listCorpusHelper.mapRow(resultSet, 0);
assertThat(annisCorpus.getId(), is(ID1));
assertThat(annisCorpus.getName(), is(NAME1));
assertThat(annisCorpus.getTextCount(), is(TEXT_COUNT1));
assertThat(annisCorpus.getTokenCount(), is(TOKEN_COUNT1));
}
use of annis.service.objects.AnnisCorpus in project ANNIS by korpling.
the class QueryServiceImpl method singleCorpus.
@GET
@Path("corpora/{top}")
@Produces("application/xml")
public List<AnnisCorpus> singleCorpus(@PathParam("top") String toplevelName) {
List<AnnisCorpus> result = new ArrayList<>();
Subject user = SecurityUtils.getSubject();
LinkedList<String> originalCorpusNames = new LinkedList<>();
originalCorpusNames.add(toplevelName);
List<Long> ids = queryDao.mapCorpusNamesToIds(originalCorpusNames);
// also add all corpora that match the alias name
ids.addAll(queryDao.mapCorpusAliasToIds(toplevelName));
if (!ids.isEmpty()) {
List<AnnisCorpus> allCorpora = queryDao.listCorpora(ids);
for (AnnisCorpus c : allCorpora) {
if (user.isPermitted("query:show:" + c.getName())) {
result.add(c);
}
}
}
return result;
}
Aggregations