Revision: 3297
Author: silva.josemanuel1
Date: Fri Feb 12 15:21:05 2010
Log: Moved DiffChunk and DiffType to the library, since the server
component now uses them.
Added a method to get a list of DiffChunks by getting the server to compare
two revisions.
http://code.google.com/p/power-architect/source/detail?r=3297
Deleted:
/trunk/src/ca/sqlpower/architect/diff/DiffChunk.java
/trunk/src/ca/sqlpower/architect/diff/DiffType.java
Modified:
/trunk/regress/ca/sqlpower/architect/diff/CompareSQLTest.java
/trunk/src/ca/sqlpower/architect/diff/CompareSQL.java
/trunk/src/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
/trunk/src/ca/sqlpower/architect/swingui/CompareDMFormatter.java
/trunk/src/ca/sqlpower/architect/swingui/CompareDMPanel.java
=======================================
--- /trunk/src/ca/sqlpower/architect/diff/DiffChunk.java Tue Mar 25
07:38:28 2008
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2008, SQL Power Group Inc.
- *
- * This file is part of Power*Architect.
- *
- * Power*Architect is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Power*Architect is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package ca.sqlpower.architect.diff;
-
-public class DiffChunk<T> {
- private DiffType type;
- private T data;
-
- /**
- * @param data
- * @param type
- */
- public DiffChunk(T data, DiffType type) {
- super();
- this.data = data;
- this.type = type;
- }
-
- public T getData() {
- return data;
- }
-
- public DiffType getType() {
- return type;
-
- }
- @Override
- public String toString() {
-
- return super.toString() + "(" +type+")["+data+"]";
- }
-}
=======================================
--- /trunk/src/ca/sqlpower/architect/diff/DiffType.java Tue Mar 25 07:38:28
2008
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2008, SQL Power Group Inc.
- *
- * This file is part of Power*Architect.
- *
- * Power*Architect is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Power*Architect is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package ca.sqlpower.architect.diff;
-
-public enum DiffType {
- LEFTONLY,
- MODIFIED,
- SAME, // Some implementations may not use this.
- RIGHTONLY,
- KEY_CHANGED, // primary key changed or removed
- DROP_KEY; // the key with this type needs to be dropped
-}
=======================================
--- /trunk/regress/ca/sqlpower/architect/diff/CompareSQLTest.java Mon Feb
8 10:12:47 2010
+++ /trunk/regress/ca/sqlpower/architect/diff/CompareSQLTest.java Fri Feb
12 15:21:05 2010
@@ -24,6 +24,8 @@
import java.util.List;
import junit.framework.TestCase;
+import ca.sqlpower.diff.DiffChunk;
+import ca.sqlpower.diff.DiffType;
import ca.sqlpower.sqlobject.SQLObjectException;
import ca.sqlpower.sqlobject.SQLColumn;
import ca.sqlpower.sqlobject.SQLObject;
=======================================
--- /trunk/src/ca/sqlpower/architect/diff/CompareSQL.java Mon Feb 8
10:12:47 2010
+++ /trunk/src/ca/sqlpower/architect/diff/CompareSQL.java Fri Feb 12
15:21:05 2010
@@ -29,10 +29,12 @@
import org.apache.log4j.Logger;
import ca.sqlpower.architect.ArchitectUtils;
-import ca.sqlpower.sqlobject.SQLObjectException;
+import ca.sqlpower.diff.DiffChunk;
+import ca.sqlpower.diff.DiffType;
import ca.sqlpower.sqlobject.SQLColumn;
import ca.sqlpower.sqlobject.SQLIndex;
import ca.sqlpower.sqlobject.SQLObject;
+import ca.sqlpower.sqlobject.SQLObjectException;
import ca.sqlpower.sqlobject.SQLRelationship;
import ca.sqlpower.sqlobject.SQLTable;
import ca.sqlpower.util.Monitorable;
=======================================
---
/trunk/src/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
Thu Feb 11 14:26:15 2010
+++
/trunk/src/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
Fri Feb 12 15:21:05 2010
@@ -55,6 +55,8 @@
import ca.sqlpower.dao.json.SPJSONMessageDecoder;
import ca.sqlpower.dao.json.SPJSONPersister;
import ca.sqlpower.dao.session.SessionPersisterSuperConverter;
+import ca.sqlpower.diff.DiffChunk;
+import ca.sqlpower.diff.SimpleDiffChunkJSONConverter;
import ca.sqlpower.enterprise.TransactionInformation;
import ca.sqlpower.enterprise.client.SPServerInfo;
import ca.sqlpower.sql.DataSourceCollection;
@@ -65,6 +67,7 @@
import ca.sqlpower.sql.PlDotIni;
import ca.sqlpower.sql.SPDataSource;
import ca.sqlpower.sql.SpecificDataSourceCollection;
+import ca.sqlpower.sqlobject.SQLObject;
import ca.sqlpower.sqlobject.SQLObjectException;
import ca.sqlpower.swingui.event.SessionLifecycleEvent;
import ca.sqlpower.swingui.event.SessionLifecycleListener;
@@ -352,12 +355,35 @@
executeServerRequest(httpClient,
projectLocation.getServiceInfo(),
"/project/" + projectLocation.getUUID() + "/revert",
"revisionNo=" + revisionNo,
- new BasicResponseHandler());
+ new JSONResponseHandler());
} finally {
httpClient.getConnectionManager().shutdown();
}
}
+
+ /**
+ * Gets a list of DiffChunks representing the differences between the
two revisions from the server.
+ */
+ public List<DiffChunk<SQLObject>> getComparisonDiffChunks(int
oldRevisionNo, int newRevisionNo)
+ throws IOException, URISyntaxException, JSONException,
SPPersistenceException {
+
+ SPServerInfo serviceInfo = projectLocation.getServiceInfo();
+ HttpClient httpClient = createHttpClient(serviceInfo);
+
+ try {
+ String response = executeServerRequest(httpClient,
projectLocation.getServiceInfo(),
+ "/project/" + projectLocation.getUUID() + "/compare",
+ "versions=" + oldRevisionNo + ":" + newRevisionNo,
+ new JSONResponseHandler());
+
+ return SimpleDiffChunkJSONConverter.decode(response);
+
+ } finally {
+ httpClient.getConnectionManager().shutdown();
+ }
+
+ }
public static void deleteServerWorkspace(ProjectLocation projectLocation)
throws URISyntaxException, ClientProtocolException, IOException {
SPServerInfo serviceInfo = projectLocation.getServiceInfo();
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/CompareDMFormatter.java Fri
Jan 15 15:02:04 2010
+++ /trunk/src/ca/sqlpower/architect/swingui/CompareDMFormatter.java Fri
Feb 12 15:21:05 2010
@@ -38,10 +38,10 @@
import ca.sqlpower.architect.ddl.DDLGenerator;
import ca.sqlpower.architect.diff.ArchitectDiffException;
-import ca.sqlpower.architect.diff.DiffChunk;
-import ca.sqlpower.architect.diff.DiffType;
import ca.sqlpower.architect.swingui.CompareDMPanel.SourceOrTargetStuff;
import
ca.sqlpower.architect.swingui.CompareDMSettings.SourceOrTargetSettings;
+import ca.sqlpower.diff.DiffChunk;
+import ca.sqlpower.diff.DiffType;
import ca.sqlpower.sqlobject.SQLObjectException;
import ca.sqlpower.sqlobject.SQLCatalog;
import ca.sqlpower.sqlobject.SQLColumn;
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/CompareDMPanel.java Mon Dec 21
08:27:43 2009
+++ /trunk/src/ca/sqlpower/architect/swingui/CompareDMPanel.java Fri Feb 12
15:21:05 2010
@@ -60,11 +60,11 @@
import ca.sqlpower.architect.ddl.DDLGenerator;
import ca.sqlpower.architect.ddl.DDLUtils;
import ca.sqlpower.architect.diff.CompareSQL;
-import ca.sqlpower.architect.diff.DiffChunk;
import
ca.sqlpower.architect.swingui.CompareDMPanel.SourceOrTargetStuff.CatalogPopulator;
import
ca.sqlpower.architect.swingui.CompareDMPanel.SourceOrTargetStuff.SchemaPopulator;
import ca.sqlpower.architect.swingui.CompareDMSettings.DatastoreType;
import
ca.sqlpower.architect.swingui.CompareDMSettings.SourceOrTargetSettings;
+import ca.sqlpower.diff.DiffChunk;
import ca.sqlpower.sql.DataSourceCollection;
import ca.sqlpower.sql.JDBCDataSource;
import ca.sqlpower.sql.SPDataSource;