Changeset 9874 for trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/AbstractDocument.java
- Timestamp:
- 2005-05-16T11:02:50+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/AbstractDocument.java
r8742 r9874 9 9 10 10 import java.sql.SQLException; 11 import java.sql.Statement; 11 12 import java.sql.ResultSet; 12 13 import java.sql.Timestamp; … … 190 191 // Query for documents using the same file... 191 192 String query = "SELECT DocID FROM files INNER JOIN filegroups ON files.FileGroupRef=filegroups.FileGroupRef WHERE (filegroups.FileGroupId=\"default\" AND files.FileLocation=\"" + this.fileSet.getFile(0).getLocation().toString() + "\")"; 192 connection.execute(query);193 194 List docs = new ArrayList();195 ResultSet results = connection.getResultSet();196 197 193 try { 198 if (results != null && 199 results.first()) 200 { do { 201 String value = results.getString("DocID"); 202 203 docs.add(value); 204 } while (results.next()); 205 206 Iterator docIterator = docs.iterator(); 207 while (docIterator.hasNext()) { 208 String docId = docIterator.next().toString(); 209 String innerQuery = "SELECT * FROM document WHERE DocID=\"" + docId + "\""; 210 connection.execute(innerQuery); 211 ResultSet innerSet = connection.getResultSet(); 212 if (innerSet != null && innerSet.first()) { 213 String docType = innerSet.getString("DocType"); 214 if (docType.equals(this.getDocumentType())) { 215 return docId; 194 Statement statement = connection.createStatement(); 195 ResultSet results = statement.executeQuery(query); 196 197 List docs = new ArrayList(); 198 199 if (results.first()) { 200 do { 201 String value = results.getString("DocID"); 202 docs.add(value); 203 } while (results.next()); 204 205 Iterator docIterator = docs.iterator(); 206 while (docIterator.hasNext()) { 207 String docId = docIterator.next().toString(); 208 String innerQuery = "SELECT * FROM document WHERE DocID=\"" + docId + "\""; 209 results = statement.executeQuery(innerQuery); 210 if (results.first()) { 211 String docType = results.getString("DocType"); 212 if (docType.equals(this.getDocumentType())) { 213 return docId; 214 } 215 } 216 216 } 217 }218 217 } 219 } 218 statement.close(); 220 219 } 221 220 catch (java.sql.SQLException sqlEx) { 222 System.err.println( sqlEx);221 System.err.println("AbstractDocument.getDuplicateID(): "+sqlEx); 223 222 } 224 223 … … 447 446 * Obtain a document from the SQL database 448 447 */ 449 public static AbstractDocument readSQL(GS3SQLConnection connection, ResultSet sqlResult)448 public static AbstractDocument readSQL(GS3SQLConnection connection, ResultSet sqlResult) 450 449 { try { 451 450 DocumentID id = new DocumentID(sqlResult.getString("DocID")); … … 454 453 // Use a factory method to create the correct subtype... 455 454 AbstractDocument document = DocumentFactory.createDocument(type, id); 456 457 455 // Append the document date information 458 456 document.indexDate = sqlResult.getTimestamp("IndexedDate"); … … 473 471 } 474 472 catch (SQLException sqlEx) { 475 System. out.println("Failure to load document: " + sqlEx);473 System.err.println("AbstractDocument.readSQL(): Failure to load document: " + sqlEx); 476 474 } 477 475 return null;
Note:
See TracChangeset
for help on using the changeset viewer.