columnNames) throws SAXException
+ /**
+ * Outputs a list of columnname elements sandwiched within a columnnames element.
+ *
+ * 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 columnNames,
+ List columnOrders) throws SAXException
{
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 or 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);
}
diff --git a/source/java/org/alfresco/util/schemacomp/DbObjectXMLTransformerTest.java b/source/java/org/alfresco/util/schemacomp/DbObjectXMLTransformerTest.java
index 09340f3509..126585e5f8 100644
--- a/source/java/org/alfresco/util/schemacomp/DbObjectXMLTransformerTest.java
+++ b/source/java/org/alfresco/util/schemacomp/DbObjectXMLTransformerTest.java
@@ -105,13 +105,13 @@ public class DbObjectXMLTransformerTest
public void transformColumn() throws IOException
{
Column column = new Column(null, "last_name", "VARCHAR2(100)", true);
-
+ column.setOrder(2);
transformer.output(column);
BufferedReader reader = new BufferedReader(new StringReader(writer.toString()));
dumpOutput();
assertHasPreamble(reader);
- assertEquals("", reader.readLine());
+ assertEquals("", reader.readLine());
assertEquals(" VARCHAR2(100)", reader.readLine());
assertEquals(" true", reader.readLine());
assertEquals("", reader.readLine());
@@ -159,7 +159,11 @@ public class DbObjectXMLTransformerTest
@Test
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);
@@ -168,8 +172,8 @@ public class DbObjectXMLTransformerTest
assertHasPreamble(reader);
assertEquals("", reader.readLine());
assertEquals(" ", reader.readLine());
- assertEquals(" first", reader.readLine());
- assertEquals(" second", reader.readLine());
+ assertEquals(" a_column", reader.readLine());
+ assertEquals(" b_column", reader.readLine());
assertEquals(" ", reader.readLine());
assertEquals("", reader.readLine());
}
@@ -178,7 +182,7 @@ public class DbObjectXMLTransformerTest
public void transformSchema() throws IOException
{
Collection 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 fks = fkeys(fk("fk_one", "lc", "tt", "tc"), fk("fk_two", "lc", "tt", "tc"));
Collection indexes = indexes("index_one col1 col2", "index_two col3 col4");
@@ -225,7 +229,7 @@ public class DbObjectXMLTransformerTest
public void transformTable() throws IOException
{
Collection 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 fks = fkeys(fk("fk_one", "lc", "tt", "tc"), fk("fk_two", "lc", "tt", "tc"));
Collection indexes = indexes("index_one col1 col2", "index_two col3 col4");
@@ -258,7 +262,7 @@ public class DbObjectXMLTransformerTest
public void transformObjectWithValidators() throws IOException
{
Collection 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 fks = fkeys(fk("fk_one", "lc", "tt", "tc"), fk("fk_two", "lc", "tt", "tc"));
Collection indexes = indexes("index_one col1 col2", "index_two col3 col4");
diff --git a/source/java/org/alfresco/util/schemacomp/ExportDb.java b/source/java/org/alfresco/util/schemacomp/ExportDb.java
index 1eec1b5641..746d816176 100644
--- a/source/java/org/alfresco/util/schemacomp/ExportDb.java
+++ b/source/java/org/alfresco/util/schemacomp/ExportDb.java
@@ -230,6 +230,9 @@ public class ExportDb
String nullableString = columns.getString("IS_NULLABLE");
column.setNullable(parseBoolean(nullableString));
+
+ column.setOrder(columns.getInt("ORDINAL_POSITION"));
+
column.setParent(table);
table.getColumns().add(column);
}
@@ -250,6 +253,9 @@ public class ExportDb
}
String columnName = primarykeycols.getString("COLUMN_NAME");
pk.getColumnNames().add(columnName);
+
+ int columnOrder = primarykeycols.getInt("KEY_SEQ");
+ pk.getColumnOrders().add(columnOrder);
}
primarykeycols.close();
diff --git a/source/java/org/alfresco/util/schemacomp/SchemaCompPackagetTestSuite.java b/source/java/org/alfresco/util/schemacomp/SchemaCompPackageTestSuite.java
similarity index 94%
rename from source/java/org/alfresco/util/schemacomp/SchemaCompPackagetTestSuite.java
rename to source/java/org/alfresco/util/schemacomp/SchemaCompPackageTestSuite.java
index ef97b95001..37642040a0 100644
--- a/source/java/org/alfresco/util/schemacomp/SchemaCompPackagetTestSuite.java
+++ b/source/java/org/alfresco/util/schemacomp/SchemaCompPackageTestSuite.java
@@ -34,6 +34,6 @@ import org.junit.runners.Suite;
ValidatorTestSuite.class,
SchemaCompTestSuite.class
})
-public class SchemaCompPackagetTestSuite
+public class SchemaCompPackageTestSuite
{
}
diff --git a/source/java/org/alfresco/util/schemacomp/SchemaCompTestingUtils.java b/source/java/org/alfresco/util/schemacomp/SchemaCompTestingUtils.java
index a6a79eec7a..1706d19a4c 100644
--- a/source/java/org/alfresco/util/schemacomp/SchemaCompTestingUtils.java
+++ b/source/java/org/alfresco/util/schemacomp/SchemaCompTestingUtils.java
@@ -20,6 +20,7 @@ package org.alfresco.util.schemacomp;
import static org.junit.Assert.assertTrue;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -84,6 +85,7 @@ public class SchemaCompTestingUtils
{
String[] parts = colDefs[i].split(" ");
columns[i] = new Column(null, parts[0], parts[1], false);
+ columns[i].setOrder(i+1);
}
return Arrays.asList(columns);
}
@@ -91,7 +93,14 @@ public class SchemaCompTestingUtils
public static PrimaryKey pk(String name, String... columnNames)
{
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 columnOrders = new ArrayList(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;
}
diff --git a/source/java/org/alfresco/util/schemacomp/XML.java b/source/java/org/alfresco/util/schemacomp/XML.java
index d53075c43b..01560dc1c2 100644
--- a/source/java/org/alfresco/util/schemacomp/XML.java
+++ b/source/java/org/alfresco/util/schemacomp/XML.java
@@ -51,6 +51,7 @@ public abstract class XML
public static final String EL_PROPERTY = "property";
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_CLASS = "class";
}
diff --git a/source/java/org/alfresco/util/schemacomp/XMLToSchema.java b/source/java/org/alfresco/util/schemacomp/XMLToSchema.java
index 3a43dd077a..4912665bb3 100644
--- a/source/java/org/alfresco/util/schemacomp/XMLToSchema.java
+++ b/source/java/org/alfresco/util/schemacomp/XMLToSchema.java
@@ -212,7 +212,22 @@ public class XMLToSchema extends DefaultHandler
}
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))
{
diff --git a/source/java/org/alfresco/util/schemacomp/XMLToSchemaTest.java b/source/java/org/alfresco/util/schemacomp/XMLToSchemaTest.java
index 4f20b35ff3..1d2e0f73b0 100644
--- a/source/java/org/alfresco/util/schemacomp/XMLToSchemaTest.java
+++ b/source/java/org/alfresco/util/schemacomp/XMLToSchemaTest.java
@@ -80,21 +80,25 @@ public class XMLToSchemaTest
assertEquals("id", table.getColumns().get(0).getName());
assertEquals("NUMBER(10)", table.getColumns().get(0).getType());
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());
assertEquals("nodeRef", table.getColumns().get(1).getName());
assertEquals("VARCHAR2(200)", table.getColumns().get(1).getType());
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());
assertEquals("name", table.getColumns().get(2).getName());
assertEquals("VARCHAR2(150)", table.getColumns().get(2).getType());
assertEquals(true, table.getColumns().get(2).isNullable());
+ assertEquals(2, table.getColumns().get(2).getOrder());
assertSame("Wrong or no parent set", table, table.getPrimaryKey().getParent());
assertEquals("pk_node", table.getPrimaryKey().getName());
assertEquals(1, table.getPrimaryKey().getColumnNames().size());
assertEquals("id", table.getPrimaryKey().getColumnNames().get(0));
+ assertEquals(1, table.getPrimaryKey().getColumnOrders().get(0).intValue());
assertEquals(1, table.getForeignKeys().size());
assertSame("Wrong or no parent set", table, table.getForeignKeys().get(0).getParent());
diff --git a/source/java/org/alfresco/util/schemacomp/model/Column.java b/source/java/org/alfresco/util/schemacomp/model/Column.java
index 1b33308a7b..28e41fbcf1 100644
--- a/source/java/org/alfresco/util/schemacomp/model/Column.java
+++ b/source/java/org/alfresco/util/schemacomp/model/Column.java
@@ -32,6 +32,7 @@ public class Column extends AbstractDbObject
{
private String type;
private boolean nullable;
+ private int order;
public Column(String name)
@@ -86,16 +87,34 @@ public class Column extends AbstractDbObject
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
public int hashCode()
{
final int prime = 31;
int result = super.hashCode();
result = prime * result + (this.nullable ? 1231 : 1237);
+ result = prime * result + this.order;
result = prime * result + ((this.type == null) ? 0 : this.type.hashCode());
return result;
}
-
+
@Override
public boolean equals(Object obj)
{
@@ -104,6 +123,7 @@ public class Column extends AbstractDbObject
if (getClass() != obj.getClass()) return false;
Column other = (Column) obj;
if (this.nullable != other.nullable) return false;
+ if (this.order != other.order) return false;
if (this.type == null)
{
if (other.type != null) return false;
@@ -117,13 +137,16 @@ public class Column extends AbstractDbObject
{
DbProperty thisTypeProp = new DbProperty(this, "type");
DbProperty thisNullableProp = new DbProperty(this, "nullable");
+ DbProperty thisOrderProp = new DbProperty(this, "order");
Column thatColumn = (Column) right;
DbProperty thatTypeProp = new DbProperty(thatColumn, "type");
DbProperty thatNullableProp = new DbProperty(thatColumn, "nullable");
+ DbProperty thatOrderProp = new DbProperty(thatColumn, "order");
comparisonUtils.compareSimple(thisTypeProp, thatTypeProp, ctx);
comparisonUtils.compareSimple(thisNullableProp, thatNullableProp, ctx);
+ comparisonUtils.compareSimple(thisOrderProp, thatOrderProp, ctx);
}
@Override
diff --git a/source/java/org/alfresco/util/schemacomp/model/ColumnTest.java b/source/java/org/alfresco/util/schemacomp/model/ColumnTest.java
index 2048a9cd19..f564bf75cd 100644
--- a/source/java/org/alfresco/util/schemacomp/model/ColumnTest.java
+++ b/source/java/org/alfresco/util/schemacomp/model/ColumnTest.java
@@ -63,8 +63,11 @@ public class ColumnTest extends DbObjectTestBase
DbProperty thisNullableProp = new DbProperty(thisColumn, "nullable");
DbProperty thatNullableProp = new DbProperty(thatColumn, "nullable");
-
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
diff --git a/source/java/org/alfresco/util/schemacomp/model/PrimaryKey.java b/source/java/org/alfresco/util/schemacomp/model/PrimaryKey.java
index 9175d24cf6..3a1d5ea8cf 100644
--- a/source/java/org/alfresco/util/schemacomp/model/PrimaryKey.java
+++ b/source/java/org/alfresco/util/schemacomp/model/PrimaryKey.java
@@ -34,6 +34,7 @@ import org.alfresco.util.schemacomp.Result.Strength;
public class PrimaryKey extends AbstractDbObject
{
private final List columnNames = new ArrayList();
+ private final List columnOrders = new ArrayList();
public PrimaryKey(String name)
@@ -47,10 +48,24 @@ public class PrimaryKey extends AbstractDbObject
* @param name
* @param columnNames
*/
- public PrimaryKey(Table table, String name, List columnNames)
+ public PrimaryKey(Table table, String name, List columnNames, List columnOrders)
{
super(table, name);
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.addAll(columnNames);
}
+
+ /**
+ * @return the columnOrders
+ */
+ public List getColumnOrders()
+ {
+ return this.columnOrders;
+ }
+
+ /**
+ * @param columnOrders the columnOrders to set
+ */
+ public void setColumnOrders(List columnOrders)
+ {
+ this.columnOrders.clear();
+ this.columnOrders.addAll(columnOrders);
+ }
@Override
public int hashCode()
@@ -76,6 +108,7 @@ public class PrimaryKey extends AbstractDbObject
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((this.columnNames == null) ? 0 : this.columnNames.hashCode());
+ result = prime * result + ((this.columnOrders == null) ? 0 : this.columnOrders.hashCode());
return result;
}
@@ -91,23 +124,35 @@ public class PrimaryKey extends AbstractDbObject
if (other.columnNames != null) 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;
}
@Override
protected void doDiff(DbObject right, DiffContext ctx, Strength strength)
{
+ checkColumnOrders();
PrimaryKey rightPK = (PrimaryKey) right;
comparisonUtils.compareSimpleCollections(
new DbProperty(this, "columnNames"),
new DbProperty(rightPK, "columnNames"),
ctx,
strength);
+ comparisonUtils.compareSimpleCollections(
+ new DbProperty(this, "columnOrders"),
+ new DbProperty(rightPK, "columnOrders"),
+ ctx,
+ strength);
}
@Override
public void accept(DbObjectVisitor visitor)
{
+ checkColumnOrders();
visitor.visit(this);
}
}
diff --git a/source/java/org/alfresco/util/schemacomp/model/PrimaryKeyTest.java b/source/java/org/alfresco/util/schemacomp/model/PrimaryKeyTest.java
index 8665fe6d78..4b121461e2 100644
--- a/source/java/org/alfresco/util/schemacomp/model/PrimaryKeyTest.java
+++ b/source/java/org/alfresco/util/schemacomp/model/PrimaryKeyTest.java
@@ -41,8 +41,16 @@ public class PrimaryKeyTest extends DbObjectTestBase
@Before
public void setUp()
{
- thisPK = new PrimaryKey(null, "this_pk", Arrays.asList("id", "name", "age"));
- thatPK = new PrimaryKey(null, "that_pk", Arrays.asList("a", "b"));
+ thisPK = new PrimaryKey(
+ 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
@@ -65,6 +73,11 @@ public class PrimaryKeyTest extends DbObjectTestBase
new DbProperty(thatPK, "columnNames"),
ctx,
Strength.ERROR);
+ inOrder.verify(comparisonUtils).compareSimpleCollections(
+ new DbProperty(thisPK, "columnOrders"),
+ new DbProperty(thatPK, "columnOrders"),
+ ctx,
+ Strength.ERROR);
}
@Test
diff --git a/source/java/org/alfresco/util/schemacomp/test/exportdb/MySQLDialectExportTester.java b/source/java/org/alfresco/util/schemacomp/test/exportdb/MySQLDialectExportTester.java
index 158a177847..8427662aff 100644
--- a/source/java/org/alfresco/util/schemacomp/test/exportdb/MySQLDialectExportTester.java
+++ b/source/java/org/alfresco/util/schemacomp/test/exportdb/MySQLDialectExportTester.java
@@ -95,18 +95,21 @@ public class MySQLDialectExportTester extends AbstractExportTester
assertEquals("id", col.getName());
assertEquals("bigint", col.getType());
assertEquals(false, col.isNullable());
+ assertEquals(1, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
assertEquals("version", col.getName());
assertEquals("bigint", col.getType());
assertEquals(false, col.isNullable());
+ assertEquals(2, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
assertEquals("ex_id", col.getName());
assertEquals("bigint", col.getType());
assertEquals(false, col.isNullable());
+ assertEquals(3, col.getOrder());
col = colIt.next();
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("varchar(200)", col.getType());
assertEquals(false, col.isNullable());
+ assertEquals(4, col.getOrder());
assertEquals(2, otherTable.getIndexes().size());
Iterator indexIt = otherTable.getIndexes().iterator();
@@ -135,6 +139,7 @@ public class MySQLDialectExportTester extends AbstractExportTester
PrimaryKey pk = otherTable.getPrimaryKey();
assertSame("Incorrect parent or no parent set", otherTable, pk.getParent());
assertEquals("id", pk.getColumnNames().get(0));
+ assertEquals(1, pk.getColumnOrders().get(0).intValue());
assertEquals(1, otherTable.getForeignKeys().size());
ForeignKey fk = otherTable.getForeignKeys().get(0);
@@ -158,70 +163,82 @@ public class MySQLDialectExportTester extends AbstractExportTester
assertEquals("id", col.getName());
assertEquals("bigint", col.getType());
assertEquals(false, col.isNullable());
+ assertEquals(1, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("description", col.getName());
assertEquals("text", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(2, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("fixes_from_schema", col.getName());
assertEquals("int", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(3, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("fixes_to_schema", col.getName());
assertEquals("int", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(4, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("applied_to_schema", col.getName());
assertEquals("int", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(5, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("target_schema", col.getName());
assertEquals("int", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(6, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("applied_on_date", col.getName());
assertEquals("datetime", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(7, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("applied_to_server", col.getName());
assertEquals("varchar(64)", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(8, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("was_executed", col.getName());
assertEquals("bit", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(9, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("succeeded", col.getName());
assertEquals("bit", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(10, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("report", col.getName());
assertEquals("text", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(11, col.getOrder());
PrimaryKey pk = exampleTable.getPrimaryKey();
assertSame("Incorrect parent or no parent set", exampleTable, pk.getParent());
assertEquals("id", pk.getColumnNames().get(0));
+ assertEquals(1, pk.getColumnOrders().get(0).intValue());
}
diff --git a/source/java/org/alfresco/util/schemacomp/test/exportdb/PostgreSQLDialectExportTester.java b/source/java/org/alfresco/util/schemacomp/test/exportdb/PostgreSQLDialectExportTester.java
index d072167d17..06007e583f 100644
--- a/source/java/org/alfresco/util/schemacomp/test/exportdb/PostgreSQLDialectExportTester.java
+++ b/source/java/org/alfresco/util/schemacomp/test/exportdb/PostgreSQLDialectExportTester.java
@@ -100,18 +100,21 @@ public class PostgreSQLDialectExportTester extends AbstractExportTester
assertEquals("id", col.getName());
assertEquals("int8", col.getType());
assertEquals(false, col.isNullable());
+ assertEquals(1, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
assertEquals("version", col.getName());
assertEquals("int8", col.getType());
assertEquals(false, col.isNullable());
+ assertEquals(2, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", otherTable, col.getParent());
assertEquals("ex_id", col.getName());
assertEquals("int8", col.getType());
assertEquals(false, col.isNullable());
+ assertEquals(3, col.getOrder());
col = colIt.next();
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("varchar(200)", col.getType());
assertEquals(false, col.isNullable());
+ assertEquals(4, col.getOrder());
assertEquals(2, otherTable.getIndexes().size());
Iterator indexIt = otherTable.getIndexes().iterator();
@@ -140,6 +144,7 @@ public class PostgreSQLDialectExportTester extends AbstractExportTester
PrimaryKey pk = otherTable.getPrimaryKey();
assertSame("Incorrect parent or no parent set", otherTable, pk.getParent());
assertEquals("id", pk.getColumnNames().get(0));
+ assertEquals(1, pk.getColumnOrders().get(0).intValue());
assertEquals(1, otherTable.getForeignKeys().size());
ForeignKey fk = otherTable.getForeignKeys().get(0);
@@ -159,74 +164,87 @@ public class PostgreSQLDialectExportTester extends AbstractExportTester
assertEquals("export_test_example", exampleTable.getName());
Iterator colIt = exampleTable.getColumns().iterator();
Column col = colIt.next();
+
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("id", col.getName());
assertEquals("int8", col.getType());
assertEquals(false, col.isNullable());
+ assertEquals(1, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("description", col.getName());
assertEquals("varchar(1024)", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(2, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("fixes_from_schema", col.getName());
assertEquals("int4", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(3, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("fixes_to_schema", col.getName());
assertEquals("int4", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(4, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("applied_to_schema", col.getName());
assertEquals("int4", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(5, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("target_schema", col.getName());
assertEquals("int4", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(6, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("applied_on_date", col.getName());
assertEquals("timestamp", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(7, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("applied_to_server", col.getName());
assertEquals("varchar(64)", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(8, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("was_executed", col.getName());
assertEquals("bool", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(9, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("succeeded", col.getName());
assertEquals("bool", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(10, col.getOrder());
col = colIt.next();
assertSame("Incorrect parent or no parent set", exampleTable, col.getParent());
assertEquals("report", col.getName());
assertEquals("varchar(1024)", col.getType());
assertEquals(true, col.isNullable());
+ assertEquals(11, col.getOrder());
PrimaryKey pk = exampleTable.getPrimaryKey();
assertSame("Incorrect parent or no parent set", exampleTable, pk.getParent());
assertEquals("id", pk.getColumnNames().get(0));
+ assertEquals(1, pk.getColumnOrders().get(0).intValue());
}
diff --git a/source/test-resources/schemacomp/xml_to_schema_test.xml b/source/test-resources/schemacomp/xml_to_schema_test.xml
index 1c044e9b7b..2ba5e81869 100644
--- a/source/test-resources/schemacomp/xml_to_schema_test.xml
+++ b/source/test-resources/schemacomp/xml_to_schema_test.xml
@@ -6,22 +6,22 @@
-
+
NUMBER(10)
false
-
+
VARCHAR2(200)
false
-
+
VARCHAR2(150)
true
- id
+ id