use of io.github.vocabhunter.analysis.core.VocabHunterException in project VocabHunter by VocabHunter.
the class SelectionExportTool method exportSelection.
public static void exportSelection(final SessionState state, final Path file) {
try {
List<String> words = state.getOrderedUses().stream().filter(sessionWord -> sessionWord.getState().equals(WordState.UNKNOWN)).map(SessionWord::getWordIdentifier).collect(Collectors.toList());
Files.write(file, words);
} catch (final IOException e) {
throw new VocabHunterException(String.format("Unable to export to file '%s", file), e);
}
}
use of io.github.vocabhunter.analysis.core.VocabHunterException in project VocabHunter by VocabHunter.
the class SessionController method updateWordList.
private void updateWordList() {
boolean isEditable = sessionModel.isEditable();
FilterSettings filterSettings = sessionModel.getFilterSettings();
boolean isFilterEnabled = sessionModel.isEnableFilters();
VocabHunterException exception;
boolean isFilterSuccess;
try {
WordFilter filter = filterSettingsTool.filter(filterSettings, isFilterEnabled);
MarkTool<WordModel> markTool = new MarkTool<>(filter, sessionModel.getAllWords());
isFilterSuccess = markTool.isValidFilter();
if (isFilterSuccess) {
sessionModel.updateWordList(isEditable, markTool);
wordListHandler.selectClosestWord(isEditable, filter);
}
exception = null;
} catch (final VocabHunterException e) {
LOG.error("Failed to activate filter", e);
exception = e;
isFilterSuccess = false;
}
if (!isFilterSuccess) {
processFilterFailure(exception);
}
}
use of io.github.vocabhunter.analysis.core.VocabHunterException in project VocabHunter by VocabHunter.
the class FilterFileModelTranslatorImpl method fromModel.
@Override
public BaseListedFile fromModel(final FilterFileModel model) {
FilterFileMode mode = model.getMode();
Path file = model.getFile();
switch(mode) {
case SESSION_KNOWN:
return new SessionListedFile(file, false);
case SESSION_SEEN:
return new SessionListedFile(file, true);
case EXCEL:
return new ExcelListedFile(file, model.getColumns());
case DOCUMENT:
return new DocumentListedFile(file);
default:
throw new VocabHunterException("Unsupported mode " + mode);
}
}
Aggregations