if (documentRepository.existsSourceDocument(project, aFile.getOriginalFilename())) { return ResponseEntity .status(HttpStatus.CONFLICT)
if (documentRepository.existsSourceDocument(project, aFile.getOriginalFilename())) { return ResponseEntity .status(HttpStatus.CONFLICT)
/** * @return a boolean value. True if import was successful. False if import was aborted because * the document already exists. */ @Override public boolean importDocumentFromDocumentRepository(User aUser, Project aProject, String aDocumentTitle, DocumentRepository aRepository) throws IOException { String text = externalSearchService.getDocumentById(aUser, aRepository, aDocumentTitle) .getText(); if (documentService.existsSourceDocument(aProject, aDocumentTitle)) { return false; } SourceDocument document = new SourceDocument(); document.setName(aDocumentTitle); document.setProject(aProject); document.setFormat(PLAIN_TEXT); try (InputStream is = new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8))) { documentService.uploadSourceDocument(is, document); } catch (IOException | UIMAException e) { throw new IOException("Unable to retrieve document [" + aDocumentTitle + "]", e); } return true; } }
public ResultRowView(String id, long rowNumber, IModel<ExternalSearchResult> model) { super(id, model); ExternalSearchResult result = (ExternalSearchResult) getDefaultModelObject(); String documentTitle = result.getDocumentTitle(); String highlight = Utilities.cleanHighlight(result.getHighlights().get(0)); boolean existsSourceDocument = documentService .existsSourceDocument(project, documentTitle); // Import and open annotation LambdaAjaxLink link; if (!existsSourceDocument) { link = new LambdaAjaxLink("docLink", t -> actionImport(t, result, documentTitle)); } else { // open action link = new LambdaAjaxLink("docLink", t -> actionOpen(t, result, documentTitle)); } String title = defaultIfBlank(result.getDocumentTitle(), defaultIfBlank(result.getDocumentId(), defaultIfBlank(result.getUri(), "<no title>"))); add(link); link.add(new Label("title", title)); link.add(new Label("score", result.getScore())); link.add(new Label("highlight", highlight).setEscapeModelStrings(false)); link.add(new Label("importStatus", () -> existsSourceDocument ? "imported" : "not imported")); } }
private void actionImportDocument(AjaxRequestTarget aTarget, ExternalSearchResult aResult) { String documentTitle = aResult.getDocumentTitle(); String text = externalSearchService .getDocumentById(userRepository.getCurrentUser(), currentRepository, documentTitle) .getText(); if (documentService.existsSourceDocument(project, documentTitle)) { error("Document [" + documentTitle + "] already uploaded! Delete " + "the document if you want to upload again"); } else { importDocument(documentTitle, text); aTarget.add(dataTableContainer); } }
String fileName = documentToUpload.getClientFileName(); if (documentService.existsSourceDocument(project, fileName)) { error("Document " + fileName + " already uploaded ! Delete " + "the document if you want to upload again");
String fileName = documentToUpload.getClientFileName(); if (documentService.existsSourceDocument(project, fileName)) { error("Document " + fileName + " already uploaded ! Delete " + "the document if you want to upload again");
defaultIfBlank(result.getDocumentId(), defaultIfBlank(result.getUri(), "<no title>"))); boolean existsSourceDocument = documentService.existsSourceDocument(project, documentTitle);
defaultIfBlank(result.getDocumentId(), defaultIfBlank(result.getUri(), "<no title>"))); boolean existsSourceDocument = documentService.existsSourceDocument(project, documentTitle);