Skip to content

Commit eadec32

Browse files
committed
add cmdi to export zip
1 parent 55570a4 commit eadec32

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

server/src/main/kotlin/org/ivdnt/galahad/export/CorpusExport.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class CorpusExport private constructor(
6565
) {
6666
val documents = corpus.documents.readAll().filter { DocumentExport.create(this, it).layer != Layer.EMPTY }
6767
val seq: Sequence<FileMapper> = documents.asSequence().map { doc -> doc.name to { out -> formatMapper(doc, out) } }
68-
createZipFile(seq, out)
68+
val seqCmdi: Sequence<FileMapper> = documents.asSequence().map { doc -> "metadata/CMDI-${doc.uploadedFile.nameWithoutExtension}.xml" to { out -> DocumentExport.create(this, doc).cmdi(out) } }
69+
createZipFile(seq + seqCmdi, out, includeCMDI = true)
6970
}
7071

7172
companion object {

server/src/main/kotlin/org/ivdnt/galahad/export/DocumentExport.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class DocumentExport private constructor(
3232

3333
fun convert(out: OutputStream): Unit = LayerConverter.create(this).convert(out)
3434
fun merge(out: OutputStream): Unit = LayerMerger.create(this).merge(out)
35-
fun cmdi(): CmdiMetadata = CmdiMetadata(this)
35+
fun cmdi(out: OutputStream): Unit = CmdiMetadata(this).write(out)
3636

3737
companion object {
3838
fun create(export: CorpusExport, doc: Document): DocumentExport = create(export, doc.name)

server/src/main/kotlin/org/ivdnt/galahad/util/ZipUtil.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ fun createZipFile(files: Sequence<FileMapper>, out: OutputStream? = null, includ
3232
}
3333

3434
if (includeCMDI) {
35-
val cmdis = listOf("TextProfileINT_GaLAHaD.xml", "TextProfileINT_GaLAHaD.xsd")
35+
val cmdis = arrayOf("TextProfileINT_GaLAHaD.xml", "TextProfileINT_GaLAHaD.xsd")
3636
for (cmdi in cmdis) {
3737
val cmdiFile = getResourceStream(cmdi)
38-
zipStream.putNextEntry(ZipEntry(cmdi))
38+
zipStream.putNextEntry(ZipEntry("metadata/$cmdi"))
3939
zipStream.write(cmdiFile!!.readBytes())
4040
}
4141
}

0 commit comments

Comments
 (0)