@ApiOperation(value = "List annotations of a document in a project") @RequestMapping( value = "/" + PROJECTS + "/{" + PARAM_PROJECT_ID + "}/" + DOCUMENTS + "/{" + PARAM_DOCUMENT_ID + "}/" + ANNOTATIONS, method = RequestMethod.GET, produces = APPLICATION_JSON_UTF8_VALUE) public ResponseEntity<RResponse<List<RAnnotation>>> annotationsList( @PathVariable(PARAM_PROJECT_ID) long aProjectId, @PathVariable(PARAM_DOCUMENT_ID) long aDocumentId) throws Exception { // Get project (this also ensures that it exists and that the current user can access it Project project = getProject(aProjectId); SourceDocument doc = getDocument(project, aDocumentId); List<AnnotationDocument> annotations = documentService.listAnnotationDocuments(doc); List<RAnnotation> annotationList = new ArrayList<>(); for (AnnotationDocument annotation : annotations) { annotationList.add(new RAnnotation(annotation)); } return ResponseEntity.ok(new RResponse<>(annotationList)); }
@ApiOperation(value = "List annotations of a document in a project") @RequestMapping( value = "/" + PROJECTS + "/{" + PARAM_PROJECT_ID + "}/" + DOCUMENTS + "/{" + PARAM_DOCUMENT_ID + "}/" + ANNOTATIONS, method = RequestMethod.GET, produces = APPLICATION_JSON_UTF8_VALUE) public ResponseEntity<RResponse<List<RAnnotation>>> annotationsList( @PathVariable(PARAM_PROJECT_ID) long aProjectId, @PathVariable(PARAM_DOCUMENT_ID) long aDocumentId) throws Exception { // Get project (this also ensures that it exists and that the current user can access it Project project = getProject(aProjectId); SourceDocument doc = getDocument(project, aDocumentId); List<AnnotationDocument> annotations = documentService.listAnnotationDocuments(doc); List<RAnnotation> annotationList = new ArrayList<>(); for (AnnotationDocument annotation : annotations) { annotationList.add(new RAnnotation(annotation)); } return ResponseEntity.ok(new RResponse<>(annotationList)); }
/** * Get the predictions of a given window for each document, where the outer list is a list of * tokens and the inner list is a list of predictions for a token. The method filters all tokens * which already have an annotation and don't need further recommendation. */ public Map<String, SuggestionDocumentGroup> getPredictionsForWholeProject( AnnotationLayer aLayer, DocumentService aDocumentService) { Map<String, SuggestionDocumentGroup> result = new HashMap<>(); List<AnnotationDocument> docs = aDocumentService.listAnnotationDocuments(project, user); for (AnnotationDocument doc : docs) { // TODO #176 use the document Id once it it available in the CAS SuggestionDocumentGroup p = getPredictions(doc.getName(), aLayer, -1, -1); result.put(doc.getName(), p); } return result; }
private void indexAllDocuments() { int users = 0; int annotationDocs = 0; int sourceDocs = 0; try { log.info("Indexing all annotation documents of project [{}]({})", project.getName(), project.getId()); for (User user : projectService.listProjectUsersWithPermissions(project)) { users++; for (AnnotationDocument document : documentService.listAnnotationDocuments(project, user)) { indexDocument(document, documentService.readAnnotationCas(document)); annotationDocs++; } } log.info("Indexing all source documents of project [{}]({})", project.getName(), project.getId()); for (SourceDocument document : documentService.listSourceDocuments(project)) { indexDocument(document, documentService.createOrReadInitialCas(document)); sourceDocs++; } } catch (IOException e) { log.error("Unable to index document", e); } log.info(String.format( "Indexing results: %d source doc(s), %d annotation doc(s) for %d user(s)", sourceDocs, annotationDocs, users)); }
.listAnnotationDocuments(sourceDocument); for (AnnotationDocument annotationDocument : annotationDocuments) { String username = annotationDocument.getUser();
.listAnnotationDocuments(sourceDocument); for (AnnotationDocument annotationDocument : annotationDocuments) { String username = annotationDocument.getUser();
@EventListener public void beforeDocumentRemove(BeforeDocumentRemovedEvent aEvent) throws Exception { log.trace("Starting beforeDocumentRemove"); SourceDocument document = aEvent.getDocument(); Project project = document.getProject(); // Retrieve index entry for the project Index index = getIndexFromMemory(project); if (index.getPhysicalIndex().isCreated()) { // Physical index exists. log.trace("Physical index already created. Proceed to remove document."); if (!index.getPhysicalIndex().isOpen()) { // Physical index is not open. Open it. log.trace("Physical index not open. Open it"); index.getPhysicalIndex().openPhysicalIndex(); } // Remove source document from the index index.getPhysicalIndex().deindexDocument(document); // Remove related annotation documents from the index for (AnnotationDocument annotationDocument : documentService .listAnnotationDocuments(document)) { index.getPhysicalIndex().deindexDocument(annotationDocument); } } }
@EventListener public void beforeDocumentRemove(BeforeDocumentRemovedEvent aEvent) throws Exception { log.trace("Starting beforeDocumentRemove"); SourceDocument document = aEvent.getDocument(); Project project = document.getProject(); // Retrieve index entry for the project Index index = getIndexFromMemory(project); if (index.getPhysicalIndex().isCreated()) { // Physical index exists. log.trace("Physical index already created. Proceed to remove document."); if (!index.getPhysicalIndex().isOpen()) { // Physical index is not open. Open it. log.trace("Physical index not open. Open it"); index.getPhysicalIndex().openPhysicalIndex(); } // Remove source document from the index index.getPhysicalIndex().deindexDocument(document); // Remove related annotation documents from the index for (AnnotationDocument annotationDocument : documentService .listAnnotationDocuments(document)) { index.getPhysicalIndex().deindexDocument(annotationDocument); } } }
.listAnnotationDocuments(aBModel.getDocument())) { if (annotationDocument.getState().equals(AnnotationDocumentState.FINISHED)) { finishedAnnotationDocuments.add(annotationDocument);
.listAnnotationDocuments(aBModel.getDocument())) { if (annotationDocument.getState().equals(AnnotationDocumentState.FINISHED)) { finishedAnnotationDocuments.add(annotationDocument);
documentService.listAnnotationDocuments(sourceDocument)) {
documentService.listAnnotationDocuments(sourceDocument)) {
for (AnnotationDocument ad : documentService.listAnnotationDocuments(sd)) { if (documentService.existsAnnotationCas(ad)) { LogMessageSet messageSet = new LogMessageSet(
for (AnnotationDocument ad : documentService.listAnnotationDocuments(sd)) { if (documentService.existsAnnotationCas(ad)) { LogMessageSet messageSet = new LogMessageSet(
for (AnnotationDocument ad : documentService.listAnnotationDocuments(sd)) { if (documentService.existsAnnotationCas(ad)) { LogMessageSet messageSet = new LogMessageSet(
for (AnnotationDocument ad : documentService.listAnnotationDocuments(sd)) { if (documentService.existsAnnotationCas(ad)) { LogMessageSet messageSet = new LogMessageSet(
private void exportAnnotationDocuments(Project aProject, ExportedProject aExProject) { List<ExportedAnnotationDocument> annotationDocuments = new ArrayList<>(); // add source documents to a project List<SourceDocument> documents = documentService.listSourceDocuments(aProject); for (SourceDocument sourceDocument : documents) { // add annotation document to Project for (AnnotationDocument annotationDocument : documentService .listAnnotationDocuments(sourceDocument)) { ExportedAnnotationDocument exAnnotationDocument = new ExportedAnnotationDocument(); exAnnotationDocument.setName(annotationDocument.getName()); exAnnotationDocument.setState(annotationDocument.getState()); exAnnotationDocument.setUser(annotationDocument.getUser()); exAnnotationDocument.setTimestamp(annotationDocument.getTimestamp()); exAnnotationDocument.setSentenceAccessed(annotationDocument.getSentenceAccessed()); exAnnotationDocument.setCreated(annotationDocument.getCreated()); exAnnotationDocument.setUpdated(annotationDocument.getUpdated()); annotationDocuments.add(exAnnotationDocument); } } aExProject.setAnnotationDocuments(annotationDocuments); }
private void exportAnnotationDocuments(Project aProject, ExportedProject aExProject) { List<ExportedAnnotationDocument> annotationDocuments = new ArrayList<>(); // add source documents to a project List<SourceDocument> documents = documentService.listSourceDocuments(aProject); for (SourceDocument sourceDocument : documents) { // add annotation document to Project for (AnnotationDocument annotationDocument : documentService .listAnnotationDocuments(sourceDocument)) { ExportedAnnotationDocument exAnnotationDocument = new ExportedAnnotationDocument(); exAnnotationDocument.setName(annotationDocument.getName()); exAnnotationDocument.setState(annotationDocument.getState()); exAnnotationDocument.setUser(annotationDocument.getUser()); exAnnotationDocument.setTimestamp(annotationDocument.getTimestamp()); exAnnotationDocument.setSentenceAccessed(annotationDocument.getSentenceAccessed()); exAnnotationDocument.setCreated(annotationDocument.getCreated()); exAnnotationDocument.setUpdated(annotationDocument.getUpdated()); annotationDocuments.add(exAnnotationDocument); } } aExProject.setAnnotationDocuments(annotationDocuments); }
.listAnnotationDocuments(state.getDocument())) { if (annotationDocument.getState().equals(AnnotationDocumentState.FINISHED)) { finishedAnnotationDocuments.add(annotationDocument);
.listAnnotationDocuments(state.getDocument())) { if (annotationDocument.getState().equals(AnnotationDocumentState.FINISHED)) { finishedAnnotationDocuments.add(annotationDocument);