From 6e0f8f2edf398a62b35a53250710514f437fd8f2 Mon Sep 17 00:00:00 2001 From: alindo Date: Mon, 28 Oct 2024 12:54:26 +0000 Subject: [PATCH] wip --- .../content/SIARDDKContentImportStrategy.java | 57 +++++++++---------- .../SIARDDK1007MetadataImportStrategy.java | 2 +- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/in/content/SIARDDKContentImportStrategy.java b/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/in/content/SIARDDKContentImportStrategy.java index de527c2e..b025c56f 100644 --- a/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/in/content/SIARDDKContentImportStrategy.java +++ b/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/in/content/SIARDDKContentImportStrategy.java @@ -219,17 +219,17 @@ public void importContent(DatabaseExportModule dbExportHandler, SIARDArchiveCont .withMessage( "Error reading metadata XSD file: " + pathStrategy.getXsdFilePath(SIARDDKConstants.DOC_INDEX)) .withCause(e); - } - } else if (table.getId().contains(SIARDDKConstants.CONTEXT_DOCUMENTATION_VIRTUAL_TABLE_NAME)) { - try { - populateContextDocumentationTable(table, databaseStructure.getName().replace(" ", "")); - } catch (FileNotFoundException e) { - throw new ModuleException() - .withMessage( - "Error reading metadata XSD file: " + pathStrategy.getXsdFilePath(SIARDDKConstants.DOC_INDEX)) - .withCause(e); - } - } + }} +// } else if (table.getId().contains(SIARDDKConstants.CONTEXT_DOCUMENTATION_VIRTUAL_TABLE_NAME)) { +// try { +// populateContextDocumentationTable(table, databaseStructure.getName().replace(" ", "")); +// } catch (FileNotFoundException e) { +// throw new ModuleException() +// .withMessage( +// "Error reading metadata XSD file: " + pathStrategy.getXsdFilePath(SIARDDKConstants.DOC_INDEX)) +// .withCause(e); +// } +// } } completedSchemas++; this.dbExportHandler.handleDataCloseSchema(importAsSchema); @@ -237,7 +237,8 @@ public void importContent(DatabaseExportModule dbExportHandler, SIARDArchiveCont } - void populateContextDocumentationTable(TableStructure table, String dbName) throws ModuleException, FileNotFoundException { + void populateContextDocumentationTable(TableStructure table, String dbName) + throws ModuleException, FileNotFoundException { F contextDoc = loadContextDocTableContent(); currentTable = table; this.dbExportHandler.handleDataOpenTable(table.getId()); @@ -257,29 +258,25 @@ void populateContextDocumentationTable(TableStructure table, String dbName) thro cells[cellCounter] = documentTitleCell; cellCounter++; Cell documentDateCell = new SimpleCell( - SIARDDKConstants.DOCUMENT_DATE + SIARDDKConstants.FILE_EXTENSION_SEPARATOR + rowCounter, - getDocumentDate(doc)); + SIARDDKConstants.DOCUMENT_DATE + SIARDDKConstants.FILE_EXTENSION_SEPARATOR + rowCounter, getDocumentDate(doc)); cells[cellCounter] = documentDateCell; cellCounter++; - String binPath = ""; - String docPath = pathStrategy.getMainFolder().getPath().toString() + SIARDDKConstants.RESOURCE_FILE_SEPARATOR - + SIARDDKConstants.CONTEXT_DOCUMENTATION_FOLDER_NAME + SIARDDKConstants.RESOURCE_FILE_SEPARATOR - + SIARDDKConstants.DOC_COLLECTION_FOLDER_NAME + SIARDDKConstants.RESOURCE_FILE_SEPARATOR + getDocumentID(doc); - File docFolder = new File(docPath); - if (docFolder.exists() && docFolder.isDirectory()) { - File[] fileList = docFolder.listFiles(); - if (fileList != null && fileList.length == 1) { - binPath = docPath + SIARDDKConstants.RESOURCE_FILE_SEPARATOR + fileList[0].getName(); - } else if (fileList != null && fileList.length > 1){ - binPath = docPath; - } - } try { + String docPath = pathStrategy.getMainFolder().getPath().toString() + SIARDDKConstants.RESOURCE_FILE_SEPARATOR + + SIARDDKConstants.CONTEXT_DOCUMENTATION_FOLDER_NAME + SIARDDKConstants.RESOURCE_FILE_SEPARATOR + + SIARDDKConstants.DOC_COLLECTION_FOLDER_NAME + SIARDDKConstants.RESOURCE_FILE_SEPARATOR + getDocumentID(doc); + String digest = ""; + File docFolder = new File(docPath); + if (docFolder.exists() && docFolder.isDirectory()) { + File[] fileList = docFolder.listFiles(); + if (fileList != null && fileList.length == 1) { + docPath = docPath + SIARDDKConstants.RESOURCE_FILE_SEPARATOR + fileList[0].getName(); + digest = DigestUtils.sha1Hex(FileUtils.readFileToByteArray(Paths.get(docPath).toFile())); + } + } Cell blobCell = new BinaryCell( SIARDDKConstants.BLOB_EXTENSION + SIARDDKConstants.FILE_EXTENSION_SEPARATOR + rowCounter, - new DummyInputStreamProvider(), binPath, 0L, - DigestUtils.sha1Hex(FileUtils.readFileToByteArray(Paths.get(binPath).toFile())), - DigestUtils.getSha1Digest().toString()); + new DummyInputStreamProvider(), docPath, 0L, digest, DigestUtils.getSha1Digest().toString()); cells[cellCounter] = blobCell; cellCounter++; rowCounter++; diff --git a/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/in/metadata/SIARDDK1007MetadataImportStrategy.java b/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/in/metadata/SIARDDK1007MetadataImportStrategy.java index 1b1e991b..1ce98ba1 100644 --- a/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/in/metadata/SIARDDK1007MetadataImportStrategy.java +++ b/dbptk-modules/dbptk-module-siard/src/main/java/com/databasepreservation/modules/siard/in/metadata/SIARDDK1007MetadataImportStrategy.java @@ -299,7 +299,7 @@ protected List getTables(SiardDiark siardArchive) throws ModuleE if (needsVirtualTable) { lstTblsDptkl.add(createVirtualTable()); } - lstTblsDptkl.add(createContextDocumentationTable()); + //lstTblsDptkl.add(createContextDocumentationTable()); } return lstTblsDptkl; }