Skip to content

Commit

Permalink
parsing: add subtype to metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
handymenny committed Nov 17, 2024
1 parent ac10e5f commit bdfe2ef
Showing 1 changed file with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,29 @@ class Parsing(
capabilities.setMetadata("description", description)
}

if (type == LogType.H) {
// set subtypes
val subTypes =
getInputs().mapNotNull {
when (it) {
input -> defaultRat
inputNR -> Rat.NR
inputENDC -> Rat.EUTRA_NR
else -> null
}
}

if (subTypes.isNotEmpty()) {
capabilities.addMetadata("subTypes", subTypes.joinToString(", "))
}
}

return capabilities
}

private fun getInputs(): List<InputSource?> =
arrayOf(input, inputNR, inputENDC).filterNot { it == null || it.size() == 0L }

private fun parseCapabilities(): Capabilities {
val imports = LogType.getImporter(type) ?: return Capabilities()

Expand Down Expand Up @@ -79,16 +99,12 @@ class Parsing(
val inputDir = "$path/input"
val outputDir = "$path/output"
val id = capabilities.id
val inputs = arrayOf(input, inputNR, inputENDC)
val inputsPath = mutableListOf<String>()

inputs
.filterNot { it == null || it.size() == 0L }
.forEachIndexed { index, data ->
val inputsPath =
getInputs().mapIndexed { index, data ->
val fileName = "$id-$index"
val inputPath = "$inputDir/$fileName"
IOUtils.outputFile(data!!.readBytes(), inputPath, compression)
inputsPath.add(fileName)
fileName
}

val encodedString = Json.custom().encodeToString(capabilities)
Expand Down

0 comments on commit bdfe2ef

Please sign in to comment.