mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
ALF-11668: Add position identifiers (same as seq elements in current schema dump tool)
As for current schemadump tool, table columns and primary key column names have order associated with them. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32296 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.util.schemacomp;
|
package org.alfresco.util.schemacomp;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.util.schemacomp.model.Column;
|
import org.alfresco.util.schemacomp.model.Column;
|
||||||
@@ -136,6 +135,11 @@ public class DbObjectXMLTransformer
|
|||||||
Index index = (Index) dbObject;
|
Index index = (Index) dbObject;
|
||||||
attribs.addAttribute("", "", XML.ATTR_UNIQUE, "CDATA", Boolean.toString(index.isUnique()));
|
attribs.addAttribute("", "", XML.ATTR_UNIQUE, "CDATA", Boolean.toString(index.isUnique()));
|
||||||
}
|
}
|
||||||
|
else if (dbObject instanceof Column)
|
||||||
|
{
|
||||||
|
Column column = (Column) dbObject;
|
||||||
|
attribs.addAttribute("", "", XML.ATTR_ORDER, "CDATA", Integer.toString(column.getOrder()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transformDbObject(DbObject dbObject) throws SAXException
|
private void transformDbObject(DbObject dbObject) throws SAXException
|
||||||
@@ -223,12 +227,12 @@ public class DbObjectXMLTransformer
|
|||||||
|
|
||||||
private void transformIndex(Index index) throws SAXException
|
private void transformIndex(Index index) throws SAXException
|
||||||
{
|
{
|
||||||
columnNameList(index.getColumnNames());
|
columnNameList(index.getColumnNames(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void transformPrimaryKey(PrimaryKey pk) throws SAXException
|
private void transformPrimaryKey(PrimaryKey pk) throws SAXException
|
||||||
{
|
{
|
||||||
columnNameList(pk.getColumnNames());
|
columnNameList(pk.getColumnNames(), pk.getColumnOrders());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -260,12 +264,40 @@ public class DbObjectXMLTransformer
|
|||||||
xmlOut.endElement("", "", tag);
|
xmlOut.endElement("", "", tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void columnNameList(Collection<String> columnNames) throws SAXException
|
/**
|
||||||
|
* Outputs a list of columnname elements sandwiched within a columnnames element.
|
||||||
|
* <p>
|
||||||
|
* The columnOrders parameter will provide a corresponding list of integers that will be
|
||||||
|
* provided in each columnname element's order attribute. This parameter may be null
|
||||||
|
* in which case order attributes will be ommitted.
|
||||||
|
*
|
||||||
|
* @param columnNames
|
||||||
|
* @param columnOrders
|
||||||
|
* @throws SAXException
|
||||||
|
*/
|
||||||
|
private void columnNameList(List<String> columnNames,
|
||||||
|
List<Integer> columnOrders) throws SAXException
|
||||||
{
|
{
|
||||||
simpleStartTag(XML.EL_COLUMN_NAMES);
|
simpleStartTag(XML.EL_COLUMN_NAMES);
|
||||||
for (String columnName : columnNames)
|
for (int i = 0; i < columnNames.size(); i++)
|
||||||
{
|
{
|
||||||
simpleElement(XML.EL_COLUMN_NAME, columnName);
|
String columnName = columnNames.get(i);
|
||||||
|
|
||||||
|
final AttributesImpl attribs = new AttributesImpl();
|
||||||
|
if (columnOrders != null)
|
||||||
|
{
|
||||||
|
int columnOrder = columnOrders.get(i);
|
||||||
|
attribs.addAttribute("", "", XML.ATTR_ORDER, "CDATA", Integer.toString(columnOrder));
|
||||||
|
}
|
||||||
|
// Create a <columnname> or <columnname order="n"> start tag
|
||||||
|
xmlOut.startElement("", "", XML.EL_COLUMN_NAME, attribs);
|
||||||
|
|
||||||
|
// Provide the elements content
|
||||||
|
char[] chars = columnName.toCharArray();
|
||||||
|
xmlOut.characters(chars, 0, chars.length);
|
||||||
|
|
||||||
|
// Provide the closing tag
|
||||||
|
simpleEndTag(XML.EL_COLUMN_NAME);
|
||||||
}
|
}
|
||||||
simpleEndTag(XML.EL_COLUMN_NAMES);
|
simpleEndTag(XML.EL_COLUMN_NAMES);
|
||||||
}
|
}
|
||||||
|
@@ -105,13 +105,13 @@ public class DbObjectXMLTransformerTest
|
|||||||
public void transformColumn() throws IOException
|
public void transformColumn() throws IOException
|
||||||
{
|
{
|
||||||
Column column = new Column(null, "last_name", "VARCHAR2(100)", true);
|
Column column = new Column(null, "last_name", "VARCHAR2(100)", true);
|
||||||
|
column.setOrder(2);
|
||||||
transformer.output(column);
|
transformer.output(column);
|
||||||
|
|
||||||
BufferedReader reader = new BufferedReader(new StringReader(writer.toString()));
|
BufferedReader reader = new BufferedReader(new StringReader(writer.toString()));
|
||||||
dumpOutput();
|
dumpOutput();
|
||||||
assertHasPreamble(reader);
|
assertHasPreamble(reader);
|
||||||
assertEquals("<column name=\"last_name\">", reader.readLine());
|
assertEquals("<column name=\"last_name\" order=\"2\">", reader.readLine());
|
||||||
assertEquals(" <type>VARCHAR2(100)</type>", reader.readLine());
|
assertEquals(" <type>VARCHAR2(100)</type>", reader.readLine());
|
||||||
assertEquals(" <nullable>true</nullable>", reader.readLine());
|
assertEquals(" <nullable>true</nullable>", reader.readLine());
|
||||||
assertEquals("</column>", reader.readLine());
|
assertEquals("</column>", reader.readLine());
|
||||||
@@ -159,7 +159,11 @@ public class DbObjectXMLTransformerTest
|
|||||||
@Test
|
@Test
|
||||||
public void transformPrimaryKey() throws IOException
|
public void transformPrimaryKey() throws IOException
|
||||||
{
|
{
|
||||||
PrimaryKey pk = new PrimaryKey(null, "pk_name", Arrays.asList("first", "second"));
|
PrimaryKey pk = new PrimaryKey(
|
||||||
|
null,
|
||||||
|
"pk_name",
|
||||||
|
Arrays.asList("a_column", "b_column"),
|
||||||
|
Arrays.asList(2, 1));
|
||||||
|
|
||||||
transformer.output(pk);
|
transformer.output(pk);
|
||||||
|
|
||||||
@@ -168,8 +172,8 @@ public class DbObjectXMLTransformerTest
|
|||||||
assertHasPreamble(reader);
|
assertHasPreamble(reader);
|
||||||
assertEquals("<primarykey name=\"pk_name\">", reader.readLine());
|
assertEquals("<primarykey name=\"pk_name\">", reader.readLine());
|
||||||
assertEquals(" <columnnames>", reader.readLine());
|
assertEquals(" <columnnames>", reader.readLine());
|
||||||
assertEquals(" <columnname>first</columnname>", reader.readLine());
|
assertEquals(" <columnname order=\"2\">a_column</columnname>", reader.readLine());
|
||||||
assertEquals(" <columnname>second</columnname>", reader.readLine());
|
assertEquals(" <columnname order=\"1\">b_column</columnname>", reader.readLine());
|
||||||
assertEquals(" </columnnames>", reader.readLine());
|
assertEquals(" </columnnames>", reader.readLine());
|
||||||
assertEquals("</primarykey>", reader.readLine());
|
assertEquals("</primarykey>", reader.readLine());
|
||||||
}
|
}
|
||||||
@@ -178,7 +182,7 @@ public class DbObjectXMLTransformerTest
|
|||||||
public void transformSchema() throws IOException
|
public void transformSchema() throws IOException
|
||||||
{
|
{
|
||||||
Collection<Column> columns = columns("one VARCHAR2(100)", "two NUMBER(10)");
|
Collection<Column> columns = columns("one VARCHAR2(100)", "two NUMBER(10)");
|
||||||
PrimaryKey pk = new PrimaryKey(null, "pk_for_my_table", Arrays.asList("id"));
|
PrimaryKey pk = new PrimaryKey(null, "pk_for_my_table", Arrays.asList("id"), Arrays.asList(1));
|
||||||
Collection<ForeignKey> fks = fkeys(fk("fk_one", "lc", "tt", "tc"), fk("fk_two", "lc", "tt", "tc"));
|
Collection<ForeignKey> fks = fkeys(fk("fk_one", "lc", "tt", "tc"), fk("fk_two", "lc", "tt", "tc"));
|
||||||
Collection<Index> indexes = indexes("index_one col1 col2", "index_two col3 col4");
|
Collection<Index> indexes = indexes("index_one col1 col2", "index_two col3 col4");
|
||||||
|
|
||||||
@@ -225,7 +229,7 @@ public class DbObjectXMLTransformerTest
|
|||||||
public void transformTable() throws IOException
|
public void transformTable() throws IOException
|
||||||
{
|
{
|
||||||
Collection<Column> columns = columns("one VARCHAR2(100)", "two NUMBER(10)");
|
Collection<Column> columns = columns("one VARCHAR2(100)", "two NUMBER(10)");
|
||||||
PrimaryKey pk = new PrimaryKey(null, "pk_for_my_table", Arrays.asList("id"));
|
PrimaryKey pk = new PrimaryKey(null, "pk_for_my_table", Arrays.asList("id"), Arrays.asList(1));
|
||||||
Collection<ForeignKey> fks = fkeys(fk("fk_one", "lc", "tt", "tc"), fk("fk_two", "lc", "tt", "tc"));
|
Collection<ForeignKey> fks = fkeys(fk("fk_one", "lc", "tt", "tc"), fk("fk_two", "lc", "tt", "tc"));
|
||||||
Collection<Index> indexes = indexes("index_one col1 col2", "index_two col3 col4");
|
Collection<Index> indexes = indexes("index_one col1 col2", "index_two col3 col4");
|
||||||
|
|
||||||
@@ -258,7 +262,7 @@ public class DbObjectXMLTransformerTest
|
|||||||
public void transformObjectWithValidators() throws IOException
|
public void transformObjectWithValidators() throws IOException
|
||||||
{
|
{
|
||||||
Collection<Column> columns = columns("one VARCHAR2(100)", "two NUMBER(10)");
|
Collection<Column> columns = columns("one VARCHAR2(100)", "two NUMBER(10)");
|
||||||
PrimaryKey pk = new PrimaryKey(null, "pk_for_my_table", Arrays.asList("id"));
|
PrimaryKey pk = new PrimaryKey(null, "pk_for_my_table", Arrays.asList("id"), Arrays.asList(1));
|
||||||
Collection<ForeignKey> fks = fkeys(fk("fk_one", "lc", "tt", "tc"), fk("fk_two", "lc", "tt", "tc"));
|
Collection<ForeignKey> fks = fkeys(fk("fk_one", "lc", "tt", "tc"), fk("fk_two", "lc", "tt", "tc"));
|
||||||
Collection<Index> indexes = indexes("index_one col1 col2", "index_two col3 col4");
|
Collection<Index> indexes = indexes("index_one col1 col2", "index_two col3 col4");
|
||||||
|
|
||||||
|
@@ -230,6 +230,9 @@ public class ExportDb
|
|||||||
|
|
||||||
String nullableString = columns.getString("IS_NULLABLE");
|
String nullableString = columns.getString("IS_NULLABLE");
|
||||||
column.setNullable(parseBoolean(nullableString));
|
column.setNullable(parseBoolean(nullableString));
|
||||||
|
|
||||||
|
column.setOrder(columns.getInt("ORDINAL_POSITION"));
|
||||||
|
|
||||||
column.setParent(table);
|
column.setParent(table);
|
||||||
table.getColumns().add(column);
|
table.getColumns().add(column);
|
||||||
}
|
}
|
||||||
@@ -250,6 +253,9 @@ public class ExportDb
|
|||||||
}
|
}
|
||||||
String columnName = primarykeycols.getString("COLUMN_NAME");
|
String columnName = primarykeycols.getString("COLUMN_NAME");
|
||||||
pk.getColumnNames().add(columnName);
|
pk.getColumnNames().add(columnName);
|
||||||
|
|
||||||
|
int columnOrder = primarykeycols.getInt("KEY_SEQ");
|
||||||
|
pk.getColumnOrders().add(columnOrder);
|
||||||
}
|
}
|
||||||
primarykeycols.close();
|
primarykeycols.close();
|
||||||
|
|
||||||
|
@@ -34,6 +34,6 @@ import org.junit.runners.Suite;
|
|||||||
ValidatorTestSuite.class,
|
ValidatorTestSuite.class,
|
||||||
SchemaCompTestSuite.class
|
SchemaCompTestSuite.class
|
||||||
})
|
})
|
||||||
public class SchemaCompPackagetTestSuite
|
public class SchemaCompPackageTestSuite
|
||||||
{
|
{
|
||||||
}
|
}
|
@@ -20,6 +20,7 @@ package org.alfresco.util.schemacomp;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -84,6 +85,7 @@ public class SchemaCompTestingUtils
|
|||||||
{
|
{
|
||||||
String[] parts = colDefs[i].split(" ");
|
String[] parts = colDefs[i].split(" ");
|
||||||
columns[i] = new Column(null, parts[0], parts[1], false);
|
columns[i] = new Column(null, parts[0], parts[1], false);
|
||||||
|
columns[i].setOrder(i+1);
|
||||||
}
|
}
|
||||||
return Arrays.asList(columns);
|
return Arrays.asList(columns);
|
||||||
}
|
}
|
||||||
@@ -91,7 +93,14 @@ public class SchemaCompTestingUtils
|
|||||||
public static PrimaryKey pk(String name, String... columnNames)
|
public static PrimaryKey pk(String name, String... columnNames)
|
||||||
{
|
{
|
||||||
assertTrue("No columns specified", columnNames.length > 0);
|
assertTrue("No columns specified", columnNames.length > 0);
|
||||||
PrimaryKey pk = new PrimaryKey(null, name, Arrays.asList(columnNames));
|
// Create a list of column orders, ordered the same as the supplied column names
|
||||||
|
// i.e. 1, 2, 3... N
|
||||||
|
List<Integer> columnOrders = new ArrayList<Integer>(columnNames.length);
|
||||||
|
for (int i = 1; i <= columnNames.length; i++)
|
||||||
|
{
|
||||||
|
columnOrders.add(i);
|
||||||
|
}
|
||||||
|
PrimaryKey pk = new PrimaryKey(null, name, Arrays.asList(columnNames), columnOrders);
|
||||||
return pk;
|
return pk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,6 +51,7 @@ public abstract class XML
|
|||||||
public static final String EL_PROPERTY = "property";
|
public static final String EL_PROPERTY = "property";
|
||||||
|
|
||||||
public static final String ATTR_NAME = "name";
|
public static final String ATTR_NAME = "name";
|
||||||
|
public static final String ATTR_ORDER = "order";
|
||||||
public static final String ATTR_UNIQUE = "unique";
|
public static final String ATTR_UNIQUE = "unique";
|
||||||
public static final String ATTR_CLASS = "class";
|
public static final String ATTR_CLASS = "class";
|
||||||
}
|
}
|
||||||
|
@@ -212,7 +212,22 @@ public class XMLToSchema extends DefaultHandler
|
|||||||
}
|
}
|
||||||
else if (qName.equals(XML.EL_COLUMN))
|
else if (qName.equals(XML.EL_COLUMN))
|
||||||
{
|
{
|
||||||
stack.push(new Column(atts.getValue(XML.ATTR_NAME)));
|
Column column = new Column(atts.getValue(XML.ATTR_NAME));
|
||||||
|
if (atts.getValue(XML.ATTR_ORDER) != null)
|
||||||
|
{
|
||||||
|
int order = Integer.parseInt(atts.getValue(XML.ATTR_ORDER));
|
||||||
|
column.setOrder(order);
|
||||||
|
}
|
||||||
|
stack.push(column);
|
||||||
|
}
|
||||||
|
else if (qName.equals(XML.EL_COLUMN_NAME))
|
||||||
|
{
|
||||||
|
if (stack.peek() instanceof PrimaryKey && atts.getValue(XML.ATTR_ORDER) != null)
|
||||||
|
{
|
||||||
|
PrimaryKey pk = (PrimaryKey) stack.peek();
|
||||||
|
Integer columnOrder = Integer.parseInt(atts.getValue(XML.ATTR_ORDER));
|
||||||
|
pk.getColumnOrders().add(columnOrder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (qName.equals(XML.EL_PRIMARY_KEY))
|
else if (qName.equals(XML.EL_PRIMARY_KEY))
|
||||||
{
|
{
|
||||||
|
@@ -80,21 +80,25 @@ public class XMLToSchemaTest
|
|||||||
assertEquals("id", table.getColumns().get(0).getName());
|
assertEquals("id", table.getColumns().get(0).getName());
|
||||||
assertEquals("NUMBER(10)", table.getColumns().get(0).getType());
|
assertEquals("NUMBER(10)", table.getColumns().get(0).getType());
|
||||||
assertEquals(false, table.getColumns().get(0).isNullable());
|
assertEquals(false, table.getColumns().get(0).isNullable());
|
||||||
|
assertEquals(1, table.getColumns().get(0).getOrder());
|
||||||
|
|
||||||
assertSame("Wrong or no parent set", table, table.getColumns().get(1).getParent());
|
assertSame("Wrong or no parent set", table, table.getColumns().get(1).getParent());
|
||||||
assertEquals("nodeRef", table.getColumns().get(1).getName());
|
assertEquals("nodeRef", table.getColumns().get(1).getName());
|
||||||
assertEquals("VARCHAR2(200)", table.getColumns().get(1).getType());
|
assertEquals("VARCHAR2(200)", table.getColumns().get(1).getType());
|
||||||
assertEquals(false, table.getColumns().get(1).isNullable());
|
assertEquals(false, table.getColumns().get(1).isNullable());
|
||||||
|
assertEquals(3, table.getColumns().get(1).getOrder());
|
||||||
|
|
||||||
assertSame("Wrong or no parent set", table, table.getColumns().get(2).getParent());
|
assertSame("Wrong or no parent set", table, table.getColumns().get(2).getParent());
|
||||||
assertEquals("name", table.getColumns().get(2).getName());
|
assertEquals("name", table.getColumns().get(2).getName());
|
||||||
assertEquals("VARCHAR2(150)", table.getColumns().get(2).getType());
|
assertEquals("VARCHAR2(150)", table.getColumns().get(2).getType());
|
||||||
assertEquals(true, table.getColumns().get(2).isNullable());
|
assertEquals(true, table.getColumns().get(2).isNullable());
|
||||||
|
assertEquals(2, table.getColumns().get(2).getOrder());
|
||||||
|
|
||||||
assertSame("Wrong or no parent set", table, table.getPrimaryKey().getParent());
|
assertSame("Wrong or no parent set", table, table.getPrimaryKey().getParent());
|
||||||
assertEquals("pk_node", table.getPrimaryKey().getName());
|
assertEquals("pk_node", table.getPrimaryKey().getName());
|
||||||
assertEquals(1, table.getPrimaryKey().getColumnNames().size());
|
assertEquals(1, table.getPrimaryKey().getColumnNames().size());
|
||||||
assertEquals("id", table.getPrimaryKey().getColumnNames().get(0));
|
assertEquals("id", table.getPrimaryKey().getColumnNames().get(0));
|
||||||
|
assertEquals(1, table.getPrimaryKey().getColumnOrders().get(0).intValue());
|
||||||
|
|
||||||
assertEquals(1, table.getForeignKeys().size());
|
assertEquals(1, table.getForeignKeys().size());
|
||||||
assertSame("Wrong or no parent set", table, table.getForeignKeys().get(0).getParent());
|
assertSame("Wrong or no parent set", table, table.getForeignKeys().get(0).getParent());
|
||||||
|
@@ -32,6 +32,7 @@ public class Column extends AbstractDbObject
|
|||||||
{
|
{
|
||||||
private String type;
|
private String type;
|
||||||
private boolean nullable;
|
private boolean nullable;
|
||||||
|
private int order;
|
||||||
|
|
||||||
|
|
||||||
public Column(String name)
|
public Column(String name)
|
||||||
@@ -86,16 +87,34 @@ public class Column extends AbstractDbObject
|
|||||||
this.nullable = nullable;
|
this.nullable = nullable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the order
|
||||||
|
*/
|
||||||
|
public int getOrder()
|
||||||
|
{
|
||||||
|
return this.order;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param order the order to set
|
||||||
|
*/
|
||||||
|
public void setOrder(int order)
|
||||||
|
{
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result + (this.nullable ? 1231 : 1237);
|
result = prime * result + (this.nullable ? 1231 : 1237);
|
||||||
|
result = prime * result + this.order;
|
||||||
result = prime * result + ((this.type == null) ? 0 : this.type.hashCode());
|
result = prime * result + ((this.type == null) ? 0 : this.type.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
@@ -104,6 +123,7 @@ public class Column extends AbstractDbObject
|
|||||||
if (getClass() != obj.getClass()) return false;
|
if (getClass() != obj.getClass()) return false;
|
||||||
Column other = (Column) obj;
|
Column other = (Column) obj;
|
||||||
if (this.nullable != other.nullable) return false;
|
if (this.nullable != other.nullable) return false;
|
||||||
|
if (this.order != other.order) return false;
|
||||||
if (this.type == null)
|
if (this.type == null)
|
||||||
{
|
{
|
||||||
if (other.type != null) return false;
|
if (other.type != null) return false;
|
||||||
@@ -117,13 +137,16 @@ public class Column extends AbstractDbObject
|
|||||||
{
|
{
|
||||||
DbProperty thisTypeProp = new DbProperty(this, "type");
|
DbProperty thisTypeProp = new DbProperty(this, "type");
|
||||||
DbProperty thisNullableProp = new DbProperty(this, "nullable");
|
DbProperty thisNullableProp = new DbProperty(this, "nullable");
|
||||||
|
DbProperty thisOrderProp = new DbProperty(this, "order");
|
||||||
|
|
||||||
Column thatColumn = (Column) right;
|
Column thatColumn = (Column) right;
|
||||||
DbProperty thatTypeProp = new DbProperty(thatColumn, "type");
|
DbProperty thatTypeProp = new DbProperty(thatColumn, "type");
|
||||||
DbProperty thatNullableProp = new DbProperty(thatColumn, "nullable");
|
DbProperty thatNullableProp = new DbProperty(thatColumn, "nullable");
|
||||||
|
DbProperty thatOrderProp = new DbProperty(thatColumn, "order");
|
||||||
|
|
||||||
comparisonUtils.compareSimple(thisTypeProp, thatTypeProp, ctx);
|
comparisonUtils.compareSimple(thisTypeProp, thatTypeProp, ctx);
|
||||||
comparisonUtils.compareSimple(thisNullableProp, thatNullableProp, ctx);
|
comparisonUtils.compareSimple(thisNullableProp, thatNullableProp, ctx);
|
||||||
|
comparisonUtils.compareSimple(thisOrderProp, thatOrderProp, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -63,8 +63,11 @@ public class ColumnTest extends DbObjectTestBase<Column>
|
|||||||
|
|
||||||
DbProperty thisNullableProp = new DbProperty(thisColumn, "nullable");
|
DbProperty thisNullableProp = new DbProperty(thisColumn, "nullable");
|
||||||
DbProperty thatNullableProp = new DbProperty(thatColumn, "nullable");
|
DbProperty thatNullableProp = new DbProperty(thatColumn, "nullable");
|
||||||
|
|
||||||
inOrder.verify(comparisonUtils).compareSimple(thisNullableProp, thatNullableProp, ctx);
|
inOrder.verify(comparisonUtils).compareSimple(thisNullableProp, thatNullableProp, ctx);
|
||||||
|
|
||||||
|
DbProperty thisOrderProp = new DbProperty(thisColumn, "order");
|
||||||
|
DbProperty thatOrderProp = new DbProperty(thatColumn, "order");
|
||||||
|
inOrder.verify(comparisonUtils).compareSimple(thisOrderProp, thatOrderProp, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -34,6 +34,7 @@ import org.alfresco.util.schemacomp.Result.Strength;
|
|||||||
public class PrimaryKey extends AbstractDbObject
|
public class PrimaryKey extends AbstractDbObject
|
||||||
{
|
{
|
||||||
private final List<String> columnNames = new ArrayList<String>();
|
private final List<String> columnNames = new ArrayList<String>();
|
||||||
|
private final List<Integer> columnOrders = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
|
||||||
public PrimaryKey(String name)
|
public PrimaryKey(String name)
|
||||||
@@ -47,10 +48,24 @@ public class PrimaryKey extends AbstractDbObject
|
|||||||
* @param name
|
* @param name
|
||||||
* @param columnNames
|
* @param columnNames
|
||||||
*/
|
*/
|
||||||
public PrimaryKey(Table table, String name, List<String> columnNames)
|
public PrimaryKey(Table table, String name, List<String> columnNames, List<Integer> columnOrders)
|
||||||
{
|
{
|
||||||
super(table, name);
|
super(table, name);
|
||||||
this.columnNames.addAll(columnNames);
|
this.columnNames.addAll(columnNames);
|
||||||
|
this.columnOrders.addAll(columnOrders);
|
||||||
|
checkColumnOrders();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure that if columnOrders are being used, there are
|
||||||
|
* as many of them as there are column names.
|
||||||
|
*/
|
||||||
|
private void checkColumnOrders()
|
||||||
|
{
|
||||||
|
if (columnOrders.size() > 0 && columnOrders.size() != columnNames.size())
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("columnOrders size does not match columnNames");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,6 +84,23 @@ public class PrimaryKey extends AbstractDbObject
|
|||||||
this.columnNames.clear();
|
this.columnNames.clear();
|
||||||
this.columnNames.addAll(columnNames);
|
this.columnNames.addAll(columnNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the columnOrders
|
||||||
|
*/
|
||||||
|
public List<Integer> getColumnOrders()
|
||||||
|
{
|
||||||
|
return this.columnOrders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param columnOrders the columnOrders to set
|
||||||
|
*/
|
||||||
|
public void setColumnOrders(List<Integer> columnOrders)
|
||||||
|
{
|
||||||
|
this.columnOrders.clear();
|
||||||
|
this.columnOrders.addAll(columnOrders);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
@@ -76,6 +108,7 @@ public class PrimaryKey extends AbstractDbObject
|
|||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result + ((this.columnNames == null) ? 0 : this.columnNames.hashCode());
|
result = prime * result + ((this.columnNames == null) ? 0 : this.columnNames.hashCode());
|
||||||
|
result = prime * result + ((this.columnOrders == null) ? 0 : this.columnOrders.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,23 +124,35 @@ public class PrimaryKey extends AbstractDbObject
|
|||||||
if (other.columnNames != null) return false;
|
if (other.columnNames != null) return false;
|
||||||
}
|
}
|
||||||
else if (!this.columnNames.equals(other.columnNames)) return false;
|
else if (!this.columnNames.equals(other.columnNames)) return false;
|
||||||
|
if (this.columnOrders == null)
|
||||||
|
{
|
||||||
|
if (other.columnOrders != null) return false;
|
||||||
|
}
|
||||||
|
else if (!this.columnOrders.equals(other.columnOrders)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doDiff(DbObject right, DiffContext ctx, Strength strength)
|
protected void doDiff(DbObject right, DiffContext ctx, Strength strength)
|
||||||
{
|
{
|
||||||
|
checkColumnOrders();
|
||||||
PrimaryKey rightPK = (PrimaryKey) right;
|
PrimaryKey rightPK = (PrimaryKey) right;
|
||||||
comparisonUtils.compareSimpleCollections(
|
comparisonUtils.compareSimpleCollections(
|
||||||
new DbProperty(this, "columnNames"),
|
new DbProperty(this, "columnNames"),
|
||||||
new DbProperty(rightPK, "columnNames"),
|
new DbProperty(rightPK, "columnNames"),
|
||||||
ctx,
|
ctx,
|
||||||
strength);
|
strength);
|
||||||
|
comparisonUtils.compareSimpleCollections(
|
||||||
|
new DbProperty(this, "columnOrders"),
|
||||||
|
new DbProperty(rightPK, "columnOrders"),
|
||||||
|
ctx,
|
||||||
|
strength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(DbObjectVisitor visitor)
|
public void accept(DbObjectVisitor visitor)
|
||||||
{
|
{
|
||||||
|
checkColumnOrders();
|
||||||
visitor.visit(this);
|
visitor.visit(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,8 +41,16 @@ public class PrimaryKeyTest extends DbObjectTestBase<PrimaryKey>
|
|||||||
@Before
|
@Before
|
||||||
public void setUp()
|
public void setUp()
|
||||||
{
|
{
|
||||||
thisPK = new PrimaryKey(null, "this_pk", Arrays.asList("id", "name", "age"));
|
thisPK = new PrimaryKey(
|
||||||
thatPK = new PrimaryKey(null, "that_pk", Arrays.asList("a", "b"));
|
null,
|
||||||
|
"this_pk",
|
||||||
|
Arrays.asList("id", "name", "age"),
|
||||||
|
Arrays.asList(2, 1, 3));
|
||||||
|
thatPK = new PrimaryKey(
|
||||||
|
null,
|
||||||
|
"that_pk",
|
||||||
|
Arrays.asList("a", "b"),
|
||||||
|
Arrays.asList(1, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -65,6 +73,11 @@ public class PrimaryKeyTest extends DbObjectTestBase<PrimaryKey>
|
|||||||
new DbProperty(thatPK, "columnNames"),
|
new DbProperty(thatPK, "columnNames"),
|
||||||
ctx,
|
ctx,
|
||||||
Strength.ERROR);
|
Strength.ERROR);
|
||||||
|
inOrder.verify(comparisonUtils).compareSimpleCollections(
|
||||||
|
new DbProperty(thisPK, "columnOrders"),
|
||||||
|
new DbProperty(thatPK, "columnOrders"),
|
||||||
|
ctx,
|
||||||
|
Strength.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -95,18 +95,21 @@ public class MySQLDialectExportTester extends AbstractExportTester
|
|||||||
assertEquals("id", col.getName());
|
assertEquals("id", col.getName());
|
||||||
assertEquals("bigint", col.getType());
|
assertEquals("bigint", col.getType());
|
||||||
assertEquals(false, col.isNullable());
|
assertEquals(false, col.isNullable());
|
||||||
|
assertEquals(1, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
|
||||||
assertEquals("version", col.getName());
|
assertEquals("version", col.getName());
|
||||||
assertEquals("bigint", col.getType());
|
assertEquals("bigint", col.getType());
|
||||||
assertEquals(false, col.isNullable());
|
assertEquals(false, col.isNullable());
|
||||||
|
assertEquals(2, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
|
||||||
assertEquals("ex_id", col.getName());
|
assertEquals("ex_id", col.getName());
|
||||||
assertEquals("bigint", col.getType());
|
assertEquals("bigint", col.getType());
|
||||||
assertEquals(false, col.isNullable());
|
assertEquals(false, col.isNullable());
|
||||||
|
assertEquals(3, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
|
||||||
@@ -114,6 +117,7 @@ public class MySQLDialectExportTester extends AbstractExportTester
|
|||||||
assertEquals("local_name", col.getName());
|
assertEquals("local_name", col.getName());
|
||||||
assertEquals("varchar(200)", col.getType());
|
assertEquals("varchar(200)", col.getType());
|
||||||
assertEquals(false, col.isNullable());
|
assertEquals(false, col.isNullable());
|
||||||
|
assertEquals(4, col.getOrder());
|
||||||
|
|
||||||
assertEquals(2, otherTable.getIndexes().size());
|
assertEquals(2, otherTable.getIndexes().size());
|
||||||
Iterator<Index> indexIt = otherTable.getIndexes().iterator();
|
Iterator<Index> indexIt = otherTable.getIndexes().iterator();
|
||||||
@@ -135,6 +139,7 @@ public class MySQLDialectExportTester extends AbstractExportTester
|
|||||||
PrimaryKey pk = otherTable.getPrimaryKey();
|
PrimaryKey pk = otherTable.getPrimaryKey();
|
||||||
assertSame("Incorrect parent or no parent set", otherTable, pk.getParent());
|
assertSame("Incorrect parent or no parent set", otherTable, pk.getParent());
|
||||||
assertEquals("id", pk.getColumnNames().get(0));
|
assertEquals("id", pk.getColumnNames().get(0));
|
||||||
|
assertEquals(1, pk.getColumnOrders().get(0).intValue());
|
||||||
|
|
||||||
assertEquals(1, otherTable.getForeignKeys().size());
|
assertEquals(1, otherTable.getForeignKeys().size());
|
||||||
ForeignKey fk = otherTable.getForeignKeys().get(0);
|
ForeignKey fk = otherTable.getForeignKeys().get(0);
|
||||||
@@ -158,70 +163,82 @@ public class MySQLDialectExportTester extends AbstractExportTester
|
|||||||
assertEquals("id", col.getName());
|
assertEquals("id", col.getName());
|
||||||
assertEquals("bigint", col.getType());
|
assertEquals("bigint", col.getType());
|
||||||
assertEquals(false, col.isNullable());
|
assertEquals(false, col.isNullable());
|
||||||
|
assertEquals(1, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("description", col.getName());
|
assertEquals("description", col.getName());
|
||||||
assertEquals("text", col.getType());
|
assertEquals("text", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(2, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("fixes_from_schema", col.getName());
|
assertEquals("fixes_from_schema", col.getName());
|
||||||
assertEquals("int", col.getType());
|
assertEquals("int", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(3, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("fixes_to_schema", col.getName());
|
assertEquals("fixes_to_schema", col.getName());
|
||||||
assertEquals("int", col.getType());
|
assertEquals("int", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(4, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("applied_to_schema", col.getName());
|
assertEquals("applied_to_schema", col.getName());
|
||||||
assertEquals("int", col.getType());
|
assertEquals("int", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(5, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("target_schema", col.getName());
|
assertEquals("target_schema", col.getName());
|
||||||
assertEquals("int", col.getType());
|
assertEquals("int", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(6, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("applied_on_date", col.getName());
|
assertEquals("applied_on_date", col.getName());
|
||||||
assertEquals("datetime", col.getType());
|
assertEquals("datetime", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(7, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("applied_to_server", col.getName());
|
assertEquals("applied_to_server", col.getName());
|
||||||
assertEquals("varchar(64)", col.getType());
|
assertEquals("varchar(64)", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(8, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("was_executed", col.getName());
|
assertEquals("was_executed", col.getName());
|
||||||
assertEquals("bit", col.getType());
|
assertEquals("bit", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(9, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("succeeded", col.getName());
|
assertEquals("succeeded", col.getName());
|
||||||
assertEquals("bit", col.getType());
|
assertEquals("bit", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(10, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("report", col.getName());
|
assertEquals("report", col.getName());
|
||||||
assertEquals("text", col.getType());
|
assertEquals("text", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(11, col.getOrder());
|
||||||
|
|
||||||
PrimaryKey pk = exampleTable.getPrimaryKey();
|
PrimaryKey pk = exampleTable.getPrimaryKey();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, pk.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, pk.getParent());
|
||||||
assertEquals("id", pk.getColumnNames().get(0));
|
assertEquals("id", pk.getColumnNames().get(0));
|
||||||
|
assertEquals(1, pk.getColumnOrders().get(0).intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -100,18 +100,21 @@ public class PostgreSQLDialectExportTester extends AbstractExportTester
|
|||||||
assertEquals("id", col.getName());
|
assertEquals("id", col.getName());
|
||||||
assertEquals("int8", col.getType());
|
assertEquals("int8", col.getType());
|
||||||
assertEquals(false, col.isNullable());
|
assertEquals(false, col.isNullable());
|
||||||
|
assertEquals(1, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
|
||||||
assertEquals("version", col.getName());
|
assertEquals("version", col.getName());
|
||||||
assertEquals("int8", col.getType());
|
assertEquals("int8", col.getType());
|
||||||
assertEquals(false, col.isNullable());
|
assertEquals(false, col.isNullable());
|
||||||
|
assertEquals(2, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
|
||||||
assertEquals("ex_id", col.getName());
|
assertEquals("ex_id", col.getName());
|
||||||
assertEquals("int8", col.getType());
|
assertEquals("int8", col.getType());
|
||||||
assertEquals(false, col.isNullable());
|
assertEquals(false, col.isNullable());
|
||||||
|
assertEquals(3, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
|
||||||
@@ -119,6 +122,7 @@ public class PostgreSQLDialectExportTester extends AbstractExportTester
|
|||||||
assertEquals("local_name", col.getName());
|
assertEquals("local_name", col.getName());
|
||||||
assertEquals("varchar(200)", col.getType());
|
assertEquals("varchar(200)", col.getType());
|
||||||
assertEquals(false, col.isNullable());
|
assertEquals(false, col.isNullable());
|
||||||
|
assertEquals(4, col.getOrder());
|
||||||
|
|
||||||
assertEquals(2, otherTable.getIndexes().size());
|
assertEquals(2, otherTable.getIndexes().size());
|
||||||
Iterator<Index> indexIt = otherTable.getIndexes().iterator();
|
Iterator<Index> indexIt = otherTable.getIndexes().iterator();
|
||||||
@@ -140,6 +144,7 @@ public class PostgreSQLDialectExportTester extends AbstractExportTester
|
|||||||
PrimaryKey pk = otherTable.getPrimaryKey();
|
PrimaryKey pk = otherTable.getPrimaryKey();
|
||||||
assertSame("Incorrect parent or no parent set", otherTable, pk.getParent());
|
assertSame("Incorrect parent or no parent set", otherTable, pk.getParent());
|
||||||
assertEquals("id", pk.getColumnNames().get(0));
|
assertEquals("id", pk.getColumnNames().get(0));
|
||||||
|
assertEquals(1, pk.getColumnOrders().get(0).intValue());
|
||||||
|
|
||||||
assertEquals(1, otherTable.getForeignKeys().size());
|
assertEquals(1, otherTable.getForeignKeys().size());
|
||||||
ForeignKey fk = otherTable.getForeignKeys().get(0);
|
ForeignKey fk = otherTable.getForeignKeys().get(0);
|
||||||
@@ -159,74 +164,87 @@ public class PostgreSQLDialectExportTester extends AbstractExportTester
|
|||||||
assertEquals("export_test_example", exampleTable.getName());
|
assertEquals("export_test_example", exampleTable.getName());
|
||||||
Iterator<Column> colIt = exampleTable.getColumns().iterator();
|
Iterator<Column> colIt = exampleTable.getColumns().iterator();
|
||||||
Column col = colIt.next();
|
Column col = colIt.next();
|
||||||
|
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("id", col.getName());
|
assertEquals("id", col.getName());
|
||||||
assertEquals("int8", col.getType());
|
assertEquals("int8", col.getType());
|
||||||
assertEquals(false, col.isNullable());
|
assertEquals(false, col.isNullable());
|
||||||
|
assertEquals(1, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("description", col.getName());
|
assertEquals("description", col.getName());
|
||||||
assertEquals("varchar(1024)", col.getType());
|
assertEquals("varchar(1024)", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(2, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("fixes_from_schema", col.getName());
|
assertEquals("fixes_from_schema", col.getName());
|
||||||
assertEquals("int4", col.getType());
|
assertEquals("int4", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(3, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("fixes_to_schema", col.getName());
|
assertEquals("fixes_to_schema", col.getName());
|
||||||
assertEquals("int4", col.getType());
|
assertEquals("int4", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(4, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("applied_to_schema", col.getName());
|
assertEquals("applied_to_schema", col.getName());
|
||||||
assertEquals("int4", col.getType());
|
assertEquals("int4", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(5, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("target_schema", col.getName());
|
assertEquals("target_schema", col.getName());
|
||||||
assertEquals("int4", col.getType());
|
assertEquals("int4", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(6, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("applied_on_date", col.getName());
|
assertEquals("applied_on_date", col.getName());
|
||||||
assertEquals("timestamp", col.getType());
|
assertEquals("timestamp", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(7, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("applied_to_server", col.getName());
|
assertEquals("applied_to_server", col.getName());
|
||||||
assertEquals("varchar(64)", col.getType());
|
assertEquals("varchar(64)", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(8, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("was_executed", col.getName());
|
assertEquals("was_executed", col.getName());
|
||||||
assertEquals("bool", col.getType());
|
assertEquals("bool", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(9, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("succeeded", col.getName());
|
assertEquals("succeeded", col.getName());
|
||||||
assertEquals("bool", col.getType());
|
assertEquals("bool", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(10, col.getOrder());
|
||||||
|
|
||||||
col = colIt.next();
|
col = colIt.next();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
|
||||||
assertEquals("report", col.getName());
|
assertEquals("report", col.getName());
|
||||||
assertEquals("varchar(1024)", col.getType());
|
assertEquals("varchar(1024)", col.getType());
|
||||||
assertEquals(true, col.isNullable());
|
assertEquals(true, col.isNullable());
|
||||||
|
assertEquals(11, col.getOrder());
|
||||||
|
|
||||||
PrimaryKey pk = exampleTable.getPrimaryKey();
|
PrimaryKey pk = exampleTable.getPrimaryKey();
|
||||||
assertSame("Incorrect parent or no parent set", exampleTable, pk.getParent());
|
assertSame("Incorrect parent or no parent set", exampleTable, pk.getParent());
|
||||||
assertEquals("id", pk.getColumnNames().get(0));
|
assertEquals("id", pk.getColumnNames().get(0));
|
||||||
|
assertEquals(1, pk.getColumnOrders().get(0).intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -6,22 +6,22 @@
|
|||||||
<objects>
|
<objects>
|
||||||
<table name="node">
|
<table name="node">
|
||||||
<columns>
|
<columns>
|
||||||
<column name="id">
|
<column name="id" order="1">
|
||||||
<type>NUMBER(10)</type>
|
<type>NUMBER(10)</type>
|
||||||
<nullable>false</nullable>
|
<nullable>false</nullable>
|
||||||
</column>
|
</column>
|
||||||
<column name="nodeRef">
|
<column name="nodeRef" order="3">
|
||||||
<type>VARCHAR2(200)</type>
|
<type>VARCHAR2(200)</type>
|
||||||
<nullable>false</nullable>
|
<nullable>false</nullable>
|
||||||
</column>
|
</column>
|
||||||
<column name="name">
|
<column name="name" order="2">
|
||||||
<type>VARCHAR2(150)</type>
|
<type>VARCHAR2(150)</type>
|
||||||
<nullable>true</nullable>
|
<nullable>true</nullable>
|
||||||
</column>
|
</column>
|
||||||
</columns>
|
</columns>
|
||||||
<primarykey name="pk_node">
|
<primarykey name="pk_node">
|
||||||
<columnnames>
|
<columnnames>
|
||||||
<columnname>id</columnname>
|
<columnname order="1">id</columnname>
|
||||||
</columnnames>
|
</columnnames>
|
||||||
</primarykey>
|
</primarykey>
|
||||||
<foreignkeys>
|
<foreignkeys>
|
||||||
|
Reference in New Issue
Block a user