From defc6130700b8b1fb1fca1ae08faff40183d4628 Mon Sep 17 00:00:00 2001 From: amentis Date: Tue, 18 Jun 2024 14:47:17 +0300 Subject: [PATCH] update file transformer base --- .../docx/audit/AuditableAction.java | 4 +- .../WordFileTransformerService.java | 16 ++++++-- pom.xml | 2 +- .../controller/FileTransformerController.java | 41 +++++++++++++++---- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/org/opencdmp/filetransformer/docx/audit/AuditableAction.java b/core/src/main/java/org/opencdmp/filetransformer/docx/audit/AuditableAction.java index efeee57..30f8fcd 100644 --- a/core/src/main/java/org/opencdmp/filetransformer/docx/audit/AuditableAction.java +++ b/core/src/main/java/org/opencdmp/filetransformer/docx/audit/AuditableAction.java @@ -10,6 +10,8 @@ public class AuditableAction { public static final EventId FileTransformer_ImportFileToDmp = new EventId(1002, "FileTransformer_ImportFileToDmp"); public static final EventId FileTransformer_ImportFileToDescription = new EventId(1003, "FileTransformer_ImportFileToDescription"); public static final EventId FileTransformer_GetSupportedFormats = new EventId(1004, "FileTransformer_GetSupportedFormats"); + public static final EventId FileTransformer_PreprocessingDmp = new EventId(1005, "FileTransformer_PreprocessingDmp"); + public static final EventId FileTransformer_PreprocessingDescription = new EventId(1006, "FileTransformer_PreprocessingDescription"); + - } diff --git a/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/WordFileTransformerService.java b/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/WordFileTransformerService.java index fffff94..708b765 100644 --- a/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/WordFileTransformerService.java +++ b/core/src/main/java/org/opencdmp/filetransformer/docx/service/wordfiletransformer/WordFileTransformerService.java @@ -18,7 +18,7 @@ import org.opencdmp.filetransformerbase.enums.FileTransformerEntityType; import org.opencdmp.filetransformerbase.interfaces.FileTransformerClient; import org.opencdmp.filetransformerbase.interfaces.FileTransformerConfiguration; import org.opencdmp.filetransformer.docx.model.enums.FileFormats; -import org.opencdmp.filetransformerbase.models.misc.FileFormat; +import org.opencdmp.filetransformerbase.models.misc.*; import org.opencdmp.filetransformer.docx.service.pdf.PdfService; import org.opencdmp.filetransformer.docx.model.enums.ParagraphStyle; import org.opencdmp.filetransformer.docx.service.storage.FileStorageService; @@ -124,12 +124,12 @@ public class WordFileTransformerService implements FileTransformerClient { @Override - public DmpModel importDmp(FileEnvelopeModel envelope) { + public DmpModel importDmp(DmpImportModel dmpImportModel) { throw new MyApplicationException("import not supported"); } @Override - public DescriptionModel importDescription(FileEnvelopeModel envelope) { + public DescriptionModel importDescription(DescriptionImportModel descriptionImportModel) { throw new MyApplicationException("import not supported"); } @@ -144,6 +144,16 @@ public class WordFileTransformerService implements FileTransformerClient { return configuration; } + @Override + public PreprocessingDmpModel preprocessingDmp(FileEnvelopeModel fileEnvelopeModel) { + throw new MyApplicationException("preprocessing not supported"); + } + + @Override + public PreprocessingDescriptionModel preprocessingDescription(FileEnvelopeModel fileEnvelopeModel) { + throw new MyApplicationException("preprocessing not supported"); + } + private List getReferenceModelOfTypeCode(DmpModel dmp, String code, UUID blueprintId){ List response = new ArrayList<>(); if (dmp.getReferences() == null) return response; diff --git a/pom.xml b/pom.xml index d3f2fb3..df8e1c0 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.opencdmp file-transformer-base - 0.0.22 + 0.0.23 org.yaml diff --git a/web/src/main/java/org/opencdmp/filetransformer/docx/web/controller/FileTransformerController.java b/web/src/main/java/org/opencdmp/filetransformer/docx/web/controller/FileTransformerController.java index e6f3724..cc7077f 100644 --- a/web/src/main/java/org/opencdmp/filetransformer/docx/web/controller/FileTransformerController.java +++ b/web/src/main/java/org/opencdmp/filetransformer/docx/web/controller/FileTransformerController.java @@ -10,6 +10,10 @@ import org.opencdmp.filetransformer.docx.audit.AuditableAction; import org.opencdmp.filetransformerbase.interfaces.FileTransformerClient; import org.opencdmp.filetransformerbase.interfaces.FileTransformerConfiguration; import org.opencdmp.filetransformer.docx.service.wordfiletransformer.WordFileTransformerService; +import org.opencdmp.filetransformerbase.models.misc.DescriptionImportModel; +import org.opencdmp.filetransformerbase.models.misc.DmpImportModel; +import org.opencdmp.filetransformerbase.models.misc.PreprocessingDescriptionModel; +import org.opencdmp.filetransformerbase.models.misc.PreprocessingDmpModel; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -56,29 +60,50 @@ public class FileTransformerController implements org.opencdmp.filetransformerba return model; } - public DmpModel importFileToDmp(@RequestBody FileEnvelopeModel fileEnvelope) { + public DmpModel importFileToDmp(@RequestBody DmpImportModel dmpImportModel) { - logger.debug(new MapLogEntry("importFileToDmp " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", fileEnvelope)); + logger.debug(new MapLogEntry("importFileToDmp " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", dmpImportModel.getFile())); - DmpModel model = fileTransformerExecutor.importDmp(fileEnvelope); + DmpModel model = fileTransformerExecutor.importDmp(dmpImportModel); this.auditService.track(AuditableAction.FileTransformer_ImportFileToDmp, Map.ofEntries( - new AbstractMap.SimpleEntry("fileEnvelope", fileEnvelope) + new AbstractMap.SimpleEntry("fileEnvelope", dmpImportModel.getFile()) )); return model; } - public DescriptionModel importFileToDescription(@RequestBody FileEnvelopeModel fileEnvelope) { - logger.debug(new MapLogEntry("importFileToDescription " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", fileEnvelope)); + public DescriptionModel importFileToDescription(@RequestBody DescriptionImportModel descriptionImportModel) { + logger.debug(new MapLogEntry("importFileToDescription " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", descriptionImportModel.getFile())); - DescriptionModel model = fileTransformerExecutor.importDescription(fileEnvelope); + DescriptionModel model = fileTransformerExecutor.importDescription(descriptionImportModel); this.auditService.track(AuditableAction.FileTransformer_ImportFileToDescription, Map.ofEntries( - new AbstractMap.SimpleEntry("importFileToDescription ", fileEnvelope) + new AbstractMap.SimpleEntry("importFileToDescription ", descriptionImportModel.getFile()) )); return model; } + public PreprocessingDmpModel preprocessingDmp(FileEnvelopeModel fileEnvelopeModel) { + logger.debug(new MapLogEntry("PreprocessingDmpModel " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", fileEnvelopeModel)); + + PreprocessingDmpModel model = fileTransformerExecutor.preprocessingDmp(fileEnvelopeModel); + + this.auditService.track(AuditableAction.FileTransformer_PreprocessingDmp, Map.ofEntries( + new AbstractMap.SimpleEntry("importFileToDescription ", fileEnvelopeModel) + )); + return model; + } + + public PreprocessingDescriptionModel preprocessingDescription(FileEnvelopeModel fileEnvelopeModel) { + logger.debug(new MapLogEntry("PreprocessingDescriptionModel " + FileEnvelopeModel.class.getSimpleName()).And("fileEnvelope", fileEnvelopeModel)); + + PreprocessingDescriptionModel model = fileTransformerExecutor.preprocessingDescription(fileEnvelopeModel); + + this.auditService.track(AuditableAction.FileTransformer_PreprocessingDescription, Map.ofEntries( + new AbstractMap.SimpleEntry("importFileToDescription ", fileEnvelopeModel) + )); + return model; } + public FileTransformerConfiguration getSupportedFormats() { logger.debug(new MapLogEntry("getSupportedFormats"));