Skip to content
Snippets Groups Projects
Commit e01bc17c authored by npedot's avatar npedot
Browse files

refacts sakila scenario from starter

parent b47d6258
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@
<version>1.0-SNAPSHOT</version>
<properties>
<main.class>unibz.cs.semint.kprime.StarterKt</main.class>
<main.class>unibz.cs.semint.kprime.Starter</main.class>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
......
package unibz.cs.semint.kprime
import unibz.cs.semint.kprime.adapter.repository.MetaSchemaJdbcAdapter
import unibz.cs.semint.kprime.adapter.service.XMLSerializerJacksonAdapter
import unibz.cs.semint.kprime.domain.DataSource
import unibz.cs.semint.kprime.domain.Database
import unibz.cs.semint.kprime.usecase.MetaSchemaReadUseCase
class SakilaScenario {
fun run() {
val sakilaMeta = readSakilaMeta()
if (sakilaMeta!=null) {
vsplitSakila(sakilaMeta)
hsplitSakila(sakilaMeta)
identifySakila(sakilaMeta)
}
}
private fun readSakilaMeta(): Database? {
val type = "psql"
val name = "sakila-source"
val driver = "org.postgresql.Driver"
val path = "jdbc:postgresql://localhost:5432/sakila"
val user = "sammy"
val pass = "pass"
val sakilaSource = DataSource(type,name,driver,path,user,pass)
val result = MetaSchemaReadUseCase().doit(sakilaSource,
"read-meta-schema sakila-source",
MetaSchemaJdbcAdapter(),
XMLSerializerJacksonAdapter())
return result.ok
}
private fun vsplitSakila(db: Database) {
// if detect(db):result
// apply(db,result):db
}
private fun hsplitSakila(db: Database) {
// if detect(db):result
// apply(db,result):db
}
private fun identifySakila(db: Database) {
// if detect(db):result
// apply(db,result):db
}
}
\ No newline at end of file
package unibz.cs.semint.kprime
import unibz.cs.semint.kprime.adapter.repository.MetaSchemaJdbcAdapter
import unibz.cs.semint.kprime.adapter.service.XMLSerializerJacksonAdapter
import unibz.cs.semint.kprime.domain.DataSource
import unibz.cs.semint.kprime.domain.Database
import unibz.cs.semint.kprime.usecase.MetaSchemaReadUseCase
class Starter {
companion object {
fun main(args:Array<String>) {
val version = "0.1.0-SNAPSHOT"
println("KPrime $version")
val sakilaMeta = readSakilaMeta()
if (sakilaMeta!=null) {
vsplitSakila(sakilaMeta)
hsplitSakila(sakilaMeta)
identifySakila(sakilaMeta)
}
}
fun readSakilaMeta():Database? {
val type = "psql"
val name = "sakila-source"
val driver = "org.postgresql.Driver"
val path = "jdbc:postgresql://localhost:5432/sakila"
val user = "sammy"
val pass = "pass"
val sakilaSource = DataSource(type,name,driver,path,user,pass)
val result = MetaSchemaReadUseCase().doit(sakilaSource,
"read-meta-schema sakila-source",
MetaSchemaJdbcAdapter(),
XMLSerializerJacksonAdapter())
return result.ok
}
fun vsplitSakila(db:Database) {
// if detect(db):result
// apply(db,result):db
}
fun hsplitSakila(db:Database) {
// if detect(db):result
// apply(db,result):db
}
/**
* Reads arguments from command lines and eventually gives then as scenario parameters.
*/
fun main(args:Array<String>) {
val version = "0.1.0-SNAPSHOT"
println("KPrime $version")
SakilaScenario().run()
}
fun identifySakila(db:Database) {
// if detect(db):result
// apply(db,result):db
}
}
}
\ No newline at end of file
......@@ -3,10 +3,18 @@ package unibz.cs.semint.kprime
import org.junit.Test
import org.junit.Assert.*
class StarterTest {
/**
* Applies Starter to local Sakila Postgres Example.
*/
class StarterTI {
@Test
fun test_starter() {
// given
val args = arrayOf<String>()
// when
Starter.main(args)
// then
assertEquals("Alfa", "Alfa")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment