Changeset 8422
- Timestamp:
- 2004-10-31T16:30:46+13:00 (19 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/CollectionManager.java
r8418 r8422 19 19 import java.net.URLEncoder; 20 20 21 import java.sql.*; 22 21 23 import javax.xml.parsers.*; 22 24 … … 31 33 import org.xml.sax.SAXParseException; 32 34 35 import org.greenstone.gsdl3.gs3build.database.*; 33 36 import org.greenstone.gsdl3.gs3build.collection.*; 34 37 import org.greenstone.gsdl3.gs3build.classifier.*; … … 124 127 return null; 125 128 } 126 System.out.println( this.type.toLowerCase());129 System.out.println("Creating a classifier of type " + this.type.toLowerCase()); 127 130 128 131 if (this.type.toLowerCase().equals("hierarchy")) { 129 System.out.println( this.file);132 System.out.println(" hierarchy file is " + this.file); 130 133 classifier = new HierarchyClassifier(this.className, this.file, this.fields, this.sort); 131 134 } … … 197 200 198 201 this.buildDocNo = 1; 202 203 try { 204 GS3SQLSelect select = new GS3SQLSelect("build"); 205 select.addField("*"); 206 this.database.execute(select.toString()); 207 ResultSet results = this.database.getResultSet(); 208 if (results != null && 209 results.first()) { 210 System.out.println("Reading all keys"); 211 do { 212 String key = results.getString("buildKey"); 213 String value = results.getString("buildValue"); 214 215 if (key.equals("NextSeqNo")) { 216 this.buildDocNo = Integer.parseInt(value); 217 } 218 else if (key.equals("lastBuildDate")) { 219 int year, month, day; 220 year = Integer.parseInt(value.substring(0, 4)); 221 month = Integer.parseInt(value.substring(4, 6)) - 1; // -1 because Gregorian Calendar perversely treats January as 0, etc. 222 day = Integer.parseInt(value.substring(6, 8)); 223 224 this.lastBuildDate = new GregorianCalendar(year, month, day); 225 } 226 } while (results.next()); 227 } 228 } 229 catch (SQLException ex) 230 { System.out.println(ex); 231 } 199 232 } 200 233 … … 249 282 public void configureCollection() 250 283 { File collectionConfig = new File(GSFile.collectionConfigFile(this.collectionHome)); 251 284 252 285 // get the File and read it in 253 286 try … … 360 393 361 394 public String getEtcDirectory() 362 363 395 { return GSFile.collectionEtcDir(this.collectionHome); 364 396 } … … 370 402 public String getBuildDirectory() 371 403 { return GSFile.collectionBuildDir(this.collectionHome); 372 }373 374 public GregorianCalendar getLastBuildDate(){375 return lastBuildDate;376 404 } 377 405 … … 400 428 { this.buildDocNo = 1; 401 429 } 430 else 431 { System.out.println("Continuing build sequence from " + this.buildDocNo); 432 } 402 433 } 403 434 this.lastBuildDate = today; … … 406 437 public void endBuild() 407 438 { 408 // here we write out the build config file 409 // create the xml for the buildConfig 410 XMLConverter converter = new XMLConverter(); 411 Document doc = converter.newDOM(); 412 Element build_config = doc.createElement(GSXML.COLLECTION_BUILD_ELEM); 413 Element meta_list = doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 414 build_config.appendChild(meta_list); 415 Element service_list = doc.createElement(GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER); 416 build_config.appendChild(service_list); 417 418 // the document structure and metadata retrieval will use GS3REtrieve service, so add it in here 419 Element base_retrieve_service = doc.createElement(GSXML.SERVICE_CLASS_ELEM); 420 base_retrieve_service.setAttribute(GSXML.NAME_ATT, "GS3Retrieve"); 421 service_list.appendChild(base_retrieve_service); 422 // ask the indexers to add stuff into the service rack list 423 this.buildManager.getIndexerManager().addServiceDescriptions(service_list); 424 this.buildManager.getClassifierManager().addServiceDescriptions(service_list); 425 // get the String 426 String build_config_string = converter.getString(build_config); 427 // write it to the file 428 try { 429 File build_config_file = new File(GSFile.collectionBuildConfigFileBuilding(this.collectionHome)); 430 BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(build_config_file), "UTF-8")); 431 writer.write(build_config_string, 0, build_config_string.length()); 432 writer.close(); 433 } catch (Exception e) { 434 System.err.println("CollectionManager.endBuild() Error while trying to output the buildConfig.xml file."); 435 System.err.println(e.getMessage()); 436 } 439 // here we write out the build config file 440 // create the xml for the buildConfig 441 XMLConverter converter = new XMLConverter(); 442 Document doc = converter.newDOM(); 443 Element build_config = doc.createElement(GSXML.COLLECTION_BUILD_ELEM); 444 Element meta_list = doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER); 445 build_config.appendChild(meta_list); 446 Element service_list = doc.createElement(GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER); 447 build_config.appendChild(service_list); 448 449 // the document structure and metadata retrieval will use GS3REtrieve service, so add it in here 450 Element base_retrieve_service = doc.createElement(GSXML.SERVICE_CLASS_ELEM); 451 base_retrieve_service.setAttribute(GSXML.NAME_ATT, "GS3Retrieve"); 452 service_list.appendChild(base_retrieve_service); 453 // ask the indexers to add stuff into the service rack list 454 this.buildManager.getIndexerManager().addServiceDescriptions(service_list); 455 this.buildManager.getClassifierManager().addServiceDescriptions(service_list); 456 // get the String 457 String build_config_string = converter.getString(build_config); 458 // write it to the file 459 try { 460 File build_config_file = new File(GSFile.collectionBuildConfigFileBuilding(this.collectionHome)); 461 BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(build_config_file), "UTF-8")); 462 writer.write(build_config_string, 0, build_config_string.length()); 463 writer.close(); 464 } catch (Exception e) { 465 System.err.println("CollectionManager.endBuild() Error while trying to output the buildConfig.xml file."); 466 System.err.println(e.getMessage()); 467 } 468 469 // Update build date information 470 GS3SQLDelete remove = new GS3SQLDelete("build"); 471 // GS3SQLWhere where = new GS3SQLWhere(new GS3SQLWhereItem("buildKey", "=", "NextSeqNo")); 472 // rem 473 this.database.execute(remove.toString()); 474 475 GS3SQLInsert insert = new GS3SQLInsert("build"); 476 insert.addValue("buildKey", "NextSeqNo"); 477 insert.addValue("buildValue", Integer.toString(this.buildDocNo)); 478 this.database.execute(insert.toString()); 479 480 insert = new GS3SQLInsert("build"); 481 insert.addValue("buildKey", "lastBuildDate"); 482 insert.addValue("buildValue", getDateString(this.lastBuildDate)); 483 this.database.execute(insert.toString()); 484 485 // Do tail of build output 437 486 Date startDate = this.lastBuildDate.getTime(); 438 487 Date date = new Date(); … … 449 498 } 450 499 451 p ublic String getNextDocumentID()452 { StringBuffer ID= new StringBuffer();453 500 private static String getDateString(GregorianCalendar date) 501 { StringBuffer dateString = new StringBuffer(); 502 454 503 int value; 455 ID.append(lastBuildDate.get(Calendar.YEAR));504 dateString.append(date.get(Calendar.YEAR)); 456 505 457 506 // the use of month is a little odd, hence the following … … 460 509 // it into January = 1, etc., and the padding is altered 461 510 // correspondingly. 462 value = lastBuildDate.get(Calendar.MONTH);511 value = date.get(Calendar.MONTH); 463 512 if (value < 9) 464 { ID.append("0");465 } 466 ID.append(value + 1);467 value = lastBuildDate.get(Calendar.DAY_OF_MONTH);513 { dateString.append("0"); 514 } 515 dateString.append(value + 1); 516 value = date.get(Calendar.DAY_OF_MONTH); 468 517 if (value < 10) 469 ID.append("0"); 470 ID.append(value); 471 472 473 value = this.buildDocNo; 518 dateString.append("0"); 519 dateString.append(value); 520 521 return dateString.toString(); 522 } 523 524 public String getNextDocumentID() 525 { StringBuffer ID = new StringBuffer(getDateString(this.lastBuildDate)); 526 527 int value = this.buildDocNo; 474 528 this.buildDocNo ++; 475 529 -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/DocumentList.java
r8421 r8422 321 321 // set the document identifier, if not already set 322 322 if (document.getID() == null) { 323 System.out.println("Posting new docuument ID"); 323 324 DocumentID id = this.idFactory.getNewDocumentID(document); 324 325 document.setID(id); … … 327 328 // add to the database as well, if it is modified... 328 329 if (document.isChanged()) { 330 System.out.println("Document was changed"); 329 331 document.getSQLWriter().writeDocument(document, this.connection); 330 332 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/doctypes/TextRecogniser.java
r7466 r8422 38 38 { this.listRepository.addDocument(new TextDocument(url)); 39 39 // TODO: spawn knowledge of children too... 40 System.out.println(" >>>Posting text document " + fileName);40 System.out.println("Posting text document " + fileName); 41 41 return true; 42 42 } -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/indexers/IndexerManager.java
r8408 r8422 47 47 { for (int p = 0; p < this.indexers[i].getNumberOfPasses(); p ++) 48 48 { 49 if (!this.indexers[i].startPass(p)) { 50 continue; 51 } 49 if (!this.indexers[i].startPass(p)) { 50 continue; 51 } 52 52 53 Iterator iterator = this.documentList.iterator(); 53 54 … … 62 63 // note any changes made to this document... 63 64 if (document.isChanged()) { 65 //System.out.println("Writing document "+document.getID()); 64 66 this.documentList.storeChangedDocument(document); 65 // System.out.println("Writing document "+document.getID());66 67 } 67 68 /** -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/util/GS3SQLConnection.java
r8408 r8422 9 9 import java.sql.Statement; 10 10 import java.sql.ResultSet; 11 12 11 13 12 import org.greenstone.gsdl3.gs3build.database.*; … … 193 192 this.connection = GS3SQLConnectionFactory.reconnect(collectionName); 194 193 194 statement = this.connection.createStatement(); 195 196 // create build history table 197 GS3SQLCreateTable buildTable = new GS3SQLCreateTable("build"); 198 buildTable.addAutoPrimaryKey("buildRef"); 199 buildTable.addProperty("buildKey", 64); 200 buildTable.addProperty("buildValue"); 201 statement.execute(buildTable.toString()); 202 195 203 // create document table 196 204 GS3SQLCreateTable docTable = new GS3SQLCreateTable("document"); … … 202 210 docTable.addProperty("IndexedDate", GS3SQLField.DATETIME_TYPE); 203 211 docTable.addProperty("ModifiedDate", GS3SQLField.DATETIME_TYPE); 204 statement = this.connection.createStatement();205 212 statement.execute(docTable.toString()); 206 213 207 // 214 // create structure table 208 215 GS3SQLCreateTable structureMap = new GS3SQLCreateTable("structure"); 209 216 structureMap.addAutoPrimaryKey("StructureRef"); … … 215 222 statement.execute(structureMap.toString()); 216 223 217 // 224 // create section table 218 225 GS3SQLCreateTable sectionMap = new GS3SQLCreateTable("divisions"); 219 226 sectionMap.addAutoPrimaryKey("DivisionRef"); … … 266 273 namespaces.addProperty("Creator", 128); 267 274 statement.execute(namespaces.toString()); 268 269 // create metadata values table 275 276 // create metadata grouping table 277 GS3SQLCreateTable metagroups = new GS3SQLCreateTable("mdgroups"); 278 metagroups.addProperty("NamespaceRef", GS3SQLField.INTEGER_TYPE); 279 metagroups.addAutoPrimaryKey("MdGroupRef"); 280 metagroups.addProperty("MdGroupID", 32); 281 statement.execute(metagroups.toString()); 282 283 // create metadata qualifiers table 284 GS3SQLCreateTable metaqualifiers = new GS3SQLCreateTable("mdqualifiers"); 285 metaqualifiers.addProperty("MdGroupRef", GS3SQLField.INTEGER_TYPE); 286 metaqualifiers.addProperty("QualifierName", 64); 287 metaqualifiers.addProperty("QualifierValue", 64); 288 statement.execute(metaqualifiers.toString()); 289 290 // create metadata values table 270 291 GS3SQLCreateTable metadata = new GS3SQLCreateTable("mdvalues"); 271 // todo: some unique id for the namespaces item272 metadata.addProperty(" NamespaceRef", GS3SQLField.INTEGER_TYPE);273 metadata.addProperty("Label", 256); 274 metadata.addProperty("Value"); 292 metadata.addProperty("NamespaceRef", GS3SQLField.INTEGER_TYPE); // the parent namespace {one candidate primary key} 293 metadata.addProperty("GroupRef", GS3SQLField.INTEGER_TYPE); // the parent group {a sub-key or independent primary key} 294 metadata.addProperty("Label", 256); // the key of the metadata item 295 metadata.addProperty("Value"); // the value of the metadata item 275 296 statement.execute(metadata.toString()); 276 297
Note:
See TracChangeset
for help on using the changeset viewer.