-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
cpa-repo/src/main/kotlin/no/nav/emottak/cpa/CPAValidator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package no.nav.emottak.cpa | ||
|
||
import no.nav.emottak.melding.model.Header | ||
import org.oasis_open.committees.ebxml_cppa.schema.cpp_cpa_2_0.CollaborationProtocolAgreement | ||
|
||
|
||
fun CollaborationProtocolAgreement.validate(header: Header) { | ||
|
||
} | ||
|
||
class ValidationException(reason: String) : Exception(reason) |
44 changes: 44 additions & 0 deletions
44
cpa-repo/src/main/kotlin/no/nav/emottak/cpa/persistence/CPA.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package no.nav.emottak.cpa.persistence | ||
|
||
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) | ||
} | ||
|
||
|
||
private fun <T : Any> Table.json( | ||
name: String, | ||
clazz: Class<T> | ||
): Column<T> = | ||
registerColumn( | ||
name = name, | ||
type = JsonColumnType(clazz) | ||
) | ||
|
||
|
||
class JsonColumnType<T : Any>(private val clazz: Class<T>) : ColumnType() { | ||
override fun sqlType(): String = | ||
"jsonb" | ||
|
||
override fun valueFromDB(value: Any): T = readValue(value as String, clazz)!! | ||
|
||
override fun notNullValueToDB(value: Any): String = writeValue(value) | ||
|
||
override fun valueToString(value: Any?): String = | ||
when (value) { | ||
is Iterable<*> -> notNullValueToDB(value) | ||
else -> super.valueToString(value) | ||
} | ||
} | ||
|
6 changes: 6 additions & 0 deletions
6
cpa-repo/src/main/kotlin/no/nav/emottak/cpa/persistence/CPARepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package no.nav.emottak.cpa.persistence | ||
|
||
class CPARepository { | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters