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; }
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 } } }
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 } } }
if (documentService.existsAnnotationDocument(document, user)) { AnnotationDocument annoDoc = documentService .getAnnotationDocument(document, user);
if (documentService.existsAnnotationDocument(document, annotator)) { annoDoc = documentService.getAnnotationDocument(document, annotator); state = annoDoc.getState();
if (documentService.existsAnnotationDocument(document, user)) { AnnotationDocument annotationDocument = documentService .getAnnotationDocument(document, user);
if (documentService.existsAnnotationDocument(sourceDocument, aRequest.getUsername()) && annotationDocumentId == -1) {
.existsAnnotationDocument(document, getModelObject().getUser())) { AnnotationDocument adoc = documentService.getAnnotationDocument(document, getModelObject().getUser());