Revision: 3493
Author: mo.jeff
Date: Wed May  5 09:39:03 2010
Log: ASSIGNED - bug 2682: Implement Save/Load to XML with User Defined Types
http://trillian.sqlpower.ca/bugzilla/show_bug.cgi?id=2682

Made an enhancement in which if the type UUID doesn't exist in the loading session, then it will attempt to replace it with an existing type with the same JDBC type.

Note however that this may not end up picking the 'right' type replacement if there's more than one UserDefinedSQLType with the same JDBC type in a session.
http://code.google.com/p/power-architect/source/detail?r=3493

Modified:
 /trunk/src/main/java/ca/sqlpower/architect/ProjectLoader.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/ProjectLoader.java Mon May 3 16:11:03 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/ProjectLoader.java Wed May 5 09:39:03 2010
@@ -712,19 +712,24 @@
             }

String sqlTypeUUID = attributes.getValue("userDefinedTypeUUID");
-            UserDefinedSQLType sqlType;
-
- // If sqlTypeUUID isn't in the file, probably because it's from an older version...
-            if (sqlTypeUUID == null) {
+            UserDefinedSQLType sqlType = null;
+
+            if (sqlTypeUUID != null ){
+                sqlType = session.findSQLTypeByUUID(sqlTypeUUID);
+            }
+
+ // If userDefinedTypeUUID isn't in the file, probably because it's + // from an older version... or if the userDefinedTypeUUID doesn't
+            // exist in this system, then try to guess it by JDBC type.
+            if (sqlTypeUUID == null || sqlType == null) {
                 String type = attributes.getValue("type");
                 int jdbcType = Integer.valueOf(type);
+ // TODO: If a session contains more than one UserDefinedSQLType + // (most likely when loading into a server) with the same JDBC
+                // type, then it may not pick the 'right' one.
                 sqlType = session.findSQLTypeByJDBCType(jdbcType);
-            } else {
-                sqlType = session.findSQLTypeByUUID(sqlTypeUUID);
-            }
-
- // TODO: Handle gracefully if sqlType is null, in which case, the - // user is probably loading a project from another user or server.
+            }
+
             col.getUserDefinedSQLType().setUpstreamType(sqlType);

             LoadSQLObjectAttributes(col, attributes);

Reply via email to