Skip to content

Commit

Permalink
koble til marshaler og fjern msgheader fra jaxb context
Browse files Browse the repository at this point in the history
  • Loading branch information
alpet committed Sep 26, 2023
1 parent 38dc81f commit 94d35f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class XmlMarshaller {
companion object {
private val jaxbContext = JAXBContext.newInstance(
org.oasis_open.committees.ebxml_cppa.schema.cpp_cpa_2_0.ObjectFactory::class.java,
org.oasis_open.committees.ebxml_msg.schema.msg_header_2_0.ObjectFactory::class.java,
org.xmlsoap.schemas.soap.envelope.ObjectFactory::class.java,
org.w3._1999.xlink.ObjectFactory::class.java,
org.w3._2009.xmldsig11_.ObjectFactory::class.java
Expand Down
14 changes: 5 additions & 9 deletions cpa-repo/src/main/kotlin/no/nav/emottak/cpa/persistence/CPA.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package no.nav.emottak.cpa.persistence

import no.nav.emottak.cpa.marshal
import no.nav.emottak.cpa.unmarshal
import org.jetbrains.exposed.sql.Column
import org.jetbrains.exposed.sql.ColumnType
import org.jetbrains.exposed.sql.Table
import org.oasis_open.committees.ebxml_cppa.schema.cpp_cpa_2_0.CollaborationProtocolAgreement

fun <T> readValue(value: String,clazz: Class<T>) : T? {
return null
}

fun writeValue(value: Any) : String = ""

class CPA : Table("cpa") {
val id: Column<String> = varchar("id",256)
val cpa = json("cpa", CollaborationProtocolAgreement::class.java)
Expand All @@ -29,11 +25,11 @@ private fun <T : Any> Table.json(

class JsonColumnType<T : Any>(private val clazz: Class<T>) : ColumnType() {
override fun sqlType(): String =
"jsonb"
"json"

override fun valueFromDB(value: Any): T = readValue(value as String, clazz)!!
override fun valueFromDB(value: Any): T = unmarshal(value as String, clazz)

override fun notNullValueToDB(value: Any): String = writeValue(value)
override fun notNullValueToDB(value: Any): String = marshal(value)

override fun valueToString(value: Any?): String =
when (value) {
Expand Down

0 comments on commit 94d35f6

Please sign in to comment.