/** * change the state of an annotation document. used to re-open closed documents */ private void changeAnnotationDocumentState(SourceDocument aSourceDocument, User aUser, AnnotationDocumentStateTransition aAnnotationDocumentStateTransition) { AnnotationDocument annotationDocument = documentService .getAnnotationDocument(aSourceDocument, aUser); documentService.transitionAnnotationDocumentState(annotationDocument, aAnnotationDocumentStateTransition); } }
private Map<String, JCas> listJcasesforCorrection(AnnotationDocument randomAnnotationDocument, SourceDocument aDocument, Mode aMode) throws UIMAException, ClassNotFoundException, IOException { Map<String, JCas> jCases = new HashMap<>(); User user = userRepository .get(SecurityContextHolder.getContext().getAuthentication().getName()); randomAnnotationDocument = documentService.getAnnotationDocument(aDocument, user); // Upgrading should be an explicit action during the opening of a document at the end // of the open dialog - it must not happen during editing because the CAS addresses // are used as IDs in the UI // repository.upgradeCasAndSave(aDocument, aMode, user.getUsername()); JCas jCas = documentService.readAnnotationCas(randomAnnotationDocument); jCases.put(user.getUsername(), jCas); return jCases; }
private Map<String, JCas> listJcasesforCorrection(AnnotationDocument randomAnnotationDocument, SourceDocument aDocument, Mode aMode) throws UIMAException, ClassNotFoundException, IOException { Map<String, JCas> jCases = new HashMap<>(); User user = userRepository .get(SecurityContextHolder.getContext().getAuthentication().getName()); randomAnnotationDocument = documentService.getAnnotationDocument(aDocument, user); // Upgrading should be an explicit action during the opening of a document at the end // of the open dialog - it must not happen during editing because the CAS addresses // are used as IDs in the UI // repository.upgradeCasAndSave(aDocument, aMode, user.getUsername()); JCas jCas = documentService.readAnnotationCas(randomAnnotationDocument); jCases.put(user.getUsername(), jCas); return jCases; }
public static boolean isFinished(final IModel<AnnotatorState> aModel, User user, DocumentService aRepository) { return aRepository.existsAnnotationDocument(aModel.getObject().getDocument(), user) && aRepository.getAnnotationDocument(aModel.getObject().getDocument(), user) .getState().equals(AnnotationDocumentState.FINISHED); } }
private Map<String, Integer> getPercentageOfFinishedDocumentsPerUser(Project aProject) { Map<String, Integer> annotatorsProgress = new HashMap<>(); if (aProject != null) { for (User user : projectService.listProjectUsersWithPermissions(aProject, PermissionLevel.ANNOTATOR)) { int finished = 0; int ignored = 0; int totalDocs = 0; List<SourceDocument> documents = documentService.listSourceDocuments(aProject); for (SourceDocument document : documents) { totalDocs++; if (documentService.isAnnotationFinished(document, user)) { finished++; } else if (documentService.existsAnnotationDocument(document, user)) { AnnotationDocument annotationDocument = documentService .getAnnotationDocument(document, user); if (annotationDocument.getState().equals(AnnotationDocumentState.IGNORE)) { ignored++; } } } annotatorsProgress.put(user.getUsername(), (int) Math.round((double) (finished * 100) / (totalDocs - ignored))); } } return annotatorsProgress; }
throws UIMAException, ClassNotFoundException, IOException, AnnotationException AnnotationDocument annoDoc = aDocumentService.getAnnotationDocument(aBModel.getDocument(), aBModel.getUser()); JCas annoCas = aDocumentService.readAnnotationCas(annoDoc);
throws UIMAException, ClassNotFoundException, IOException, AnnotationException AnnotationDocument annoDoc = aDocumentService.getAnnotationDocument(aBModel.getDocument(), aBModel.getUser()); JCas annoCas = aDocumentService.readAnnotationCas(annoDoc);
public void upgradeCasAndSave(SourceDocument aDocument, String aUsername) throws IOException { User user = userRepository.get(aUsername); if (documentService.existsAnnotationDocument(aDocument, user)) { AnnotationDocument annotationDocument = documentService.getAnnotationDocument(aDocument, user); try { CAS cas = documentService.readAnnotationCas(annotationDocument).getCas(); annotationService.upgradeCas(cas, annotationDocument); documentService.writeAnnotationCas(cas.getJCas(), annotationDocument, false); } catch (Exception e) { // no need to catch, it is acceptable that no curation document // exists to be upgraded while there are annotation documents } } }
private AnnotationDocument getAnnotation(SourceDocument aDocument, String aUser, boolean aCreateIfMissing) throws ObjectNotFoundException { try { if (aCreateIfMissing) { return documentService.createOrGetAnnotationDocument(aDocument, getUser(aUser)); } else { return documentService.getAnnotationDocument(aDocument, getUser(aUser)); } } catch (NoResultException e) { throw new ObjectNotFoundException( "Annotation for user [" + aUser + "] on document [" + aDocument.getId() + "] in project [" + aDocument.getProject().getId() + "] not found."); } }
private AnnotationDocument getAnnotation(SourceDocument aDocument, String aUser, boolean aCreateIfMissing) throws ObjectNotFoundException { try { if (aCreateIfMissing) { return documentService.createOrGetAnnotationDocument(aDocument, getUser(aUser)); } else { return documentService.getAnnotationDocument(aDocument, getUser(aUser)); } } catch (NoResultException e) { throw new ObjectNotFoundException( "Annotation for user [" + aUser + "] on document [" + aDocument.getId() + "] in project [" + aDocument.getProject().getId() + "] not found."); } }
public void upgradeCasAndSave(SourceDocument aDocument, String aUsername) throws IOException { User user = userRepository.get(aUsername); if (documentService.existsAnnotationDocument(aDocument, user)) { AnnotationDocument annotationDocument = documentService.getAnnotationDocument(aDocument, user); try { CAS cas = documentService.readAnnotationCas(annotationDocument).getCas(); annotationService.upgradeCas(cas, annotationDocument); documentService.writeAnnotationCas(cas.getJCas(), annotationDocument, false); } catch (Exception e) { // no need to catch, it is acceptable that no curation document // exists to be upgraded while there are annotation documents } } }
throws UIMAException, ClassNotFoundException, IOException, AnnotationException AnnotationDocument annoDoc = aDocumentService.getAnnotationDocument(aState.getDocument(), aState.getUser()); JCas annoCas = aDocumentService.readAnnotationCas(annoDoc);
private void actionFinishDocument(AjaxRequestTarget aTarget) { finishDocumentDialog.setConfirmAction((aCallbackTarget) -> { actionValidateDocument(aCallbackTarget, getEditorCas()); AnnotatorState state = getModelObject(); AnnotationDocument annotationDocument = documentService.getAnnotationDocument( state.getDocument(), state.getUser()); documentService.transitionAnnotationDocumentState(annotationDocument, ANNOTATION_IN_PROGRESS_TO_ANNOTATION_FINISHED); aCallbackTarget.add(finishDocumentIcon); aCallbackTarget.add(finishDocumentLink); aCallbackTarget.add(detailEditor); aCallbackTarget.add(createOrGetResetDocumentLink()); }); finishDocumentDialog.show(aTarget); }
private void actionFinishDocument(AjaxRequestTarget aTarget) { finishDocumentDialog.setConfirmAction((aCallbackTarget) -> { actionValidateDocument(aCallbackTarget, getEditorCas()); AnnotatorState state = getModelObject(); AnnotationDocument annotationDocument = documentService.getAnnotationDocument( state.getDocument(), state.getUser()); documentService.transitionAnnotationDocumentState(annotationDocument, ANNOTATION_IN_PROGRESS_TO_ANNOTATION_FINISHED); aCallbackTarget.add(finishDocumentIcon); aCallbackTarget.add(finishDocumentLink); aCallbackTarget.add(detailEditor); aCallbackTarget.add(createOrGetResetDocumentLink()); }); finishDocumentDialog.show(aTarget); }
private void actionFinishDocument(AjaxRequestTarget aTarget) { finishDocumentDialog.setConfirmAction((aCallbackTarget) -> { actionValidateDocument(aCallbackTarget, getEditorCas()); AnnotatorState state = getModelObject(); AnnotationDocument annotationDocument = documentService.getAnnotationDocument( state.getDocument(), state.getUser()); documentService.transitionAnnotationDocumentState(annotationDocument, ANNOTATION_IN_PROGRESS_TO_ANNOTATION_FINISHED); aCallbackTarget.add(finishDocumentIcon); aCallbackTarget.add(finishDocumentLink); aCallbackTarget.add(detailEditor); aCallbackTarget.add(createOrGetResetDocumentLink()); }); finishDocumentDialog.show(aTarget); }
private void actionFinishDocument(AjaxRequestTarget aTarget) { finishDocumentDialog.setConfirmAction((aCallbackTarget) -> { actionValidateDocument(aCallbackTarget, getEditorCas()); AnnotatorState state = getModelObject(); AnnotationDocument annotationDocument = documentService.getAnnotationDocument( state.getDocument(), state.getUser()); documentService.transitionAnnotationDocumentState(annotationDocument, ANNOTATION_IN_PROGRESS_TO_ANNOTATION_FINISHED); // manually update state change!! No idea why it is not updated in the DB // without calling createAnnotationDocument(...) documentService.createAnnotationDocument(annotationDocument); aCallbackTarget.add(finishDocumentIcon); aCallbackTarget.add(finishDocumentLink); aCallbackTarget.add(detailEditor); aCallbackTarget.add(createOrGetResetDocumentLink()); }); finishDocumentDialog.show(aTarget); }
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); }
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; } }