diff --git a/core/src/main/java/eu/eudat/file/transformer/service/wordfiletransformer/WordFileTransformerService.java b/core/src/main/java/eu/eudat/file/transformer/service/wordfiletransformer/WordFileTransformerService.java index 897104e..8f0b082 100644 --- a/core/src/main/java/eu/eudat/file/transformer/service/wordfiletransformer/WordFileTransformerService.java +++ b/core/src/main/java/eu/eudat/file/transformer/service/wordfiletransformer/WordFileTransformerService.java @@ -71,9 +71,14 @@ public class WordFileTransformerService implements FileTransformerClient { } default -> throw new InvalidApplicationException("Invalid type " + fileFormat); }; - String fileRef = this.storageService.storeFile(bytes); - FileEnvelopeModel wordFile = new FileEnvelopeModel(); - wordFile.setFileRef(fileRef); + + FileEnvelopeModel wordFile = new FileEnvelopeModel(); + if (this.getConfiguration().isUseSharedStorage()) { + String fileRef = this.storageService.storeFile(bytes); + wordFile.setFileRef(fileRef); + } else { + wordFile.setFile(bytes); + } wordFile.setFilename(filename); return wordFile; } @@ -90,10 +95,14 @@ public class WordFileTransformerService implements FileTransformerClient { } default -> throw new InvalidApplicationException("Invalid type " + fileFormat); }; - String fileRef = this.storageService.storeFile(bytes); - + FileEnvelopeModel wordFile = new FileEnvelopeModel(); - wordFile.setFileRef(fileRef); + if (this.getConfiguration().isUseSharedStorage()) { + String fileRef = this.storageService.storeFile(bytes); + wordFile.setFileRef(fileRef); + } else { + wordFile.setFile(bytes); + } wordFile.setFilename(filename); return wordFile; } @@ -112,10 +121,10 @@ public class WordFileTransformerService implements FileTransformerClient { @Override public FileTransformerConfiguration getConfiguration() { FileTransformerConfiguration configuration = new FileTransformerConfiguration(); - configuration.setFileTransformerId("docx/pdf"); + configuration.setFileTransformerId(this.wordFileTransformerServiceProperties.getTransformerId()); configuration.setExportVariants(FILE_FORMATS); configuration.setImportVariants(null); - configuration.setUseSharedStorage(true); + configuration.setUseSharedStorage(this.wordFileTransformerServiceProperties.isUseSharedStorage()); return configuration; } @@ -323,12 +332,10 @@ public class WordFileTransformerService implements FileTransformerClient { runInput.setText("Input: "); runInput.setColor("000000"); List referenceModels = this.getReferenceModelOfTypeCode(dmpEntity, referenceField.getReferenceType().getCode(), referenceField.getId()); - if (referenceModels != null) { - for (ReferenceModel reference : referenceModels) { - XWPFRun runResearcher = systemFieldInput.createRun(); - runResearcher.setText("• " + reference.getLabel()); - runResearcher.setColor("116a78"); - } + for (ReferenceModel reference : referenceModels) { + XWPFRun runResearcher = systemFieldInput.createRun(); + runResearcher.setText("• " + reference.getLabel()); + runResearcher.setColor("116a78"); } document.createParagraph(); diff --git a/core/src/main/java/eu/eudat/file/transformer/service/wordfiletransformer/WordFileTransformerServiceProperties.java b/core/src/main/java/eu/eudat/file/transformer/service/wordfiletransformer/WordFileTransformerServiceProperties.java index e516554..b36ee5e 100644 --- a/core/src/main/java/eu/eudat/file/transformer/service/wordfiletransformer/WordFileTransformerServiceProperties.java +++ b/core/src/main/java/eu/eudat/file/transformer/service/wordfiletransformer/WordFileTransformerServiceProperties.java @@ -4,6 +4,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties(prefix = "word-file-transformer") public class WordFileTransformerServiceProperties { + private String transformerId; + private boolean useSharedStorage; private String wordDmpTemplate; private String pidTemplate; private String wordDescriptionTemplate; @@ -16,6 +18,14 @@ public class WordFileTransformerServiceProperties { private String datasetReferenceCode; private String publicationReferenceCode; + public String getTransformerId() { + return transformerId; + } + + public void setTransformerId(String transformerId) { + this.transformerId = transformerId; + } + public String getOrganizationReferenceCode() { return organizationReferenceCode; } @@ -103,4 +113,12 @@ public class WordFileTransformerServiceProperties { public void setWordDescriptionTemplate(String wordDescriptionTemplate) { this.wordDescriptionTemplate = wordDescriptionTemplate; } + + public boolean isUseSharedStorage() { + return useSharedStorage; + } + + public void setUseSharedStorage(boolean useSharedStorage) { + this.useSharedStorage = useSharedStorage; + } } diff --git a/web/src/main/resources/config/word-file-transormer.yml b/web/src/main/resources/config/word-file-transformer.yml similarity index 90% rename from web/src/main/resources/config/word-file-transormer.yml rename to web/src/main/resources/config/word-file-transformer.yml index 2d72e3e..06e9026 100644 --- a/web/src/main/resources/config/word-file-transormer.yml +++ b/web/src/main/resources/config/word-file-transformer.yml @@ -1,7 +1,9 @@ word-file-transformer: + transformerId: "docx/pdf" word-dmp-template: classpath:documents/h2020.docx pid-template: classpath:pidLinks.json word-description-template: classpath:documents/h2020_dataset.docx + useSharedStorage: true organizationReferenceCode: "organisations" grantReferenceCode: "grants" funderReferenceCode: "funders"