Search in sources :

Example 1 with UserGeneratedFrequencyEntry

use of annis.gui.frequency.UserGeneratedFrequencyEntry in project ANNIS by korpling.

the class QueryController method executeFrequency.

public void executeFrequency(FrequencyQueryPanel panel) {
    // kill old request
    Future freqFuture = state.getExecutedTasks().get(QueryUIState.QueryType.FREQUENCY);
    if (freqFuture != null && !freqFuture.isDone()) {
        freqFuture.cancel(true);
    }
    if ("".equals(state.getAql().getValue())) {
        Notification.show("Empty query", Notification.Type.WARNING_MESSAGE);
        panel.showQueryDefinitionPanel();
        return;
    } else if (state.getSelectedCorpora().getValue().isEmpty()) {
        Notification.show("Please select a corpus", Notification.Type.WARNING_MESSAGE);
        panel.showQueryDefinitionPanel();
        return;
    }
    BeanContainer<Integer, UserGeneratedFrequencyEntry> container = state.getFrequencyTableDefinition();
    FrequencyTableQuery freqDefinition = new FrequencyTableQuery();
    for (Integer id : container.getItemIds()) {
        UserGeneratedFrequencyEntry userGen = container.getItem(id).getBean();
        freqDefinition.add(userGen.toFrequencyTableEntry());
    }
    // additionally add meta data columns
    for (String m : state.getFrequencyMetaData().getValue()) {
        FrequencyTableEntry entry = new FrequencyTableEntry();
        entry.setType(FrequencyTableEntryType.meta);
        entry.setKey(m);
        freqDefinition.add(entry);
    }
    FrequencyQuery query = QueryGenerator.frequency().query(state.getAql().getValue()).corpora(state.getSelectedCorpora().getValue()).def(freqDefinition).build();
    addHistoryEntry(query);
    FrequencyBackgroundJob job = new FrequencyBackgroundJob(ui, query, panel);
    freqFuture = Background.call(job);
    state.getExecutedTasks().put(QueryUIState.QueryType.FREQUENCY, freqFuture);
}
Also used : FrequencyTableQuery(annis.service.objects.FrequencyTableQuery) FrequencyQuery(annis.gui.objects.FrequencyQuery) UserGeneratedFrequencyEntry(annis.gui.frequency.UserGeneratedFrequencyEntry) Future(java.util.concurrent.Future) FrequencyBackgroundJob(annis.gui.controller.FrequencyBackgroundJob) FrequencyTableEntry(annis.service.objects.FrequencyTableEntry)

Aggregations

FrequencyBackgroundJob (annis.gui.controller.FrequencyBackgroundJob)1 UserGeneratedFrequencyEntry (annis.gui.frequency.UserGeneratedFrequencyEntry)1 FrequencyQuery (annis.gui.objects.FrequencyQuery)1 FrequencyTableEntry (annis.service.objects.FrequencyTableEntry)1 FrequencyTableQuery (annis.service.objects.FrequencyTableQuery)1 Future (java.util.concurrent.Future)1