Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioG70 committed Oct 28, 2024
1 parent d2777a5 commit 6e0f8f2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,25 +219,26 @@ 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);
}

}

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());
Expand All @@ -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++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ protected List<TableStructure> getTables(SiardDiark siardArchive) throws ModuleE
if (needsVirtualTable) {
lstTblsDptkl.add(createVirtualTable());
}
lstTblsDptkl.add(createContextDocumentationTable());
//lstTblsDptkl.add(createContextDocumentationTable());
}
return lstTblsDptkl;
}
Expand Down

0 comments on commit 6e0f8f2

Please sign in to comment.