Search in sources :

Example 1 with QueryId

use of de.catma.queryengine.QueryId in project catma by forTEXT.

the class AnalyzeView method handleRefreshQueryResultPanel.

private void handleRefreshQueryResultPanel(RefreshQueryResultPanel refreshQueryResultPanel) {
    QueryId queryId = refreshQueryResultPanel.getQueryId();
    executeSearch(queryId.getQuery(), queryResultPanel -> resultsPanel.replaceComponent(refreshQueryResultPanel, queryResultPanel));
}
Also used : QueryId(de.catma.queryengine.QueryId)

Example 2 with QueryId

use of de.catma.queryengine.QueryId in project catma by forTEXT.

the class AnalyzeView method addDistViz.

private void addDistViz() {
    if (getQueryResultPanelSettings().isEmpty()) {
        Notification.show("Info", "Please query some data first!", Type.HUMANIZED_MESSAGE);
        return;
    }
    VegaPanel vegaPanel = new VegaPanel(eventBus, project, kwicProviderCache, () -> new QueryOptions(// TODO: ok?
    new QueryId(""), currentCorpus.getDocumentIds(), currentCorpus.getCollectionIds(), indexInfoSet.getUnseparableCharacterSequences(), indexInfoSet.getUserDefinedSeparatingCharacters(), indexInfoSet.getLocale(), project), new DistributionDisplaySettingHandler());
    String name = "Distribution Chart " + LocalDateTime.now().format(DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM));
    VizMaxPanel vizMaxPanel = new VizMaxPanel(name, vegaPanel, getQueryResultPanelSettings(), project, kwicProviderCache, closedVizMaxPanel -> setContent(contentPanel, closedVizMaxPanel));
    VizMinPanel vizMinPanel = new VizMinPanel(name, vizMaxPanel, toBeRemovedVizMinPanel -> vizCardsPanel.removeComponent(toBeRemovedVizMinPanel), () -> setContent(vizMaxPanel, contentPanel));
    vizCardsPanel.addComponentAsFirst(vizMinPanel);
    setContent(vizMaxPanel, contentPanel);
}
Also used : QueryId(de.catma.queryengine.QueryId) VegaPanel(de.catma.ui.module.analyze.visualization.vega.VegaPanel) DistributionDisplaySettingHandler(de.catma.ui.module.analyze.visualization.vega.DistributionDisplaySettingHandler) QueryOptions(de.catma.queryengine.QueryOptions)

Example 3 with QueryId

use of de.catma.queryengine.QueryId in project catma by forTEXT.

the class AnalyzeView method addWCViz.

private void addWCViz() {
    if (getQueryResultPanelSettings().isEmpty()) {
        Notification.show("Info", "Please query some data first!", Type.HUMANIZED_MESSAGE);
        return;
    }
    VegaPanel vegaPanel = new VegaPanel(eventBus, project, kwicProviderCache, () -> new QueryOptions(// TODO: ok?
    new QueryId(""), currentCorpus.getDocumentIds(), currentCorpus.getCollectionIds(), indexInfoSet.getUnseparableCharacterSequences(), indexInfoSet.getUserDefinedSeparatingCharacters(), indexInfoSet.getLocale(), project), new WordCloudDisplaySettingHandler());
    String name = "Wordcloud " + LocalDateTime.now().format(DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM));
    VizMaxPanel vizMaxPanel = new VizMaxPanel(name, vegaPanel, getQueryResultPanelSettings(), project, kwicProviderCache, closedVizMaxPanel -> setContent(contentPanel, closedVizMaxPanel));
    VizMinPanel vizMinPanel = new VizMinPanel(name, vizMaxPanel, toBeRemovedVizMinPanel -> vizCardsPanel.removeComponent(toBeRemovedVizMinPanel), () -> setContent(vizMaxPanel, contentPanel));
    vizCardsPanel.addComponentAsFirst(vizMinPanel);
    setContent(vizMaxPanel, contentPanel);
}
Also used : QueryId(de.catma.queryengine.QueryId) WordCloudDisplaySettingHandler(de.catma.ui.module.analyze.visualization.vega.WordCloudDisplaySettingHandler) VegaPanel(de.catma.ui.module.analyze.visualization.vega.VegaPanel) QueryOptions(de.catma.queryengine.QueryOptions)

Example 4 with QueryId

use of de.catma.queryengine.QueryId in project catma by forTEXT.

the class QueryResultPanel method initPropertiesAsColumnsTagBasedData.

void initPropertiesAsColumnsTagBasedData() {
    displaySetting = DisplaySetting.PROPERTIES_AS_COLUMNS;
    miGroupByTagPath.setEnabled(true);
    miGroupByPhrase.setEnabled(true);
    miFlatTable.setEnabled(true);
    miPropertiesAsColumns.setEnabled(false);
    treeGridPanel.removeAllComponents();
    initQueryResultGrid();
    TreeDataProvider<QueryResultRowItem> queryResultDataProvider = new TreeDataProvider<QueryResultRowItem>(getPropertiesAsColumnsTagBasedTreeData());
    queryResultDataProvider.addFilter(punctuationFilter);
    Column<QueryResultRowItem, ?> tagPathColumn = queryResultGrid.addColumn(QueryResultRowItem::getTagPath).setCaption("Tag Path").setWidth(200);
    if (includeQueryId) {
    // TODO: add a queryId column
    }
    queryResultGrid.addColumn(QueryResultRowItem::getKey).setCaption("Annotation").setDescriptionGenerator(item -> item.getDetailedKeyInContext(), ContentMode.HTML).setRenderer(new HtmlRenderer()).setId("annotation").setWidth(200);
    for (String propertyName : propertyNames) {
        queryResultGrid.addColumn(item -> item.getPropertyValue(propertyName)).setCaption(propertyName).setWidth(200);
    }
    queryResultGrid.addColumn(QueryResultRowItem::getDocumentName).setCaption("Document").setWidth(200);
    queryResultGrid.addColumn(QueryResultRowItem::getCollectionName).setCaption("Collection").setWidth(200);
    if (itemSelectionListener != null) {
        ButtonRenderer<QueryResultRowItem> selectItemsRenderer = new ButtonRenderer<QueryResultRowItem>(rendererClickEvent -> itemSelectionListener.itemSelected(rendererClickEvent.getItem()));
        selectItemsRenderer.setHtmlContentAllowed(true);
        queryResultGrid.addColumn((item) -> VaadinIcons.ARROW_CIRCLE_DOWN_O.getHtml()).setCaption("Select").setRenderer(selectItemsRenderer).setExpandRatio(1);
    }
    if (itemRemovedListener != null) {
        ButtonRenderer<QueryResultRowItem> removeItemsRenderer = new ButtonRenderer<QueryResultRowItem>(rendererClickEvent -> itemRemovedListener.itemRemoved(rendererClickEvent.getItem()));
        removeItemsRenderer.setHtmlContentAllowed(true);
        queryResultGrid.addColumn((item) -> VaadinIcons.ERASER.getHtml()).setCaption("Remove").setRenderer(removeItemsRenderer).setExpandRatio(1);
    }
    FooterRow footer = queryResultGrid.prependFooterRow();
    queryResultGrid.setFooterVisible(true);
    queryResultDataProvider.addDataProviderListener(event -> handleTotalTypesChange(null, null, "Annotations", footer.getCell("annotation"), queryResultDataProvider));
    queryResultGrid.setDataProvider(queryResultDataProvider);
    handleTotalTypesChange(null, null, "Annotations", footer.getCell("annotation"), queryResultDataProvider);
    treeGridPanel.addComponent(queryResultGrid);
    if (queryResultDataProvider.getTreeData().getRootItems().size() == 0) {
        Notification.show("Info", "Your query result does not contain annotated occurrences!", Type.HUMANIZED_MESSAGE);
    }
    queryResultGrid.setSortOrder(new GridSortOrderBuilder<QueryResultRowItem>().thenAsc(tagPathColumn).build());
    initInfoLabel();
    fireDisplaySettingChanged();
}
Also used : BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) GroupedQueryResult(de.catma.queryengine.result.GroupedQueryResult) GridSortOrderBuilder(com.vaadin.data.provider.GridSortOrderBuilder) MenuItem(com.vaadin.ui.MenuBar.MenuItem) LoadingCache(com.google.common.cache.LoadingCache) SelectionListener(com.vaadin.event.selection.SelectionListener) TextField(com.vaadin.ui.TextField) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) FooterRow(com.vaadin.ui.components.grid.FooterRow) QueryResultRowArray(de.catma.queryengine.result.QueryResultRowArray) KwicProvider(de.catma.indexer.KwicProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Map(java.util.Map) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) TagQueryResultRow(de.catma.queryengine.result.TagQueryResultRow) VaadinIcons(com.vaadin.icons.VaadinIcons) QueryId(de.catma.queryengine.QueryId) IconButton(de.catma.ui.component.IconButton) Set(java.util.Set) TreeGrid(com.vaadin.ui.TreeGrid) AnnotatedTextProvider(de.catma.ui.module.annotate.annotationpanel.AnnotatedTextProvider) Collectors(java.util.stream.Collectors) BinaryOperator(java.util.function.BinaryOperator) List(java.util.List) Type(com.vaadin.ui.Notification.Type) TagDefinition(de.catma.tag.TagDefinition) ExpandEvent(com.vaadin.event.ExpandEvent) StreamResource(com.vaadin.server.StreamResource) ClickListener(com.vaadin.ui.Button.ClickListener) Column(com.vaadin.ui.Grid.Column) VerticalLayout(com.vaadin.ui.VerticalLayout) LocalDateTime(java.time.LocalDateTime) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Registration(com.vaadin.shared.Registration) Notification(com.vaadin.ui.Notification) TreeGridFactory(de.catma.ui.component.TreeGridFactory) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) WeakReference(java.lang.ref.WeakReference) CSVExportGroupedStreamSource(de.catma.ui.module.analyze.CSVExportGroupedStreamSource) InMemoryDataProvider(com.vaadin.data.provider.InMemoryDataProvider) ContentMode(com.vaadin.shared.ui.ContentMode) QueryResult(de.catma.queryengine.result.QueryResult) Iterator(java.util.Iterator) TreeData(com.vaadin.data.TreeData) ClickEvent(com.vaadin.ui.Button.ClickEvent) Project(de.catma.project.Project) Command(com.vaadin.ui.MenuBar.Command) QueryResultRow(de.catma.queryengine.result.QueryResultRow) ContextMenu(com.vaadin.contextmenu.ContextMenu) FooterCell(com.vaadin.ui.components.grid.FooterCell) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) DateTimeFormatter(java.time.format.DateTimeFormatter) FileDownloader(com.vaadin.server.FileDownloader) SerializablePredicate(com.vaadin.server.SerializablePredicate) HierarchicalQuery(com.vaadin.data.provider.HierarchicalQuery) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) CSVExportFlatStreamSource(de.catma.ui.module.analyze.CSVExportFlatStreamSource) Component(com.vaadin.ui.Component) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) FooterRow(com.vaadin.ui.components.grid.FooterRow) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer)

Example 5 with QueryId

use of de.catma.queryengine.QueryId in project catma by forTEXT.

the class QueryResultPanel method initFlatTagBasedData.

void initFlatTagBasedData() {
    displaySetting = DisplaySetting.ANNOTATIONS_AS_FLAT_TABLE;
    miGroupByTagPath.setEnabled(true);
    miGroupByPhrase.setEnabled(true);
    miFlatTable.setEnabled(false);
    miPropertiesAsColumns.setEnabled(true);
    treeGridPanel.removeAllComponents();
    initQueryResultGrid();
    TreeDataProvider<QueryResultRowItem> queryResultDataProvider = new TreeDataProvider<QueryResultRowItem>(getFlatTagBasedTreeData());
    queryResultDataProvider.addFilter(punctuationFilter);
    Column<QueryResultRowItem, ?> tagPathColumn = queryResultGrid.addColumn(QueryResultRowItem::getTagPath).setCaption("Tag Path").setDescriptionGenerator(item -> item.getDetailedKeyInContext(), ContentMode.HTML).setWidth(200);
    if (includeQueryId) {
    // TODO: add a queryId column
    }
    queryResultGrid.addColumn(QueryResultRowItem::getDocumentName).setCaption("Document").setWidth(200);
    queryResultGrid.addColumn(QueryResultRowItem::getCollectionName).setCaption("Collection").setWidth(200);
    queryResultGrid.addColumn(QueryResultRowItem::getKey).setCaption("Annotation").setId("annotation").setRenderer(new HtmlRenderer()).setWidth(200);
    if (resultContainsProperties) {
        queryResultGrid.addColumn(QueryResultRowItem::getPropertyName).setCaption("Property").setWidth(100);
        queryResultGrid.addColumn(QueryResultRowItem::getPropertyValue).setId("propertyvalue").setCaption("Property Value").setWidth(300);
    }
    if (itemSelectionListener != null) {
        ButtonRenderer<QueryResultRowItem> selectItemsRenderer = new ButtonRenderer<QueryResultRowItem>(rendererClickEvent -> itemSelectionListener.itemSelected(rendererClickEvent.getItem()));
        selectItemsRenderer.setHtmlContentAllowed(true);
        queryResultGrid.addColumn((item) -> VaadinIcons.ARROW_CIRCLE_DOWN_O.getHtml()).setCaption("Select").setRenderer(selectItemsRenderer).setExpandRatio(1);
    }
    if (itemRemovedListener != null) {
        ButtonRenderer<QueryResultRowItem> removeItemsRenderer = new ButtonRenderer<QueryResultRowItem>(rendererClickEvent -> itemRemovedListener.itemRemoved(rendererClickEvent.getItem()));
        removeItemsRenderer.setHtmlContentAllowed(true);
        queryResultGrid.addColumn((item) -> VaadinIcons.ERASER.getHtml()).setCaption("Remove").setRenderer(removeItemsRenderer).setExpandRatio(1);
    }
    queryResultGrid.setDataProvider(queryResultDataProvider);
    FooterRow footer = queryResultGrid.prependFooterRow();
    queryResultGrid.setFooterVisible(true);
    if (resultContainsProperties) {
        queryResultDataProvider.addDataProviderListener(event -> handleTotalTypesChange(null, null, "Property Values", footer.getCell("propertyvalue"), queryResultDataProvider));
        handleTotalTypesChange(null, null, "Property Values", footer.getCell("propertyvalue"), queryResultDataProvider);
    } else {
        queryResultDataProvider.addDataProviderListener(event -> handleTotalTypesChange(null, null, "Annotations", footer.getCell("annotation"), queryResultDataProvider));
        handleTotalTypesChange(null, null, "Annotations", footer.getCell("annotation"), queryResultDataProvider);
    }
    treeGridPanel.addComponent(queryResultGrid);
    if (queryResultDataProvider.getTreeData().getRootItems().size() == 0) {
        Notification.show("Info", "Your query result does not contain annotated occurrences!", Type.HUMANIZED_MESSAGE);
    }
    queryResultGrid.setSortOrder(new GridSortOrderBuilder<QueryResultRowItem>().thenAsc(tagPathColumn).build());
    initInfoLabel();
    fireDisplaySettingChanged();
}
Also used : BackgroundServiceProvider(de.catma.backgroundservice.BackgroundServiceProvider) GroupedQueryResult(de.catma.queryengine.result.GroupedQueryResult) GridSortOrderBuilder(com.vaadin.data.provider.GridSortOrderBuilder) MenuItem(com.vaadin.ui.MenuBar.MenuItem) LoadingCache(com.google.common.cache.LoadingCache) SelectionListener(com.vaadin.event.selection.SelectionListener) TextField(com.vaadin.ui.TextField) Alignment(com.vaadin.ui.Alignment) UI(com.vaadin.ui.UI) FooterRow(com.vaadin.ui.components.grid.FooterRow) QueryResultRowArray(de.catma.queryengine.result.QueryResultRowArray) KwicProvider(de.catma.indexer.KwicProvider) ErrorHandler(de.catma.ui.module.main.ErrorHandler) Map(java.util.Map) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) TagQueryResultRow(de.catma.queryengine.result.TagQueryResultRow) VaadinIcons(com.vaadin.icons.VaadinIcons) QueryId(de.catma.queryengine.QueryId) IconButton(de.catma.ui.component.IconButton) Set(java.util.Set) TreeGrid(com.vaadin.ui.TreeGrid) AnnotatedTextProvider(de.catma.ui.module.annotate.annotationpanel.AnnotatedTextProvider) Collectors(java.util.stream.Collectors) BinaryOperator(java.util.function.BinaryOperator) List(java.util.List) Type(com.vaadin.ui.Notification.Type) TagDefinition(de.catma.tag.TagDefinition) ExpandEvent(com.vaadin.event.ExpandEvent) StreamResource(com.vaadin.server.StreamResource) ClickListener(com.vaadin.ui.Button.ClickListener) Column(com.vaadin.ui.Grid.Column) VerticalLayout(com.vaadin.ui.VerticalLayout) LocalDateTime(java.time.LocalDateTime) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Registration(com.vaadin.shared.Registration) Notification(com.vaadin.ui.Notification) TreeGridFactory(de.catma.ui.component.TreeGridFactory) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer) WeakReference(java.lang.ref.WeakReference) CSVExportGroupedStreamSource(de.catma.ui.module.analyze.CSVExportGroupedStreamSource) InMemoryDataProvider(com.vaadin.data.provider.InMemoryDataProvider) ContentMode(com.vaadin.shared.ui.ContentMode) QueryResult(de.catma.queryengine.result.QueryResult) Iterator(java.util.Iterator) TreeData(com.vaadin.data.TreeData) ClickEvent(com.vaadin.ui.Button.ClickEvent) Project(de.catma.project.Project) Command(com.vaadin.ui.MenuBar.Command) QueryResultRow(de.catma.queryengine.result.QueryResultRow) ContextMenu(com.vaadin.contextmenu.ContextMenu) FooterCell(com.vaadin.ui.components.grid.FooterCell) Button(com.vaadin.ui.Button) HorizontalLayout(com.vaadin.ui.HorizontalLayout) DateTimeFormatter(java.time.format.DateTimeFormatter) FileDownloader(com.vaadin.server.FileDownloader) SerializablePredicate(com.vaadin.server.SerializablePredicate) HierarchicalQuery(com.vaadin.data.provider.HierarchicalQuery) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) CSVExportFlatStreamSource(de.catma.ui.module.analyze.CSVExportFlatStreamSource) Component(com.vaadin.ui.Component) TreeDataProvider(com.vaadin.data.provider.TreeDataProvider) HtmlRenderer(com.vaadin.ui.renderers.HtmlRenderer) FooterRow(com.vaadin.ui.components.grid.FooterRow) ButtonRenderer(com.vaadin.ui.renderers.ButtonRenderer)

Aggregations

QueryId (de.catma.queryengine.QueryId)6 LoadingCache (com.google.common.cache.LoadingCache)3 VaadinIcons (com.vaadin.icons.VaadinIcons)3 Alignment (com.vaadin.ui.Alignment)3 Button (com.vaadin.ui.Button)3 Component (com.vaadin.ui.Component)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)3 Notification (com.vaadin.ui.Notification)3 Type (com.vaadin.ui.Notification.Type)3 UI (com.vaadin.ui.UI)3 VerticalLayout (com.vaadin.ui.VerticalLayout)3 BackgroundServiceProvider (de.catma.backgroundservice.BackgroundServiceProvider)3 KwicProvider (de.catma.indexer.KwicProvider)3 QueryResult (de.catma.queryengine.result.QueryResult)3 IconButton (de.catma.ui.component.IconButton)3 ErrorHandler (de.catma.ui.module.main.ErrorHandler)3 LocalDateTime (java.time.LocalDateTime)3 DateTimeFormatter (java.time.format.DateTimeFormatter)3 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3