Commit 3b27baf3 authored by npedot's avatar npedot
Browse files

change xml jackson for list of elements, for tables,columns,constraints,attributes

parent beebc16e
package unibz.cs.semint.kprime.domain.ddl
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement
import unibz.cs.semint.kprime.domain.ddl.schemalgo.*
......@@ -12,8 +13,12 @@ class Schema () {
@JacksonXmlProperty(isAttribute = true)
var id: String=""
@JacksonXmlElementWrapper(localName = "tables")
@JacksonXmlProperty(localName = "table")
var tables: ArrayList<Table>? = ArrayList<Table>()
@JacksonXmlElementWrapper(localName = "constraints")
@JacksonXmlProperty(localName = "constraint")
var constraints: MutableList<Constraint>? = ArrayList<Constraint>()
fun table(name: String): Table? {
......
package unibz.cs.semint.kprime.domain.ddl
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement
......@@ -13,5 +14,7 @@ class Source () {
@JacksonXmlProperty(isAttribute = true)
var table: String=""
@JacksonXmlElementWrapper(localName = "columns")
@JacksonXmlProperty(localName = "column")
var columns= ArrayList<Column>()
}
package unibz.cs.semint.kprime.domain.ddl
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement
......@@ -21,6 +22,8 @@ class Table (): Labelled by Labeller(){
@JacksonXmlProperty(isAttribute = true)
var parent: String? = null
@JacksonXmlElementWrapper(localName = "columns")
@JacksonXmlProperty(localName = "column")
var columns= ArrayList<Column>()
@JacksonXmlProperty(isAttribute = true)
......
package unibz.cs.semint.kprime.domain.ddl
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement
import unibz.cs.semint.kprime.domain.ddl.Column
......@@ -14,5 +15,7 @@ class Target () {
@JacksonXmlProperty(isAttribute = true)
var table: String=""
@JacksonXmlElementWrapper(localName = "columns")
@JacksonXmlProperty(localName = "column")
var columns = ArrayList<Column>()
}
package unibz.cs.semint.kprime.domain.dql
import com.fasterxml.jackson.annotation.JsonPropertyOrder
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement
@JacksonXmlRootElement(localName = "select")
@JsonPropertyOrder("distinct", "attributes", "from", "where", "limit")
class Select {
var distinct: Boolean = false
@JacksonXmlElementWrapper(localName = "attributes")
@JacksonXmlProperty(localName = "attribute")
var attributes : MutableList<Attribute> = ArrayList<Attribute>()
var from = From()
var where = Where()
......
......@@ -48,8 +48,8 @@ class QueryTest {
<select>
<distinct>false</distinct>
<attributes>
<attributes name="Name"/>
<attributes name="Surname"/>
<attribute name="Name"/>
<attribute name="Surname"/>
</attributes>
<from tableName="Table1" alias=""/>
<where condition="Name='Gigi'"/>
......@@ -177,8 +177,8 @@ class QueryTest {
<select>
<distinct>false</distinct>
<attributes>
<attributes name="Name"/>
<attributes name="Surname"/>
<attribute name="Name"/>
<attribute name="Surname"/>
</attributes>
<from tableName="Table1" alias=""/>
<where condition="Name='Gigi'"/>
......@@ -188,8 +188,8 @@ class QueryTest {
<selects>
<distinct>false</distinct>
<attributes>
<attributes name="Name"/>
<attributes name="Surname"/>
<attribute name="Name"/>
<attribute name="Surname"/>
</attributes>
<from tableName="Table2" alias=""/>
<where condition="Name='Gigi'"/>
......
......@@ -59,11 +59,11 @@ class DatabaseTest {
<database name="" id="" source="">
<schema name="" id="">
<tables>
<tables name="pure_person" id="" view="person" condition="person.T=null AND person.S=null">
<table name="pure_person" id="" view="person" condition="person.T=null AND person.S=null">
<columns>
<columns name="SSN" id="id.SSN" dbname="dbname.SSN" nullable="false" dbtype=""/>
<column name="SSN" id="id.SSN" dbname="dbname.SSN" nullable="false" dbtype=""/>
</columns>
</tables>
</table>
</tables>
<constraints/>
</schema>
......
......@@ -63,25 +63,25 @@ class ApplyChangeSetUseCaseTest {
<database name="person" id="" source="">
<schema name="" id="">
<tables>
<tables name="person" id="" view="" condition="">
<table name="person" id="" view="" condition="">
<columns>
<columns name="" id="" nullable="false" dbtype=""/>
<column name="" id="" nullable="false" dbtype=""/>
</columns>
</tables>
</table>
</tables>
<constraints>
<constraints name="person.primaryKey" id="" type="PRIMARY_KEY">
<constraint name="person.primaryKey" id="" type="PRIMARY_KEY">
<source name="" id="" table="">
<columns>
<columns name="" id="" nullable="false" dbtype=""/>
<column name="" id="" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="">
<columns>
<columns name="" id="" nullable="false" dbtype=""/>
<column name="" id="" nullable="false" dbtype=""/>
</columns>
</target>
</constraints>
</constraint>
</constraints>
</schema>
<mappings/>
......@@ -104,37 +104,37 @@ class ApplyChangeSetUseCaseTest {
<database name="person" id="" source="">
<schema name="" id="">
<tables>
<tables name="person1" id="" view="" condition="">
<table name="person1" id="" view="" condition="">
<columns>
<columns name="K" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="T" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="S" id="" nullable="false" dbtype="" dbtable=""/>
<column name="K" id="" nullable="false" dbtype="" dbtable=""/>
<column name="T" id="" nullable="false" dbtype="" dbtable=""/>
<column name="S" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</tables>
<tables name="person2" id="" view="" condition="">
</table>
<table name="person2" id="" view="" condition="">
<columns>
<columns name="T" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="S" id="" nullable="false" dbtype="" dbtable=""/>
<column name="T" id="" nullable="false" dbtype="" dbtable=""/>
<column name="S" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</tables>
</table>
</tables>
<constraints>
<constraints name="" id="" type="DOUBLE_INCLUSION">
<constraint name="" id="" type="DOUBLE_INCLUSION">
<source name="" id="" table="">
<columns/>
</source>
<target name="" id="" table="">
<columns/>
</target>
</constraints>
<constraints name="" id="" type="PRIMARY_KEY">
</constraint>
<constraint name="" id="" type="PRIMARY_KEY">
<source name="" id="" table="">
<columns/>
</source>
<target name="" id="" table="">
<columns/>
</target>
</constraints>
</constraint>
</constraints>
</schema>
<mappings/>
......@@ -200,14 +200,14 @@ class ApplyChangeSetUseCaseTest {
<createConstraint name="pkey_person_surname_name" id="" type="PRIMARY_KEY">
<source name="" id="" table="person">
<columns>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<column name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<column name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</source>
<target name="" id="" table="person">
<columns>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<column name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<column name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</target>
</createConstraint>
......@@ -223,29 +223,29 @@ class ApplyChangeSetUseCaseTest {
<database name="" id="" source="">
<schema name="" id="">
<tables>
<tables name="person" id="t1" view="" condition="">
<table name="person" id="t1" view="" condition="">
<columns>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="address" id="" nullable="false" dbtype="" dbtable=""/>
<column name="name" id="" nullable="false" dbtype="" dbtable=""/>
<column name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<column name="address" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</tables>
</table>
</tables>
<constraints>
<constraints name="pkey_person_surname_name" id="" type="PRIMARY_KEY">
<constraint name="pkey_person_surname_name" id="" type="PRIMARY_KEY">
<source name="" id="" table="person">
<columns>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<column name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<column name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</source>
<target name="" id="" table="person">
<columns>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<column name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<column name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</target>
</constraints>
</constraint>
</constraints>
</schema>
<mappings/>
......@@ -281,14 +281,14 @@ class ApplyChangeSetUseCaseTest {
<createConstraint name="person_employee.doubleInc1" id="cdi1" type="DOUBLE_INCLUSION">
<source name="" id="" table="person">
<columns>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<column name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<column name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</source>
<target name="" id="" table="employee">
<columns>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<column name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<column name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</target>
</createConstraint>
......@@ -302,36 +302,36 @@ class ApplyChangeSetUseCaseTest {
val expectedDb ="""<database name="" id="" source="">
<schema name="" id="">
<tables>
<tables name="person" id="t1" view="" condition="">
<table name="person" id="t1" view="" condition="">
<columns>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="address" id="" nullable="false" dbtype="" dbtable=""/>
<column name="name" id="" nullable="false" dbtype="" dbtable=""/>
<column name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<column name="address" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</tables>
<tables name="employee" id="t2" view="" condition="">
</table>
<table name="employee" id="t2" view="" condition="">
<columns>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="salary" id="" nullable="false" dbtype="" dbtable=""/>
<column name="name" id="" nullable="false" dbtype="" dbtable=""/>
<column name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<column name="salary" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</tables>
</table>
</tables>
<constraints>
<constraints name="person_employee.doubleInc1" id="cdi1" type="DOUBLE_INCLUSION">
<constraint name="person_employee.doubleInc1" id="cdi1" type="DOUBLE_INCLUSION">
<source name="" id="" table="person">
<columns>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<column name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<column name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</source>
<target name="" id="" table="employee">
<columns>
<columns name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<columns name="name" id="" nullable="false" dbtype="" dbtable=""/>
<column name="surname" id="" nullable="false" dbtype="" dbtable=""/>
<column name="name" id="" nullable="false" dbtype="" dbtable=""/>
</columns>
</target>
</constraints>
</constraint>
</constraints>
</schema>
<mappings/>
......
......@@ -75,8 +75,8 @@ class XMLSerializerChangeSetTest {
<select>
<distinct>false</distinct>
<attributes>
<attributes name="Name"/>
<attributes name="Surname"/>
<attribute name="Name"/>
<attribute name="Surname"/>
</attributes>
<from tableName="film" alias=""/>
<where condition="Name='Gigi'"/>
......
......@@ -65,9 +65,9 @@ class XMLSerializerDatabaseTest {
<database name="dbname" id="iddb" source="">
<schema name="" id="idschema">
<tables>
<tables name="" id="" view="" condition="">
<table name="" id="" view="" condition="">
<columns/>
</tables>
</table>
</tables>
<constraints/>
</schema>
......@@ -76,7 +76,7 @@ class XMLSerializerDatabaseTest {
<select>
<distinct>false</distinct>
<attributes>
<attributes name="name"/>
<attribute name="name"/>
</attributes>
<from tableName="people" alias=""/>
<where condition=""/>
......
......@@ -40,7 +40,7 @@ class XMLSerializerTableTest {
val result = serializer.serializeTable(table).ok
// then
assertEquals("<table name=\"Gigi\" id=\"22\" view=\"\" condition=\"\"><columns><columns name=\"col1\" id=\"id1\" dbname=\"dbname1\" nullable=\"false\" dbtype=\"\"/><columns name=\"col2\" id=\"id2\" dbname=\"dbname2\" nullable=\"false\" dbtype=\"\"/></columns></table>",result)
assertEquals("<table name=\"Gigi\" id=\"22\" view=\"\" condition=\"\"><columns><column name=\"col1\" id=\"id1\" dbname=\"dbname1\" nullable=\"false\" dbtype=\"\"/><column name=\"col2\" id=\"id2\" dbname=\"dbname2\" nullable=\"false\" dbtype=\"\"/></columns></table>",result)
}
@Test
......
<constraint name="" id="idconst1" type="FOREIGN_KEY">
<source name="" id="" table="">
<columns>
<columns name="" id="" dbtype="" nullable="false"/>
<column name="" id="" dbtype="" nullable="false"/>
</columns>
</source>
<target name="" id="" table="">
<columns>
<columns name="" id="" dbtype="" nullable="false"/>
<column name="" id="" dbtype="" nullable="false"/>
</columns>
</target>
</constraint>
\ No newline at end of file
<constraint name="" id="idconst1" type="PRIMARY_KEY">
<source name="" id="" table="">
<columns>
<columns name="" id="" dbtype="" nullable="false"/>
<columns name="" id="" dbtype="" nullable="false"/>
<columns name="" id="" dbtype="" nullable="false"/>
<column name="" id="" dbtype="" nullable="false"/>
<column name="" id="" dbtype="" nullable="false"/>
<column name="" id="" dbtype="" nullable="false"/>
</columns>
</source>
<target name="" id="" table="">
......
<constraint name="" id="idconst1" type="">
<source name="" id="" table="">
<columns>
<columns name="" id="" nullable="false" dbtype=""/>
<columns name="" id="" nullable="false" dbtype=""/>
<column name="" id="" nullable="false" dbtype=""/>
<column name="" id="" nullable="false" dbtype=""/>
</columns>
</source>
<target name="" id="" table="">
<columns>
<columns name="" id="" nullable="false" dbtype=""/>
<columns name="" id="" nullable="false" dbtype=""/>
<columns name="" id="" nullable="false" dbtype=""/>
<column name="" id="" nullable="false" dbtype=""/>
<column name="" id="" nullable="false" dbtype=""/>
<column name="" id="" nullable="false" dbtype=""/>
</columns>
</target>
</constraint>
\ No newline at end of file
<database name="dbname" id="iddb" source="">
<schema name="" id="idschema">
<tables>
<tables name="" id="" condition="" view="">
<table name="" id="" condition="" view="">
<columns/>
</tables>
<tables name="" id="" condition="" view="">
</table>
<table name="" id="" condition="" view="">
<columns/>
</tables>
</table>
</tables>
<constraints/>
</schema>
......
<table name="Gigi" id="23" view="" condition="">
<columns>
<columns name="col1" id="id1" dbname="dbname1" dbtype="" nullable="false"/>
<columns name="col2" id="id2" dbname="dbname2" dbtype="" nullable="false"/>
<column name="col1" id="id1" dbname="dbname1" dbtype="" nullable="false"/>
<column name="col2" id="id2" dbname="dbname2" dbtype="" nullable="false"/>
</columns>
</table>
\ No newline at end of file
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