Here is a patch for the StandardRDBMSAdapter. The table VERSION_PREDS was not well managed into this adapter and so, gives some integrity errors when a revision descriptor is deleted via the Macro Helper.
VERSION_PREDS is maybe not a good name because the class RevisionDescriptors uses the term 'successor'. So, maybe VERSION_SUCCESSORS or something like that will be more appropriate.
Christophe
Index: StandardRDBMSAdapter.java
===================================================================
retrieving revision 1.20
diff -u -r1.20 StandardRDBMSAdapter.java
--- StandardRDBMSAdapter.java 3 Mar 2004 12:06:47 -0000 1.20
+++ StandardRDBMSAdapter.java 13 Mar 2004 23:00:39 -0000
@@ -709,11 +709,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 {
@@ -872,12 +873,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()) {
@@ -892,22 +895,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();
@@ -923,20 +929,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;
@@ -948,7 +954,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();
@@ -959,7 +965,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();
@@ -971,7 +977,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();
@@ -983,7 +989,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);
@@ -993,15 +999,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]
