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

adds xpath transform use case test (WIP ignore)

parent b9a49b4d
No related branches found
No related tags found
No related merge requests found
......@@ -62,6 +62,10 @@ class Schema () {
return constraints().filter { c -> c.type.equals(Constraint.TYPE.FOREIGN_KEY.name) }
}
fun foreignsTable(tableName: String): List<Constraint> {
return foreignKeys().filter { f -> f.source.table.equals(tableName) }
}
fun doubleIncs(): List<Constraint> {
return constraints().filter { c -> c.type.equals(Constraint.TYPE.DOUBLE_INCLUSION.name) }
}
......
......@@ -69,7 +69,9 @@ class XPathTransformUseCase {
var newline = line
for (key in tranformerParmeters.keys) {
val newValue = (tranformerParmeters[key] as List<String>).get(0)
newline = newline.replace("%%${key}%%", newValue)
println(" *************************** XPathTransformUseCase.parametrized(): ${key} == ${newValue}")
newline = newline.replace("${key}", newValue)
println(newline)
}
return newline
}
......@@ -164,6 +166,9 @@ class XPathTransformUseCase {
templ = templConfig.getTemplate(templateFilePath)
}
val outWriter = StringWriter()
for(ent in templModel) {
println("${ent.key} === ${ent.value}")
}
templ.process(templModel, outWriter)
println("33++++++++++++++++++++++++++++++++++++++++++-------------------------------")
......@@ -189,7 +194,7 @@ class XPathTransformUseCase {
var violation = ""
for (xPathLine in xPaths) {
//println("------------------------------------------")
if (xPathLine.startsWith("%%")) continue
if (xPathLine.startsWith("((")) continue
val xPathTokens = xPathLine.split("==")
val name = xPathTokens[0]
val rule = xPathTokens[1]
......
......@@ -150,7 +150,7 @@ class TransformerXUseCase(
private fun checkRequiredParams(xPathProperties: List<String>, transformerParams: Map<String, Any>): Pair<MutableList<String>, List<String>> {
var xPathProperties1 = xPathProperties
val failedCheckRequiredParams = mutableListOf<String>()
if (xPathProperties1.size > 0 && xPathProperties1[0].startsWith("%%")) {
if (xPathProperties1.size > 0 && xPathProperties1[0].startsWith("((")) {
// check required params
val requireds = xPathProperties1[0].split(",")
for (required in requireds) {
......@@ -172,7 +172,7 @@ class TransformerXUseCase(
if (!File(dbFilePath).isFile) return Applicability(false,"db name ${dbFilePath} not exists", transformerParams)
if (xPathProperties.size>0 && xPathProperties[0].startsWith("%%")) {
if (xPathProperties.size>0 && xPathProperties[0].startsWith("((")) {
// check required params
val requireds = xPathProperties[0].split(",")
for (required in requireds) {
......
<changeSet id="234">
<createTable name="${table[0]}1" id="" view="${table[0]}" condition="${condition1}">
<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>
<#list rests as rest>
<columns name="${rest}" id="id.${rest}" dbname="" nullable="true" dbtype=""/>
</#list>
</columns>
</createTable>
<createTable name="${table[0]}2" id="" view="${table[0]}" condition="${condition2}">
<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>
<#list rests as rest>
<columns name="${rest}" id="id.${rest}" dbname="" nullable="true" dbtype=""/>
<changeSet id="345">
<createTable name="${((originTable))}_1" id="" view="${((originTable))}" condition="${((condition))}">
<columns>
<#list all as att1>
<columns name="${att1}" id="id.${att1}" dbname="" nullable="false" dbtype=""/>
</#list>
</columns>
</createTable>
<createConstraint name="${table[0]}.doubleInclusion" id="" type="DOUBLE_INCLUSION">
<source name="" id="" table="${table[0]}1">
<columns>
<#list lhss as lhs>
<columns name="${lhs}" id="id.${lhs}" dbname="" nullable="false" dbtype=""/>
</#list>
</columns>
</source>
<target name="" id="" table="${table[0]}2">
<columns>
<#list lhss as lhs>
<columns name="${lhs}" id="id.${lhs}" dbname="" nullable="false" dbtype=""/>
</#list>
</columns>
</target>
</createConstraint>
<createConstraint name="${table[0]}2.primaryKey" id="" type="PRIMARY_KEY">
<source name="" id="" table="${table[0]}2">
<columns>
<#list lhss as lhs>
<columns name="${lhs}" id="id.${lhs}" dbname="" nullable="false" dbtype=""/>
</#list>
</columns>
</source>
<target name="" id="" table="">
<columns>
<columns name="" id="" dbname="" nullable="false" dbtype=""/>
</columns>
</target>
</createConstraint>
<createConstraint name="${table[0]}1.primaryKey" id="" type="PRIMARY_KEY">
<source name="" id="" table="${table[0]}1">
<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="${table[0]}"/>
<dropConstraint path="" schemaName="" constraintName="${table[0]}.primaryKey"/>
</changeSet>
\ No newline at end of file
</createTable>
</changeSet>
originTable==/database/schema/constraints/constraints[@type='FUNCTIONAL']/source/@table > 0
all==/database/schema/tables/tables[@name='%%originTable%%']/columns/columns/@name
keys==/database/schema/constraints/constraints[@type='PRIMARY_KEY']/source[@table='%%originTable%%']/columns/columns/@name
lhss==/database/schema/constraints/constraints[@type='FUNCTIONAL']/source[@table='%%originTable%%']/columns/columns/@name > 0
rhss==/database/schema/constraints/constraints[@type='FUNCTIONAL']/target[@table='%%originTable%%']/columns/columns/@name > 0
all==/database/schema/tables/tables[@name='((originTable))']/columns/columns/@name
keys==/database/schema/constraints/constraints[@type='PRIMARY_KEY']/source[@table='((originTable))']/columns/columns/@name
lhss==/database/schema/constraints/constraints[@type='FUNCTIONAL']/source[@table='((originTable))']/columns/columns/@name > 0
rhss==/database/schema/constraints/constraints[@type='FUNCTIONAL']/target[@table='((originTable))']/columns/columns/@name > 0
rests==- all keys lhss rhss
table==/database/schema/tables/tables[@name='%%originTable%%']/@name
table==/database/schema/tables/tables[@name='((originTable))']/@name
view1==+ keys lhss rests
view2==+ lhss rhss
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment