private JCas getJCas(AnnotatorState aState, AnnotationDocument aDocument) throws IOException { if (aState.getMode().equals(Mode.AUTOMATION) || aState.getMode().equals(Mode.CORRECTION)) { return correctionDocumentService.readCorrectionCas(aState.getDocument()); } else { return documentService.readAnnotationCas(aDocument); } }
private List<AnnotationLayer> getLayersToRender() { AnnotatorState state = getModelObject(); List<AnnotationLayer> layersToRender = new ArrayList<>(); for (AnnotationLayer layer : state.getAnnotationLayers()) { boolean isSegmentationLayer = layer.getName().equals(Token.class.getName()) || layer.getName().equals(Sentence.class.getName()); boolean isUnsupportedLayer = layer.getType().equals(CHAIN_TYPE) && (state.getMode().equals(Mode.AUTOMATION) || state.getMode().equals(Mode.CORRECTION) || state.getMode().equals(Mode.CURATION)); if (layer.isEnabled() && !isSegmentationLayer && !isUnsupportedLayer) { layersToRender.add(layer); } } return layersToRender; }
private List<AnnotationLayer> getLayersToRender() { AnnotatorState state = getModelObject(); List<AnnotationLayer> layersToRender = new ArrayList<>(); for (AnnotationLayer layer : state.getAnnotationLayers()) { boolean isSegmentationLayer = layer.getName().equals(Token.class.getName()) || layer.getName().equals(Sentence.class.getName()); boolean isUnsupportedLayer = layer.getType().equals(CHAIN_TYPE) && (state.getMode().equals(Mode.AUTOMATION) || state.getMode().equals(Mode.CORRECTION) || state.getMode().equals(Mode.CURATION)); if (layer.isEnabled() && !isSegmentationLayer && !isUnsupportedLayer) { layersToRender.add(layer); } } return layersToRender; } }
private List<AnnotationLayer> getLayersToRender() { AnnotatorState state = getModelObject(); List<AnnotationLayer> layersToRender = new ArrayList<>(); for (AnnotationLayer layer : state.getAnnotationLayers()) { boolean isSegmentationLayer = layer.getName().equals(Token.class.getName()) || layer.getName().equals(Sentence.class.getName()); boolean isUnsupportedLayer = layer.getType().equals(CHAIN_TYPE) && (state.getMode().equals(Mode.AUTOMATION) || state.getMode().equals(Mode.CORRECTION) || state.getMode().equals(Mode.CURATION)); if (layer.isEnabled() && !isSegmentationLayer && !isUnsupportedLayer) { layersToRender.add(layer); } } return layersToRender; }
private JCas getJCas(AnnotatorState aState, AnnotationDocument aDocument) throws IOException { if (aState.getMode().equals(Mode.AUTOMATION) || aState.getMode().equals(Mode.CORRECTION)) { return correctionDocumentService.readCorrectionCas(aState.getDocument()); } else { return documentService.readAnnotationCas(aDocument); } }
private List<AnnotationLayer> getLayersToRender() { AnnotatorState state = getModelObject(); List<AnnotationLayer> layersToRender = new ArrayList<>(); for (AnnotationLayer layer : state.getAnnotationLayers()) { boolean isSegmentationLayer = layer.getName().equals(Token.class.getName()) || layer.getName().equals(Sentence.class.getName()); boolean isUnsupportedLayer = layer.getType().equals(CHAIN_TYPE) && (state.getMode().equals(Mode.AUTOMATION) || state.getMode().equals(Mode.CORRECTION) || state.getMode().equals(Mode.CURATION)); if (layer.isEnabled() && !isSegmentationLayer && !isUnsupportedLayer) { layersToRender.add(layer); } } return layersToRender; } }
public static void savePreference(UserPreferencesService aPrefService, AnnotatorState aState, String aUsername) throws IOException { aPrefService.savePreferences(aState.getProject(), aUsername, aState.getMode(), aState.getPreferences()); } }
private FileResourceStream export() { File downloadFile = null; String username = state.getObject().getMode() .equals(Mode.AUTOMATION) && preferences.getObject().documentType .equals(SELECTEXPORT.AUTOMATED.toString()) ? "CORRECTION_USER" : SecurityContextHolder.getContext().getAuthentication() .getName(); try { downloadFile = importExportService.exportAnnotationDocument( state.getObject().getDocument(), username, importExportService.getFormatByName(preferences.getObject().format) .get(), state.getObject().getDocument().getName(), state.getObject().getMode()); } catch (Exception e) { LOG.error("Export failed", e); error("Export failed:" + ExceptionUtils.getRootCauseMessage(e)); // This will cause the open dialog to pop up again, but at least // the error feedback message will be visible. With the // RestartResponseException the feedback message only flashes. throw new NonResettingRestartException(getPage().getPageClass()); } return new FileResourceStream(downloadFile); }
if (state.getMode().equals(Mode.CURATION)) { diff = CasDiff2.doDiffSingle(annotationService, state.getProject(), entryTypes, LinkCompareBehavior.LINK_ROLE_AS_LABEL, jCases, addSuggestionColor(state.getProject(), state.getMode(), jCases, annoStates, d, false, false); addSuggestionColor(state.getProject(), state.getMode(), jCases, annoStates, i, true, false); all.removeAll(i); addSuggestionColor(state.getProject(), state.getMode(), jCases, annoStates, all, false, true); return annoStates;
private void writeEditorCas(AnnotatorState aState, JCas aJCas) throws IOException { if (aState.getMode().equals(Mode.ANNOTATION) || aState.getMode().equals(Mode.AUTOMATION) || aState.getMode().equals(Mode.CORRECTION)) { documentService.writeAnnotationCas(aJCas, aState.getDocument(), aState.getUser(), true); updateDocumentTimestampAfterWrite(aState, documentService.getAnnotationCasTimestamp( aState.getDocument(), aState.getUser().getUsername())); } else if (aState.getMode().equals(Mode.CURATION)) { curationDocumentService.writeCurationCas(aJCas, aState.getDocument(), true); updateDocumentTimestampAfterWrite(aState, curationDocumentService .getCurationCasTimestamp(aState.getDocument())); } }
public void writeEditorCas(JCas aJCas) throws IOException { AnnotatorState state = getModelObject(); if (state.getMode().equals(Mode.ANNOTATION) || state.getMode().equals(Mode.AUTOMATION) || state.getMode().equals(Mode.CORRECTION)) { documentService.writeAnnotationCas(aJCas, state.getDocument(), state.getUser(), true); // Update timestamp in state Optional<Long> diskTimestamp = documentService .getAnnotationCasTimestamp(state.getDocument(), state.getUser().getUsername()); if (diskTimestamp.isPresent()) { state.setAnnotationDocumentTimestamp(diskTimestamp.get()); } } else if (state.getMode().equals(Mode.CURATION)) { curationDocumentService.writeCurationCas(aJCas, state.getDocument(), true); // Update timestamp in state Optional<Long> diskTimestamp = curationDocumentService .getCurationCasTimestamp(state.getDocument()); if (diskTimestamp.isPresent()) { state.setAnnotationDocumentTimestamp(diskTimestamp.get()); } } }
private void writeEditorCas(AnnotatorState aState, JCas aJCas) throws IOException { if (aState.getMode().equals(Mode.ANNOTATION) || aState.getMode().equals(Mode.AUTOMATION) || aState.getMode().equals(Mode.CORRECTION)) { documentService.writeAnnotationCas(aJCas, aState.getDocument(), aState.getUser(), true); updateDocumentTimestampAfterWrite(aState, documentService.getAnnotationCasTimestamp( aState.getDocument(), aState.getUser().getUsername())); } else if (aState.getMode().equals(Mode.CURATION)) { curationDocumentService.writeCurationCas(aJCas, aState.getDocument(), true); updateDocumentTimestampAfterWrite(aState, curationDocumentService .getCurationCasTimestamp(aState.getDocument())); } }
private void actionCancel(AjaxRequestTarget aTarget) { projectSelectionForm.detach(); documentSelectionForm.detach(); if (Mode.CURATION.equals(state.getMode())) { state.setDocument(null, null); // on cancel, go welcomePage } onCancel(aTarget); modalWindow.close(aTarget); }
boolean isAnnotationFinished() { AnnotatorState state = getModelObject(); if (state.getMode().equals(Mode.CURATION)) { return state.getDocument().getState().equals(SourceDocumentState.CURATION_FINISHED); } else { return documentService.isAnnotationFinished(state.getDocument(), state.getUser()); } }
private void mergeSpan(IRequestParameters aRequest, UserAnnotationSegment aCurationUserSegment, JCas aJcas) throws AnnotationException, UIMAException, ClassNotFoundException, IOException { AnnotationDocument clickedAnnotationDocument; AnnotatorState state = aCurationUserSegment.getAnnotatorState(); if (state.getMode().equals(Mode.AUTOMATION) || state.getMode().equals(Mode.CORRECTION)) { // createSpan / getJCas do not require an annotation document in this mode clickedAnnotationDocument = null; } else { SourceDocument sourceDocument = aCurationUserSegment.getAnnotatorState().getDocument(); clickedAnnotationDocument = documentService.getAnnotationDocument(sourceDocument, aCurationUserSegment.getUsername()); } int address = aRequest.getParameterValue(PARAM_ID).toInt(); String spanType = removePrefix(aRequest.getParameterValue(PARAM_TYPE).toString()); createSpan(spanType, state, aJcas, clickedAnnotationDocument, address); }
private void mergeSpan(IRequestParameters aRequest, UserAnnotationSegment aCurationUserSegment, JCas aJcas) throws AnnotationException, UIMAException, ClassNotFoundException, IOException { AnnotationDocument clickedAnnotationDocument; AnnotatorState state = aCurationUserSegment.getAnnotatorState(); if (state.getMode().equals(Mode.AUTOMATION) || state.getMode().equals(Mode.CORRECTION)) { // createSpan / getJCas do not require an annotation document in this mode clickedAnnotationDocument = null; } else { SourceDocument sourceDocument = aCurationUserSegment.getAnnotatorState().getDocument(); clickedAnnotationDocument = documentService.getAnnotationDocument(sourceDocument, aCurationUserSegment.getUsername()); } int address = aRequest.getParameterValue(PARAM_ID).toInt(); String spanType = removePrefix(aRequest.getParameterValue(PARAM_TYPE).toString()); createSpan(spanType, state, aJcas, clickedAnnotationDocument, address); }
Model.of(SELECTEXPORT.ANNOTATED.toString()), Arrays.asList( SELECTEXPORT.ANNOTATED.toString(), SELECTEXPORT.AUTOMATED.toString())); documentType.setVisible(state.getObject().getMode().equals(Mode.AUTOMATION)); form.add(documentType);
public static boolean isDocumentFinished(DocumentService aRepository, AnnotatorState aBratAnnotatorModel) { try { if (aBratAnnotatorModel.getMode().equals(Mode.CURATION)) { // Load document freshly from DB so we get the latest state. The document state // in the annotator state might be stale. SourceDocument doc = aRepository.getSourceDocument( aBratAnnotatorModel.getDocument().getProject().getId(), aBratAnnotatorModel.getDocument().getId()); return doc.getState().equals(SourceDocumentState.CURATION_FINISHED); } else { // if annotationDocument is finished, disable editing AnnotationDocument adoc = aRepository.getAnnotationDocument( aBratAnnotatorModel.getDocument(), aBratAnnotatorModel.getUser()); return adoc.getState().equals(AnnotationDocumentState.FINISHED); } } catch (Exception e) { return false; } }
public static boolean isDocumentFinished(DocumentService aRepository, AnnotatorState aBratAnnotatorModel) { try { if (aBratAnnotatorModel.getMode().equals(Mode.CURATION)) { // Load document freshly from DB so we get the latest state. The document state // in the annotator state might be stale. SourceDocument doc = aRepository.getSourceDocument( aBratAnnotatorModel.getDocument().getProject().getId(), aBratAnnotatorModel.getDocument().getId()); return doc.getState().equals(SourceDocumentState.CURATION_FINISHED); } else { // if annotationDocument is finished, disable editing AnnotationDocument adoc = aRepository.getAnnotationDocument( aBratAnnotatorModel.getDocument(), aBratAnnotatorModel.getUser()); return adoc.getState().equals(AnnotationDocumentState.FINISHED); } } catch (Exception e) { return false; } }