From 83032900ac28fa03fc0d378bb7721eda07c36806 Mon Sep 17 00:00:00 2001 From: Martin Ledvinka Date: Mon, 2 Dec 2024 16:43:38 +0100 Subject: [PATCH] [kbss-cvut/termit-ui#581] Add a template file for term translations import. --- .../termit/rest/VocabularyController.java | 9 +++++++-- .../service/business/VocabularyService.java | 18 +++++++++++++++--- .../template/termit-translations-import.xlsx | Bin 0 -> 39672 bytes .../termit/rest/VocabularyControllerTest.java | 18 +++++++++++++++++- .../business/VocabularyServiceTest.java | 4 ++-- 5 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/template/termit-translations-import.xlsx diff --git a/src/main/java/cz/cvut/kbss/termit/rest/VocabularyController.java b/src/main/java/cz/cvut/kbss/termit/rest/VocabularyController.java index 9f8475ad0..b90780d59 100644 --- a/src/main/java/cz/cvut/kbss/termit/rest/VocabularyController.java +++ b/src/main/java/cz/cvut/kbss/termit/rest/VocabularyController.java @@ -205,8 +205,13 @@ public ResponseEntity createVocabulary( @ApiResponse(responseCode = "200", description = "Template Excel file is returned as attachment") @GetMapping("/import/template") @PreAuthorize("permitAll()") - public ResponseEntity getExcelTemplateFile() { - final TypeAwareResource template = vocabularyService.getExcelTemplateFile(); + public ResponseEntity getExcelTemplateFile( + @Parameter(description = "Whether the file will be used to import only term translations") + @RequestParam(name = "translationsOnly", required = false, + defaultValue = "false") boolean translationsOnly) { + final TypeAwareResource template = + translationsOnly ? vocabularyService.getExcelTranslationsImportTemplateFile() : + vocabularyService.getExcelImportTemplateFile(); return ResponseEntity.ok() .contentType(MediaType.parseMediaType( template.getMediaType().orElse(MediaType.APPLICATION_OCTET_STREAM_VALUE))) diff --git a/src/main/java/cz/cvut/kbss/termit/service/business/VocabularyService.java b/src/main/java/cz/cvut/kbss/termit/service/business/VocabularyService.java index 4861464e2..bd250002f 100644 --- a/src/main/java/cz/cvut/kbss/termit/service/business/VocabularyService.java +++ b/src/main/java/cz/cvut/kbss/termit/service/business/VocabularyService.java @@ -299,18 +299,30 @@ public Vocabulary importTermTranslations(URI vocabularyIri, MultipartFile file) * * @return Template file as a resource */ - public TypeAwareResource getExcelTemplateFile() { + public TypeAwareResource getExcelImportTemplateFile() { + return getExcelTemplate("termit-import"); + } + + private TypeAwareResource getExcelTemplate(String fileName) { final Configuration config = context.getBean(Configuration.class); return config.getTemplate().getExcelImport().map(File::new) .map(f -> (TypeAwareResource) new TypeAwareFileSystemResource(f, ExportFormat.EXCEL.getMediaType())) .orElseGet(() -> { - assert getClass().getClassLoader().getResource("template/termit-import.xlsx") != null; - return new TypeAwareClasspathResource("template/termit-import.xlsx", + assert getClass().getClassLoader().getResource("template/" + fileName + ExportFormat.EXCEL.getFileExtension()) != null; + return new TypeAwareClasspathResource("template/" + fileName + ExportFormat.EXCEL.getFileExtension(), ExportFormat.EXCEL.getMediaType()); }); } + /** + * Gets an Excel template file that can be used to import term translations into TermIt. + * @return Template file as a resource + */ + public TypeAwareResource getExcelTranslationsImportTemplateFile() { + return getExcelTemplate("termit-translations-import"); + } + @Override public List getChanges(Vocabulary asset, ChangeRecordFilterDto filterDto) { return changeRecordService.getChanges(asset, filterDto); diff --git a/src/main/resources/template/termit-translations-import.xlsx b/src/main/resources/template/termit-translations-import.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..47326329bab451e2f0df4693637399bf72b2c1dd GIT binary patch literal 39672 zcmeI5c{r5q-|$JHY!#(Nw5e2PER|GDyO^X>sVtKuWEmOT7-rfesT46}tB{I}vYQzb zLYfegeXK*a8OAckZ0}WF^W5FfaXui&xOt*Z*T}o`#=?3MMHN~ zKgU)q+G%nUd0?|wxP{r|=k9%BkJZ}9HNGFsjwT1D?IbN$aJ;<$O>+z?q;@hN zD=wGUIbyyDzowt@acM*TgEjoe)WMh-<)XrVFVBmU($%EJw{)DmG3M)njvQqqEm@_H zFbg}M$fNcvABW4x20z*MgaI@{%^V4d4 z1AU8$bcd=0qfON*vZ0;qJ5p<-mMgbC3`F0-DEBxYICQvBWnqM}vsbRa0qjUFJf+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*xj@etr{|5e=H)AO%N zcYl+(h6hTG1MkXzDot7ZTWJR$lsD4-uWqpG>r#CW0Nn?){hx1u2QIA-AU(VtJ-iX8 z(4LMc+rPTO?{1Gjcjw_Hf7zXSe|4ANNBE!b5`E?`@AA_MavVMnsJ4WJ{Et6CCw}|U H6cYajhMLY$ literal 0 HcmV?d00001 diff --git a/src/test/java/cz/cvut/kbss/termit/rest/VocabularyControllerTest.java b/src/test/java/cz/cvut/kbss/termit/rest/VocabularyControllerTest.java index 0a5a6b9e1..202354185 100644 --- a/src/test/java/cz/cvut/kbss/termit/rest/VocabularyControllerTest.java +++ b/src/test/java/cz/cvut/kbss/termit/rest/VocabularyControllerTest.java @@ -638,7 +638,7 @@ void getAccessLevelRetrievesAccessLevelToSpecifiedVocabulary() throws Exception @Test void getExcelTemplateFileReturnsExcelTemplateFileRetrievedFromServiceAsAttachment() throws Exception { - when(serviceMock.getExcelTemplateFile()).thenReturn(new TypeAwareFileSystemResource( + when(serviceMock.getExcelImportTemplateFile()).thenReturn(new TypeAwareFileSystemResource( new File(getClass().getClassLoader().getResource("template/termit-import.xlsx").toURI()), Constants.MediaType.EXCEL)); @@ -646,6 +646,22 @@ void getExcelTemplateFileReturnsExcelTemplateFileRetrievedFromServiceAsAttachmen assertThat(mvcResult.getResponse().getHeader(HttpHeaders.CONTENT_DISPOSITION), containsString("attachment")); assertThat(mvcResult.getResponse().getHeader(HttpHeaders.CONTENT_DISPOSITION), containsString("filename=\"termit-import.xlsx\"")); + verify(serviceMock).getExcelImportTemplateFile(); + } + + @Test + void getExcelTemplateFileReturnsExcelTermTranslationsTemplateFileRetrievedFromServiceAsAttachment() + throws Exception { + when(serviceMock.getExcelTranslationsImportTemplateFile()).thenReturn(new TypeAwareFileSystemResource( + new File(getClass().getClassLoader().getResource("template/termit-translations-import.xlsx").toURI()), + Constants.MediaType.EXCEL)); + + final MvcResult mvcResult = mockMvc.perform( + get(PATH + "/import/template").queryParam("translationsOnly", Boolean.toString(true))).andReturn(); + assertThat(mvcResult.getResponse().getHeader(HttpHeaders.CONTENT_DISPOSITION), containsString("attachment")); + assertThat(mvcResult.getResponse().getHeader(HttpHeaders.CONTENT_DISPOSITION), + containsString("filename=\"termit-translations-import.xlsx\"")); + verify(serviceMock).getExcelTranslationsImportTemplateFile(); } @Test diff --git a/src/test/java/cz/cvut/kbss/termit/service/business/VocabularyServiceTest.java b/src/test/java/cz/cvut/kbss/termit/service/business/VocabularyServiceTest.java index ca6b97ab2..9ad04a33a 100644 --- a/src/test/java/cz/cvut/kbss/termit/service/business/VocabularyServiceTest.java +++ b/src/test/java/cz/cvut/kbss/termit/service/business/VocabularyServiceTest.java @@ -383,9 +383,9 @@ void importNewVocabularyPublishesVocabularyCreatedEvent() { } @Test - void getExcelTemplateFileReturnsResourceRepresentingExcelTemplateFile() throws Exception { + void getExcelTemplateFileReturnsResourceRepresentingExcelImportTemplateFile() throws Exception { when(appContext.getBean(Configuration.class)).thenReturn(new Configuration()); - final TypeAwareResource result = sut.getExcelTemplateFile(); + final TypeAwareResource result = sut.getExcelImportTemplateFile(); assertTrue(result.getFileExtension().isPresent()); assertEquals(ExportFormat.EXCEL.getFileExtension(), result.getFileExtension().get()); assertTrue(result.getMediaType().isPresent());