Changeset 6288
- Timestamp:
- 2003-12-17T13:15:07+13:00 (20 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/AbstractHierarchyNode.java
r6104 r6288 15 15 public abstract class AbstractHierarchyNode 16 16 { 17 String prefix; // a basic prefix used in this hierarchy 17 18 String descriptor; // the textual descriptor used on screen or long-hand 18 19 String name; // the index number, letter assignment or other item … … 35 36 this.name = null; 36 37 this.id = null; 38 this.prefix = null; 37 39 this.childNodes = new ArrayList(); 38 40 this.childDocs = new ArrayList(); … … 41 43 } 42 44 43 public AbstractHierarchyNode(String name, String id, String descriptor)45 public AbstractHierarchyNode(String prefix, String name, String id, String descriptor) 44 46 { this.descriptor = descriptor; 45 47 this.name = name; 46 48 this.id = id; 49 this.prefix = prefix; 47 50 this.childNodes = new ArrayList(); 48 51 this.childDocs = new ArrayList(); … … 96 99 97 100 public String getParentId() 98 { int dotAt = this.id.lastIndexOf('.'); 101 { 102 if (this.id == null) { 103 return ""; 104 } 105 106 int dotAt = this.id.lastIndexOf('.'); 99 107 if (dotAt < 0) { 100 108 return ""; … … 188 196 select = new GS3SQLSelect("classifiers"); 189 197 select.addField("ClassifyRef"); 190 GS3SQLWhereItem whereItem = new GS3SQLWhereItem("ClassifyID", "=", this. id);198 GS3SQLWhereItem whereItem = new GS3SQLWhereItem("ClassifyID", "=", this.prefix+"."+this.id); 191 199 GS3SQLWhere where = new GS3SQLWhere(whereItem); 192 200 select.setWhere(where); … … 206 214 else { 207 215 insert = new GS3SQLInsert("classifiers"); 208 if (this.parent != null) { 209 insert.addValue("ParentID", this.getParentId()); 216 217 String parentId = this.getParentId(); 218 219 if (parentId.length() > 0) { 220 insert.addValue("ParentID", this.prefix+"."+this.getParentId()); 210 221 } 222 else { 223 insert.addValue("ParentID", this.prefix); 224 } 211 225 212 226 action = insert; 213 227 } 214 action.addValue("ClassifyID", this. id);228 action.addValue("ClassifyID", this.prefix+"."+this.id); 215 229 action.addValue("Name", this.name); 216 230 action.addValue("Description", this.descriptor); … … 246 260 247 261 // delete child documents 248 GS3SQLDelete delete = new GS3SQLDelete("class ifydocuments");262 GS3SQLDelete delete = new GS3SQLDelete("classdocuments"); 249 263 delete.setWhere(where); 250 264 … … 266 280 while (iterator.hasNext()) { 267 281 DocumentID docId = (DocumentID) iterator.next(); 268 insert = new GS3SQLInsert("class ifydocuments");282 insert = new GS3SQLInsert("classdocuments"); 269 283 insert.addValue("ClassifyRef", Integer.toString(classifyRef), GS3SQLField.INTEGER_TYPE); 270 284 insert.addValue("DocID", docId.toString()); 285 286 connection.execute(insert.toString()); 271 287 } 272 288 return true; -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/GS2HierarchyClassifier.java
r6104 r6288 49 49 } 50 50 51 public GS2HierarchyNode(String name, String id, String descriptor)52 { super( name, id, descriptor);51 public GS2HierarchyNode(String prefix, String name, String id, String descriptor) 52 { super(prefix, name, id, descriptor); 53 53 } 54 54 … … 97 97 98 98 this.rootNode = new GS2HierarchyNode(); 99 String prefix = "CL"+hierarchyName; 99 100 100 101 while (this.hasMoreLines()) { … … 120 121 121 122 // Initialise the tree 122 GS2HierarchyNode node = new GS2HierarchyNode( name, "CL"+hierarchyName+"."+id, description);123 GS2HierarchyNode node = new GS2HierarchyNode(prefix, name, id, description); 123 124 124 125 this.rootNode.add(node); … … 224 225 */ 225 226 public boolean classifyDocument(DocumentID documentID, DocumentInterface document) 226 { // the observer records the assignment of documents to classifications 227 { if (this.hierarchy == null) { 228 return true; 229 } 230 231 // the observer records the assignment of documents to classifications 227 232 GS2HierarchyClassifierObserver classifyObserver = new GS2HierarchyClassifierObserver(document); 228 233 … … 241 246 } 242 247 248 System.out.println("Matching " + values.get(0).toString()); 249 250 if (documentID == null) { 251 System.out.println("Bad documentID"); 252 continue; 253 } 254 243 255 // ...and send them to the classifier 244 256 this.hierarchy.getClassifications(documentID, values, classifyObserver);
Note:
See TracChangeset
for help on using the changeset viewer.