Changeset 9851 for branches/ant-install-branch
- Timestamp:
- 2005-05-10T15:54:21+12:00 (19 years ago)
- Location:
- branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDescriptive.java
r8742 r9851 389 389 action = update; 390 390 } 391 else 392 { // Set result set to null, just in case next() didn't work above... 393 resultSet = null; 394 395 // It is a new node and needs writing 396 action = new GS3SQLInsert("metadata"); 397 398 action.addValue("DocID", document.getID().toString()); 399 action.addValue("MetaID", this.ID); 400 } 391 else { // Set result set to null, just in case first() didn't work above... 392 resultSet = null; 393 394 // It is a new node and needs writing 395 action = new GS3SQLInsert("metadata"); 396 397 action.addValue("DocID", document.getID().toString()); 398 action.addValue("MetaID", this.ID); 399 } 401 400 402 401 // always set the group identifier … … 406 405 connection.execute(action.toString()); 407 406 408 // create a new resultset if necessary 409 if (resultSet == null) { 410 // now execute the select statement again to get the new identifier 411 // 'MetadataRef' 412 // System.out.println(select.toString()); 413 connection.execute(select.toString()); 414 415 resultSet = connection.getResultSet(); 416 resultSet.first(); 417 } 407 // get the resultSet again 408 // now execute the select statement again to get the new identifier 409 // 'MetadataRef' 410 // System.out.println(select.toString()); 411 connection.execute(select.toString()); 412 413 resultSet = connection.getResultSet(); 414 resultSet.first(); 415 418 416 419 417 // get the reference for this item... 420 418 sqlId = resultSet.getInt("MetadataRef"); 419 connection.closeStatement(); 421 420 } 422 421 catch (SQLException sql){ … … 476 475 // as it will 477 476 ResultSet namespaceSet = connection.getResultSet(); 477 478 // clone the connection cos we are still usign the old result set 479 GS3SQLConnection cloned_connection = connection.cloneConnection(); 480 478 481 if (namespaceSet != null && namespaceSet.first()) { 479 482 do { 480 METSNamespace namespace = METSNamespace.readSQL(c onnection, namespaceSet);483 METSNamespace namespace = METSNamespace.readSQL(cloned_connection, namespaceSet); 481 484 if (namespace != null) { 482 485 descriptive.addNamespace(namespace); … … 488 491 while (namespaceSet.next()); 489 492 } 490 493 cloned_connection.close(); 494 cloned_connection = null; 491 495 return descriptive; 492 496 } 493 497 catch (SQLException sqlEx){ 494 498 System.out.println(sqlEx); 499 sqlEx.printStackTrace(); 495 500 System.exit(1); 496 501 } -
branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDescriptiveSet.java
r8742 r9851 238 238 connection.execute(select.toString()); 239 239 240 // clone the connection cos we are still using the old result set 241 GS3SQLConnection cloned_connection = connection.cloneConnection(); 242 240 243 // start going through the matching metadata blocks 241 244 try { … … 243 246 resultSet.first(); 244 247 do { 245 METSDescriptive descriptive = METSDescriptive.readSQL(document, c onnection, resultSet);248 METSDescriptive descriptive = METSDescriptive.readSQL(document, cloned_connection, resultSet); 246 249 if (descriptive != null) { 247 250 set.addDescriptive(descriptive); … … 251 254 } 252 255 } while (resultSet.next()); 256 257 connection.closeStatement(); 253 258 } 254 259 catch (SQLException sqlEx) { 255 260 System.out.println(sqlEx); 261 sqlEx.printStackTrace(); 256 262 System.exit(1); 257 263 } 258 264 265 259 266 return set; 260 267 } -
branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDivision.java
r8742 r9851 484 484 if (resultSet == null || 485 485 !resultSet.first()) { 486 resultSet = null; 486 if (resultSet != null) { 487 resultSet.close(); 488 resultSet = null; 489 } 487 490 488 491 GS3SQLInsert insert = new GS3SQLInsert("divisions"); … … 499 502 GS3SQLUpdate update = new GS3SQLUpdate("divisions"); 500 503 GS3SQLWhere updateWhere = 501 new GS3SQLWhere(new GS3SQLWhereItem("DivisionRef", "=", Integer.toString(sqlRef), 502 GS3SQLField.INTEGER_TYPE)); 504 new GS3SQLWhere(new GS3SQLWhereItem("DivisionRef", "=", Integer.toString(sqlRef), GS3SQLField.INTEGER_TYPE)); 503 505 update.setWhere(updateWhere); 504 506 action = update; … … 637 639 // circulate through to obtain further children 638 640 ResultSet childSet = connection.getResultSet(); 641 // clone the connection cos we are still usign the old result set 642 GS3SQLConnection cloned_connection = connection.cloneConnection(); 643 639 644 if (childSet.first()) 640 645 { 641 646 do { 642 METSDivision childDivision = METSDivision.readSQL(c onnection, childSet);647 METSDivision childDivision = METSDivision.readSQL(cloned_connection, childSet); 643 648 division.addDivision(childDivision); 644 649 } … … 646 651 } 647 652 653 cloned_connection.close(); 654 cloned_connection = null; 648 655 select = new GS3SQLSelect("divisionfilerefs"); 649 656 select.addField("*"); … … 680 687 } 681 688 689 connection.closeStatement(); 682 690 return division; 683 691 } -
branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFile.java
r8742 r9851 230 230 action.addValue("MIMEType", this.MIMEType); 231 231 232 return connection.execute(action.toString()); 232 boolean return_val = connection.execute(action.toString()); 233 connection.closeStatement(); 234 return return_val; 233 235 } 234 236 -
branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileGroup.java
r8742 r9851 375 375 // parse through the child groups 376 376 ResultSet childSet = connection.getResultSet(); 377 // clone the connection cos we are still usign the old result set 378 GS3SQLConnection cloned_connection = connection.cloneConnection(); 377 379 if (childSet.first()) { 378 380 do { 379 METSFileGroup fileGroup = METSFileGroup.readSQL(document, c onnection, childSet);381 METSFileGroup fileGroup = METSFileGroup.readSQL(document, cloned_connection, childSet); 380 382 if (fileGroup != null) { 381 383 group.addGroup(fileGroup); … … 397 399 if (childFileSet != null && childFileSet.first()) { 398 400 do { 399 METSFile file = METSFile.readSQL(c onnection, childFileSet);401 METSFile file = METSFile.readSQL(cloned_connection, childFileSet); 400 402 if (file != null) { 401 403 group.addFile(file); … … 404 406 while (childFileSet.next()); 405 407 } 406 408 cloned_connection.close(); 409 cloned_connection = null; 407 410 return group; 408 411 } -
branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileSet.java
r8742 r9851 310 310 311 311 // start going through the matching file groups 312 // clone the connection cos we are still usign the old result set 313 GS3SQLConnection cloned_connection = connection.cloneConnection(); 312 314 try { 313 315 ResultSet resultSet = connection.getResultSet(); 314 316 resultSet.first(); 315 317 do { 316 METSFileGroup filegroup = METSFileGroup.readSQL(document, c onnection, resultSet);318 METSFileGroup filegroup = METSFileGroup.readSQL(document, cloned_connection, resultSet); 317 319 if (filegroup != null) { 318 320 set.addGroup(filegroup); 319 321 } 320 322 } while (resultSet.next()); 323 324 cloned_connection.close(); 325 cloned_connection = null; 321 326 } 322 327 catch (SQLException sqlEx) { 323 328 System.out.println(sqlEx); 329 sqlEx.printStackTrace(); 324 330 System.exit(1); 325 331 } -
branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSStructure.java
r8742 r9851 300 300 // parse through the divisions 301 301 ResultSet divisionSet = connection.getResultSet(); 302 // use a new connection for the following bit, cos we still want to use results from the last execute 303 GS3SQLConnection cloned_connection = connection.cloneConnection(); 302 304 if (divisionSet != null && divisionSet.first()) { 303 305 do { 304 METSDivision division = METSDivision.readSQL(c onnection, divisionSet);306 METSDivision division = METSDivision.readSQL(cloned_connection, divisionSet); 305 307 if (division != null) { 306 308 structure.addDivision(division); … … 309 311 while (divisionSet.next()); 310 312 } 311 313 cloned_connection.close(); 314 cloned_connection = null; 312 315 return structure; 313 316 } 314 317 catch (SQLException sqlEx) 315 318 { System.out.println(sqlEx + " " + select.toString()); 319 sqlEx.printStackTrace(); 316 320 System.exit(1); 317 321 } -
branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSStructureSet.java
r8742 r9851 158 158 select.setWhere(new GS3SQLWhere(whereItem)); 159 159 connection.execute(select.toString()); 160 // clone the connection cos we are still usign the old result set 161 GS3SQLConnection cloned_connection = connection.cloneConnection(); 160 162 161 163 // start going through the matching metadata blocks … … 164 166 resultSet.first(); 165 167 do { 166 METSStructure structure = METSStructure.readSQL(document, c onnection, resultSet);168 METSStructure structure = METSStructure.readSQL(document, cloned_connection, resultSet); 167 169 if (structure != null) { 168 170 set.addStructure(structure); 169 171 } 170 172 } while (resultSet.next()); 173 cloned_connection.close(); 174 cloned_connection = null; 171 175 } 172 176 catch (SQLException sqlEx) { 173 177 System.out.println(sqlEx); 178 sqlEx.printStackTrace(); 174 179 System.exit(1); 175 180 }
Note:
See TracChangeset
for help on using the changeset viewer.