[power-matchmaker] r2771 committed - The next button on the validation screen becomes disabled when the las...

0 views
Skip to first unread message

power-ma...@googlecode.com

unread,
Jan 27, 2011, 2:31:41 PM1/27/11
to matchmake...@googlegroups.com
Revision: 2771
Author: ThomasObrien95
Date: Thu Jan 27 11:30:54 2011
Log: The next button on the validation screen becomes disabled when the
last graph is reached.
http://code.google.com/p/power-matchmaker/source/detail?r=2771

Modified:
/branches/0.9.7/src/ca/sqlpower/matchmaker/swingui/MMSUtils.java

/branches/0.9.7/src/ca/sqlpower/matchmaker/swingui/MatchResultVisualizer.java

=======================================
--- /branches/0.9.7/src/ca/sqlpower/matchmaker/swingui/MMSUtils.java Thu
Jan 27 10:06:15 2011
+++ /branches/0.9.7/src/ca/sqlpower/matchmaker/swingui/MMSUtils.java Thu
Jan 27 11:30:54 2011
@@ -29,6 +29,7 @@
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
+import java.math.BigInteger;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -571,6 +572,54 @@
}
}
return db;
- }
-
-}
+ }
+
+ /**
+ * Returns the largest graph number so we know when we get to the end of
the
+ * generated graphs.
+ */
+ public static BigInteger findMaxGraphNumber(MatchMakerSession session,
Project project) throws SQLException {
+ SQLDatabase db = MatchMakerUtils.createProjectGraphDataSource(session,
project);
+ Connection testConnection = null;
+ Statement stmt = null;
+ ResultSet rs = null;
+ try {
+ testConnection = db.getConnection();
+ stmt = testConnection.createStatement();
+ rs = stmt.executeQuery("SELECT MAX(" +
MatchMakerUtils.GRAPH_ID_COL_NAME + ") FROM " +
MatchMakerUtils.GRAPH_TABLE_NAME);
+ if (rs.next()) {
+ if (rs.getBigDecimal(1) != null) {
+ return rs.getBigDecimal(1).toBigInteger();
+ } else {
+ return BigInteger.ZERO;
+ }
+ } else {
+ return BigInteger.ZERO;
+ }
+ } catch (SQLObjectException e) {
+ throw new SQLObjectRuntimeException(e);
+ } finally {
+ if (rs != null) {
+ try {
+ rs.close();
+ } catch (Exception e) {
+ logger.error("Error closing statement to graph db.", e);
+ }
+ }
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (Exception e) {
+ logger.error("Error closing statement to graph db.", e);
+ }
+ }
+ if (testConnection != null) {
+ try {
+ testConnection.close();
+ } catch (Exception e) {
+ logger.error("Error closing connection test.", e);
+ }
+ }
+ }
+ }
+}
=======================================
---
/branches/0.9.7/src/ca/sqlpower/matchmaker/swingui/MatchResultVisualizer.java
Thu Jan 27 10:06:15 2011
+++
/branches/0.9.7/src/ca/sqlpower/matchmaker/swingui/MatchResultVisualizer.java
Thu Jan 27 11:30:54 2011
@@ -752,12 +752,15 @@
*/
private BigInteger endGraph = BigInteger.valueOf(4);

+ private final BigInteger maxGraphNumber;
+
public MatchResultVisualizer(Project project, MatchMakerSwingSession
session) throws SQLException, SQLObjectException {
super();
if (!MMSUtils.checkForGraphTable(session, project, logger)) {
SQLDatabase db = MMSUtils.setupProjectGraphTable(session, project,
logger);
MMSUtils.populateProjectGraphTable(project, logger, db);
}
+ maxGraphNumber = MMSUtils.findMaxGraphNumber(session, project);
this.project = project;

if (!project.doesSourceTableExist() |
| !project.verifySourceTableStructure()) {
@@ -1007,6 +1010,12 @@
if (startGraph.equals(BigInteger.ZERO)) {
prevButton.setEnabled(false);
}
+ if (endGraph.compareTo(maxGraphNumber) == 1) {
+ endGraph = maxGraphNumber;
+ }
+ if (endGraph.equals(maxGraphNumber)) {
+ nextButton.setEnabled(false);
+ }
}

/**

Reply all
Reply to author
Forward
0 new messages