ozeigermann 2004/03/23 06:04:13
Modified: src/stores/org/apache/slide/store/impl/rdbms Tag:
SLIDE_2_0_RELEASE_BRANCH StandardRDBMSAdapter.java
Log:
Applied patch my Christophe Lombart to correctly manager table VERSION_PREDS.
Revision Changes Path
No revision
No revision
1.14.2.6 +69 -28
jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java
Index: StandardRDBMSAdapter.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java,v
retrieving revision 1.14.2.5
retrieving revision 1.14.2.6
diff -u -r1.14.2.5 -r1.14.2.6
--- StandardRDBMSAdapter.java 3 Mar 2004 12:07:50 -0000 1.14.2.5
+++ StandardRDBMSAdapter.java 23 Mar 2004 14:04:13 -0000 1.14.2.6
@@ -710,11 +710,12 @@
PreparedStatement statement = null;
ResultSet res = null;
try {
- // FIXME Statement never executed and asymmetric vs
createRevisionDescriptors.
+
statement =
connection.prepareStatement(
- "delete VERSION_PREDS from VERSION_PREDS vp, VERSION_HISTORY
vh, URI u where vp.VERSION_ID = vh.VERSION_ID and vh.URI_ID = u.URI_ID and
u.URI_STRING = ?");
+ "delete VERSION_PREDS from VERSION_PREDS vp, VERSION_HISTORY vh,
URI u where vp.VERSION_ID = vh.VERSION_ID and vh.URI_ID = u.URI_ID and u.URI_STRING =
?");
statement.setString(1, uri.toString());
+ statement.executeUpdate();
} catch (SQLException e) {
throw createException(e, uri.toString());
} finally {
@@ -873,12 +874,14 @@
Hashtable workingRevisions = new Hashtable();
Hashtable latestRevisionNumbers = new Hashtable();
Hashtable branches = new Hashtable();
+ Vector allRevisions = new Vector();
+
boolean isVersioned = false;
// check if versioned
try {
statement =
connection.prepareStatement(
- "select IS_VERSIONED from VERSION v, URI u where v.URI_ID =
u.URI_ID and u.URI_STRING = ?");
+ "select IS_VERSIONED from VERSION v, URI u where v.URI_ID =
u.URI_ID and u.URI_STRING = ?");
statement.setString(1, uri.toString());
res = statement.executeQuery();
if (res.next()) {
@@ -893,22 +896,25 @@
try {
statement =
connection.prepareStatement(
- "select vh.REVISION_NO, b.BRANCH_STRING from
VERSION_HISTORY vh, BRANCH b, URI u where vh.BRANCH_ID = b.BRANCH_ID and vh.URI_ID =
u.URI_ID and u.URI_STRING = ?");
+ "select vh.REVISION_NO, b.BRANCH_STRING from VERSION_HISTORY
vh, BRANCH b, URI u where vh.BRANCH_ID = b.BRANCH_ID and vh.URI_ID = u.URI_ID and
u.URI_STRING = ? order by vh.REVISION_NO ");
statement.setString(1, uri.toString());
res = statement.executeQuery();
while (res.next()) {
- latestRevisionNumbers.put(res.getString(2), new
NodeRevisionNumber(res.getString(1)));
+ NodeRevisionNumber revisionNumber = new
NodeRevisionNumber(res.getString(1));
+ allRevisions.add(revisionNumber); // will be used to get
revisions successor
+ latestRevisionNumbers.put(res.getString(2), revisionNumber); //
store the lastest revision / branch
}
} finally {
close(statement, res);
}
- for (Enumeration e = latestRevisionNumbers.elements();
e.hasMoreElements();) {
+
+ for (Enumeration e = allRevisions.elements(); e.hasMoreElements();) {
NodeRevisionNumber revisionNumber = (NodeRevisionNumber)
e.nextElement();
- // get predecessors
+ // get successors
try {
statement =
connection.prepareStatement(
- "select pvh.REVISION_NO from VERSION_HISTORY vh,
VERSION_HISTORY pvh, VERSION_PREDS vp, URI u where pvh.VERSION_ID = vp.VERSION_ID and
vp.VERSION_ID = vh.VERSION_ID and vh.URI_ID = u.URI_ID and u.URI_STRING = ? and
vh.REVISION_NO"
+ "select pvh.REVISION_NO from VERSION_HISTORY vh,
VERSION_HISTORY pvh, VERSION_PREDS vp, URI u where pvh.VERSION_ID = vp.VERSION_ID and
vp.VERSION_ID = vh.VERSION_ID and vh.URI_ID = u.URI_ID and u.URI_STRING = ? and
vh.REVISION_NO"
+
getRevisionNumberAsWhereQueryFragement(revisionNumber));
statement.setString(1, uri.toString());
res = statement.executeQuery();
@@ -924,20 +930,20 @@
}
revisionDescriptors =
new NodeRevisionDescriptors(
- uri.toString(),
- initialRevision,
- workingRevisions,
- latestRevisionNumbers,
- branches,
- isVersioned);
+ uri.toString(),
+ initialRevision,
+ workingRevisions,
+ latestRevisionNumbers,
+ branches,
+ isVersioned);
} catch (SQLException e) {
throw createException(e, uri.toString());
}
return revisionDescriptors;
}
-
+
public void createRevisionDescriptors(Connection connection, Uri uri,
NodeRevisionDescriptors revisionDescriptors)
- throws ServiceAccessException {
+ throws ServiceAccessException {
PreparedStatement statement = null;
ResultSet res = null;
@@ -949,7 +955,7 @@
try {
statement =
connection.prepareStatement(
- "SELECT 1 FROM VERSION v, URI u WHERE v.URI_ID = u.URI_ID
and u.URI_STRING = ?");
+ "SELECT 1 FROM VERSION v, URI u WHERE v.URI_ID = u.URI_ID and
u.URI_STRING = ?");
statement.setString(1, uri.toString());
res = statement.executeQuery();
revisionExists = res.next();
@@ -960,7 +966,7 @@
try {
statement =
connection.prepareStatement(
- "insert into VERSION (URI_ID, IS_VERSIONED) select
u.URI_ID, ? from URI u where u.URI_STRING = ?");
+ "insert into VERSION (URI_ID, IS_VERSIONED) select
u.URI_ID, ? from URI u where u.URI_STRING = ?");
statement.setInt(1, isVersioned);
statement.setString(2, uri.toString());
statement.executeUpdate();
@@ -972,7 +978,7 @@
try {
statement =
connection.prepareStatement(
- "SELECT 1 FROM VERSION_HISTORY vh, URI u WHERE vh.URI_ID =
u.URI_ID and u.URI_STRING = ? and REVISION_NO"
+ "SELECT 1 FROM VERSION_HISTORY vh, URI u WHERE
vh.URI_ID = u.URI_ID and u.URI_STRING = ? and REVISION_NO"
+
getRevisionNumberAsWhereQueryFragement(revisionDescriptors.getLatestRevision()));
statement.setString(1, uri.toString());
res = statement.executeQuery();
@@ -984,7 +990,7 @@
try {
statement =
connection.prepareStatement(
- "insert into VERSION_HISTORY (URI_ID, BRANCH_ID,
REVISION_NO) select u.URI_ID, b.BRANCH_ID, ? from URI u, BRANCH b where u.URI_STRING =
? and b.BRANCH_STRING = ?");
+ "insert into VERSION_HISTORY (URI_ID, BRANCH_ID,
REVISION_NO) select u.URI_ID, b.BRANCH_ID, ? from URI u, BRANCH b where u.URI_STRING =
? and b.BRANCH_STRING = ?");
statement.setString(1,
getRevisionNumberAsString(revisionDescriptors.getLatestRevision()));
statement.setString(2, uri.toString());
statement.setString(3, NodeRevisionDescriptors.MAIN_BRANCH);
@@ -994,15 +1000,50 @@
close(statement, res);
}
}
+
+
+ // Add revision successors
+ Enumeration revisionNumbers =
revisionDescriptors.enumerateRevisionNumbers();
+ while (revisionNumbers.hasMoreElements()) {
+ NodeRevisionNumber nodeRevisionNumber = (NodeRevisionNumber)
revisionNumbers.nextElement();
+
+ Enumeration successors =
revisionDescriptors.getSuccessors(nodeRevisionNumber);
+ while (successors.hasMoreElements())
+ {
+ try {
+ NodeRevisionNumber successor = (NodeRevisionNumber)
successors.nextElement();
+
+ statement =
+ connection.prepareStatement(
+ "insert into VERSION_PREDS (VERSION_ID,
PREDECESSOR_ID) " +
+ " select vr.version_id , suc.version_id" +
+ " FROM uri, version_history vr,
version_history suc " +
+ " where vr.uri_id = uri.uri_id " +
+ " and suc.uri_id = uri.uri_id " +
+ " and uri_string = ? " +
+ " and vr.revision_no = ? " +
+ " and suc.revision_no = ? " );
+
+ statement.setString(1, uri.toString());
+ statement.setString(2, nodeRevisionNumber.toString());
+ statement.setString(3, successor.toString());
+ statement.executeUpdate();
+ } finally {
+ close(statement);
+ }
+ }
+ }
getLogger().log(
- revisionDescriptors.getOriginalUri() +
revisionDescriptors.getInitialRevision(),
- LOG_CHANNEL,
- Logger.INFO);
+ revisionDescriptors.getOriginalUri() +
revisionDescriptors.getInitialRevision(),
+ LOG_CHANNEL,
+ Logger.INFO);
+
+
} catch (SQLException e) {
throw createException(e, uri.toString());
}
}
-
+
public void createRevisionContent(
Connection connection,
Uri uri,
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]