Changeset 6010
- Timestamp:
- 2003-11-26T15:35:27+13:00 (20 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/DocumentFactory.java
r5944 r6010 11 11 { return new TextDocument(id); 12 12 } 13 else if (type.equals(IndexDocument.INDEX_DOCUMENT_TYPE)) 14 { return new IndexDocument(id); 15 } 13 16 return null; 14 17 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/DocumentIDFactory.java
r5800 r6010 4 4 5 5 public class DocumentIDFactory implements DocumentIDFactoryInterface 6 { 6 { private CollectionManager collection; 7 7 8 9 10 8 public DocumentIDFactory(CollectionManager collection) 9 { this.collection = collection; 10 } 11 11 12 13 {DocumentID id;12 public DocumentID getNewDocumentID(DocumentInterface document) 13 { DocumentID id; 14 14 15 16 17 18 19 15 String idString = this.collection.getNextDocumentID(); 16 id = new DocumentID(idString); 17 18 return id; 19 } 20 20 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/DocumentList.java
r5944 r6010 14 14 import java.sql.SQLException; 15 15 import java.sql.ResultSet; 16 17 import org.greenstone.gsdl3.gs3build.metadata.METSFileGroup; 16 18 17 19 import org.greenstone.gsdl3.gs3build.util.GS3SQLConnection; … … 48 50 this.count = 0; 49 51 this.connection = connection; 52 } 53 54 public List findDocumentIdsUsingFile(String fileRef) 55 { 56 // Get the simple list of file objects & their file group reference 57 String query = "SELECT FileGroupRef FROM files WHERE FileLocation REGEXP \"" + fileRef +"\";"; 58 59 this.connection.execute(query); 60 61 try { 62 63 ResultSet results = this.connection.getResultSet(); 64 if (results == null || 65 !results.first()) { 66 return null; 67 } 68 69 // get a list of group ids first and turn it into a query on filegroups 70 StringBuffer queryBuffer = new StringBuffer("SELECT * FROM filegroups WHERE "); 71 boolean first = true; 72 73 do { 74 int groupRef = results.getInt("FileGroupRef"); 75 76 if (first) { 77 first = false; 78 } 79 else { 80 queryBuffer.append(" OR "); 81 } 82 queryBuffer.append("FileGroupRef=" + Integer.toString(groupRef)); 83 } while (results.next()); 84 queryBuffer.append(";"); 85 86 // make a holder for the actual file section identifiers 87 List divisions = new ArrayList(); 88 89 // expand (or, in fact, contract) through the document 90 // structures...recreating new filegroup queries as necessary 91 while (queryBuffer.length() > 0) { 92 connection.execute(queryBuffer.toString()); 93 94 results = this.connection.getResultSet(); 95 if (results == null || !results.first()) { 96 return null; 97 } 98 99 queryBuffer = new StringBuffer(); 100 do { 101 String type = results.getString("ParentType"); 102 String parentRef = results.getString("ParentRef"); 103 if (type.equals(METSFileGroup.SECTION_PARENT)) { 104 divisions.add(parentRef); 105 } 106 else { 107 if (queryBuffer.length() > 0) { 108 queryBuffer.append(" OR "); 109 } 110 queryBuffer.append("FileGroupRef=" + parentRef); 111 } 112 } while (results.next()); 113 114 if (queryBuffer.length() > 0) { 115 queryBuffer.insert(0, "SELECT * FROM filegroups WHERE "); 116 queryBuffer.append(";"); 117 } 118 } 119 120 // ok, now find all the sections in which we are interested... 121 queryBuffer.setLength(0); 122 queryBuffer.append("SELECT DISTINCT DocID FROM filesection WHERE "); 123 Iterator iterator = divisions.iterator(); 124 first = true; 125 126 while (iterator.hasNext()) { 127 String ref = iterator.next().toString(); 128 129 if (first) { 130 first = false; 131 } 132 else { 133 queryBuffer.append(" OR "); 134 } 135 136 queryBuffer.append("FileSectionRef="+ref); 137 } 138 queryBuffer.append(";"); 139 140 // execute the division query 141 this.connection.execute(queryBuffer.toString()); 142 143 results = this.connection.getResultSet(); 144 if (results == null || 145 !results.first()) { 146 return null; 147 } 148 149 List reply = new ArrayList(); 150 do { 151 reply.add(results.getString("DocID")); 152 } while (results.next()); 153 154 return reply; 155 } 156 catch (SQLException ex) { 157 System.err.println(ex); 158 } 159 return null; 50 160 } 51 161 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/DocumentSQLWriter.java
r5944 r6010 54 54 // which would suggest placing it in the AbstractDocument or similar 55 55 // class?! 56 if (document.getDocumentMetadata() == null) { 57 System.out.println("Null metadata document"); 58 } 56 59 document.getDocumentMetadata().writeSQL(document, connection); 57 60 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/IndexDocument.java
r5944 r6010 22 22 { 23 23 public static final String INDEX_DOCUMENT_TYPE = "GSINDEX"; 24 24 25 public IndexDocument(DocumentID id) 26 { super(id); 27 } 28 25 29 public IndexDocument(URL url) 26 30 { super(url); … … 38 42 } 39 43 40 public METSDescriptiveSet getDocumentMetadata() 41 { return null; 44 /** 45 * Indicate whether this document is indexed. 46 * 47 * @see: DocumentInterface.isIndexed 48 */ 49 public boolean isIndexed() 50 { 51 return true; 42 52 } 53 43 54 }
Note:
See TracChangeset
for help on using the changeset viewer.