Commit 9117e45d authored by npedot's avatar npedot
Browse files

adds sakila query for film1 mappings

parent 030264f1
...@@ -68,33 +68,15 @@ technology depenent packages ...@@ -68,33 +68,15 @@ technology depenent packages
* A domain component has to depends on nothing. * A domain component has to depends on nothing.
## v0.1.0 ## v1.0.0
from object database meta representation as input SQL-based migrations
apply kotlin transformer vertical or horizontal add liquibase adapter
obtain a second database meta representation as output add flyway adapter
## v0.2.0
from xml object database meta representation as input
apply kotlin transformer vertical or horizontal
obtain a changeset representation as output
## v0.3.0
from xml object database meta representation as input
a generic xpath engine extraction plus freemarker template to generate
obtain a database meta representation as output
## v0.4.0
from xml object database meta representation as input
a xml transfomer descriptor
### to fix ### to fix
* jdbc read views metainfo
* film_id doppio nella tabella film_core. * film_id doppio nella tabella film_core.
* redirect FOREIGN_KEY from splitted table. * redirect FOREIGN_KEY from splitted table.
* remove select PRIMARY KEY not by name, but by source table. * remove select PRIMARY KEY not by name, but by source table.
......
...@@ -44,13 +44,13 @@ class TransformerVUseCase(serializer: IXMLSerializerService, fileIOAdapter: File ...@@ -44,13 +44,13 @@ class TransformerVUseCase(serializer: IXMLSerializerService, fileIOAdapter: File
tranformerParmeters, tranformerParmeters,
StringWriter()) StringWriter())
if (changeSet.size()!=0) { if (changeSet.size()!=0) {
val csFileName = workingDir + "cs_${timestamp.format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss_nnnnnnnnnn"))}.xml" val csFileName = workingDir + "${timestamp.format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss_nnnnnnnnnn"))}_cs.xml"
println("Written cs file $tableToSplit : $csFileName ") println("Written cs file $tableToSplit : $csFileName ")
fileIOAdapter.writeOnWorkingFilePath(serializer.prettyChangeSet(changeSet), csFileName) fileIOAdapter.writeOnWorkingFilePath(serializer.prettyChangeSet(changeSet), csFileName)
} }
val newdb = ApplyChangeSetUseCase(serializer).apply(db, changeSet) val newdb = ApplyChangeSetUseCase(serializer).apply(db, changeSet)
val newDbFileName = workingDir + "db_${timestamp.format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss_nnnnnnnnnn"))}.xml" val newDbFileName = workingDir + "${timestamp.format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss_nnnnnnnnnn"))}_db.xml"
fileIOAdapter.writeOnWorkingFilePath(serializer.prettyDatabase(newdb), newDbFileName) fileIOAdapter.writeOnWorkingFilePath(serializer.prettyDatabase(newdb), newDbFileName)
println("Written db files $tableToSplit : $newDbFileName") println("Written db files $tableToSplit : $newDbFileName")
......
package unibz.cs.semint.kprime.scenario.sakila package unibz.cs.semint.kprime.scenario.sakila
import junit.framework.Assert.assertEquals
import org.junit.Test import org.junit.Test
import unibz.cs.semint.kprime.adapter.repository.QueryJdbcAdapter import unibz.cs.semint.kprime.adapter.repository.QueryJdbcAdapter
import unibz.cs.semint.kprime.adapter.service.XMLSerializerJacksonAdapter
import unibz.cs.semint.kprime.domain.DataSource import unibz.cs.semint.kprime.domain.DataSource
import unibz.cs.semint.kprime.domain.dql.Query import unibz.cs.semint.kprime.domain.dql.Query
import unibz.cs.semint.kprime.domain.dql.Select
import unibz.cs.semint.kprime.usecase.common.SQLizeUseCase
class SakilaQueryTI { class SakilaQueryTI {
...@@ -52,4 +56,43 @@ class SakilaQueryTI { ...@@ -52,4 +56,43 @@ class SakilaQueryTI {
} }
@Test
fun test_sakila_film1_query_to_xml() {
// given
val query = SQLizeUseCase().fromsql("""
SELECT film_id,title,description,release_year,release_year,original_language_id,length,rating
FROM film
""".trimIndent())
// when
var queryXml = XMLSerializerJacksonAdapter().prettyQuery(query) as String
// then
assertEquals("""
<query>
<select>
<attributes>
<attributes name="film_id"/>
<attributes name="title"/>
<attributes name="description"/>
<attributes name="release_year"/>
<attributes name="release_year"/>
<attributes name="original_language_id"/>
<attributes name="length"/>
<attributes name="rating"/>
</attributes>
<from>
<from tableName="film" alias="" joinOn=""/>
</from>
<where condition=""/>
</select>
<union>
<selects/>
</union>
<minus>
<selects/>
</minus>
</query>
""".trimIndent(),queryXml)
}
} }
\ No newline at end of file
...@@ -48,7 +48,7 @@ class OptimusUseCaseTI { ...@@ -48,7 +48,7 @@ class OptimusUseCaseTI {
database.schema database.schema
.addFunctionals("address", "address_id --> address2") .addFunctionals("address", "address_id --> address2")
val rootWorkingDir = "/home/nipe/Temp/" val rootWorkingDir = System.getenv()["tmp_dir"] ?: "" // "/home/nipe/Temp/"
val timestampSuffix = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss_nnnnnnnnnn")) val timestampSuffix = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss_nnnnnnnnnn"))
val workingDir = rootWorkingDir + timestampSuffix + "/" val workingDir = rootWorkingDir + timestampSuffix + "/"
File(workingDir).mkdirs() File(workingDir).mkdirs()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment