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

adds vertical compose PersonTransfomerScenarioTI

parent c58c174f
No related branches found
No related tags found
No related merge requests found
......@@ -50,19 +50,21 @@ class PersonTransfomerScenarioTI {
@Test
fun test_xpath_horizontal_decomposition_on_person_db() {
/*
// given
val dbFilePath = "db/person.xml"
val trasformerName = "horizontal"
val trasformerDirection = "decompose"
val trasformerVersion = "1"
val dbFilePath = "db/person_splitted.xml"
val transfomerXml = PersonTransfomerScenarioTI::class.java.getResource("/transformer/verticalTransfomer.xml").readText()
val vTransfomer = XMLSerializeUseCase(XMLSerializerJacksonAdapter()).deserializeTransformer(transfomerXml).ok
val templateFilePath = vTransfomer!!.composer.template.filename
val xrules = toProperties(vTransfomer!!.composer.xman.xrules)
val tranformerParmeters = mutableMapOf<String,Any>()
tranformerParmeters["table"]="person"
tranformerParmeters["targetTable"]="person"
tranformerParmeters["originTable1"]="person1"
tranformerParmeters["originTable2"]="person2"
println(templateFilePath)
// when
XPathTransformUseCase().transform(dbFilePath, trasformerName, trasformerDirection, trasformerVersion,tranformerParmeters,OutputStreamWriter(System.out))
val newDb = XPathTransformUseCase().transform(dbFilePath, templateFilePath, xrules, tranformerParmeters, StringWriter())
// then
// print to console output
*/
println(newDb)
}
......
<database name="" id="">
<schema name="" id="">
<tables>
<tables name="person2" id="" view="" condition="">
<columns>
<columns name="SSN2" id="id.SSN" dbname="dbname.SSN" nullable="false" dbtype=""/>
<columns name="T2" id="id.T" dbname="dbname.T" nullable="false" dbtype=""/>
<columns name="S2" id="id.S" dbname="dbname.S" nullable="true" dbtype=""/>
<columns name="X2" id="id.X" dbname="dbname.X" nullable="true" dbtype=""/>
</columns>
</tables>
<tables name="person1" id="" view="person" condition="">
<columns>
<columns name="SSN" id="id.SSN" dbname="" nullable="false" dbtype=""/>
<columns name="T" id="id.T" dbname="" nullable="false" dbtype=""/>
<columns name="X" id="id.X" dbname="" nullable="true" dbtype=""/>
</columns>
</tables>
<tables name="person2" id="" view="person" condition="">
<columns>
<columns name="T" id="id.T" dbname="" nullable="false" dbtype=""/>
<columns name="S" id="id.S" dbname="" nullable="false" dbtype=""/>
</columns>
</tables>
</tables>
<constraints>
<constraints name="primaryKey.person" id="" type="PRIMARY_KEY">
<source name="" id="" table="person">
<columns>
<columns name="SSN" id="id.SSN" dbname="dbname.SSN" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="">
<columns>
<columns name="" id="" dbname="" nullable="false" dbtype=""/>
</columns>
</target>
</constraints>
<constraints name="functional.person" id="" type="FUNCTIONAL">
<source name="" id="" table="person">
<columns>
<columns name="T" id="id.T" dbname="dbname.T" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="person">
<columns>
<columns name="S" id="id.S" dbname="dbname.S" nullable="true" dbtype=""/>
</columns>
</target>
</constraints>
<constraints name="person.doubleInclusion" id="" type="DOUBLE_INCLUSION">
<source name="" id="" table="person1">
<columns>
<columns name="T" id="id.T" dbname="" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="person2">
<columns>
<columns name="T" id="id.T" dbname="" nullable="false" dbtype=""/>
</columns>
</target>
</constraints>
<constraints name="person2.primaryKey" id="" type="PRIMARY_KEY">
<source name="" id="" table="person2">
<columns>
<columns name="T" id="id.T" dbname="" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="">
<columns>
<columns name="" id="" dbname="" nullable="false" dbtype=""/>
</columns>
</target>
</constraints>
<constraints name="person1.primaryKey" id="" type="PRIMARY_KEY">
<source name="" id="" table="person1">
<columns>
<columns name="SSN" id="id.SSN" dbname="" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="">
<columns>
<columns name="" id="" dbname="" nullable="false" dbtype=""/>
</columns>
</target>
</constraints>
</constraints>
</schema>
<mapping/>
</database>
\ No newline at end of file
<changeSet id="234">
<createTable name="${targetTable[0]}" id="" view="" condition="">
<columns>
<#list keys as key>
<columns name="${key}" id="id.${key}" dbname="" nullable="false" dbtype=""/>
</#list>
<#list lhss as lhs>
<columns name="${lhs}" id="id.${lhs}" dbname="" nullable="false" dbtype=""/>
</#list>
<#list rhss as rhs>
<columns name="${rhs}" id="id.${rhs}" dbname="" nullable="false" dbtype=""/>
</#list>
</columns>
</createTable>
<createConstraint name="${targetTable[0]}.primaryKey" id="" type="PRIMARY_KEY">
<source name="" id="" table="${targetTable[0]}">
<columns>
<#list keys as key>
<columns name="${key}" id="id.${key}" dbname="" nullable="false" dbtype=""/>
</#list>
</columns>
</source>
<target name="" id="" table="">
<columns>
<columns name="" id="" dbname="" nullable="false" dbtype=""/>
</columns>
</target>
</createConstraint>
<dropTable path="" schemaName="" tableName="${originTable1[0]}"/>
<dropTable path="" schemaName="" tableName="${originTable2[0]}"/>
<dropConstraint path="" schemaName="" constraintName="${originTable1[0]}.primaryKey"/>
<dropConstraint path="" schemaName="" constraintName="${originTable2[0]}.primaryKey"/>
<dropConstraint path="" schemaName="" constraintName="${targetTable[0]}.doubleInclusion"/>
</changeSet>
\ No newline at end of file
keys=/database/schema/constraints/constraints[@type='PRIMARY_KEY']/source[@table='%%originTable1%%']/columns/columns/@name
lhss=/database/schema/tables/tables[@name='%%originTable1%%']/columns/columns/@name > 0
rhss=/database/schema/tables/tables[@name='%%originTable2%%']/columns/columns/@name > 0
\ No newline at end of file
......@@ -2,10 +2,12 @@
<composer>
<xman>
<xrules>
<xrules name="all">/database/schema/tables/tables[@name='%%originTable%%']/columns/columns/@name</xrules>
<xrules name="keys">/database/schema/constraints/constraints[@type='PRIMARY_KEY']/source[@table='%%originTable1%%']/columns/columns/@name</xrules>
<xrules name="lhss">/database/schema/tables/tables[@name='%%originTable1%%']/columns/columns/@name</xrules>
<xrules name="rhss">/database/schema/tables/tables[@name='%%originTable2%%']/columns/columns/@name</xrules>
</xrules>
</xman>
<template filename=""/>
<template filename="transformer/vertical/compose/vertical_changeset_1.template"/>
</composer>
<splitter>
<xman>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment