Revision 1755
Added by Jing Tao over 21 years ago
src/edu/ucsb/nceas/metacat/DocumentImpl.java | ||
---|---|---|
271 | 271 |
PreparedStatement pstmt = null; |
272 | 272 |
//MetaCatUtil util = new MetaCatUtil(); |
273 | 273 |
AccessionNumber ac; |
274 |
String action = null; |
|
274 | 275 |
try { |
275 | 276 |
//dbconn = util.openDBConnection(); |
276 | 277 |
//check out DBConnection |
... | ... | |
286 | 287 |
if (revInDataBase==-1 && userSpecifyRev>0 ) |
287 | 288 |
{ |
288 | 289 |
ac = new AccessionNumber(accnum, "insert"); |
290 |
action = "insert"; |
|
289 | 291 |
} |
290 | 292 |
//rev is greater the last revsion number and revInDataBase isn't -1 |
291 | 293 |
// it is a updated data file |
... | ... | |
295 | 297 |
//archive the old entry |
296 | 298 |
archiveDocRevision(docIdWithoutRev, user); |
297 | 299 |
//delete the old entry in xml_documents |
298 |
deleteXMLDocuments(docIdWithoutRev); |
|
300 |
//deleteXMLDocuments(docIdWithoutRev);
|
|
299 | 301 |
ac = new AccessionNumber(accnum, "update"); |
302 |
action = "update"; |
|
300 | 303 |
} |
301 | 304 |
//other situation |
302 | 305 |
else |
... | ... | |
307 | 310 |
} |
308 | 311 |
String docid = ac.getDocid(); |
309 | 312 |
String rev = ac.getRev(); |
310 |
SimpleDateFormat formatter = new SimpleDateFormat ("yy-MM-dd HH:mm:ss");
|
|
313 |
/*SimpleDateFormat formatter = new SimpleDateFormat ("MM/dd/yy HH:mm:ss");
|
|
311 | 314 |
Date localtime = new Date(); |
312 | 315 |
String dateString = formatter.format(localtime); |
316 |
String sqlDateString=dbAdapter.toDate(dateString, "MM/DD/YY HH24:MI:SS");*/ |
|
317 |
String sqlDateString = dbAdapter.getDateTimeFunction(); |
|
313 | 318 |
|
314 |
/*String sqlDateString = "to_date('" + dateString + |
|
315 |
"', 'YY-MM-DD HH24:MI:SS')";*/ |
|
316 |
String sqlDateString=dbAdapter.toDate(dateString, "YY-MM-DD HH24:MI:SS"); |
|
317 |
|
|
318 | 319 |
StringBuffer sql = new StringBuffer(); |
319 |
sql.append("insert into xml_documents (docid, docname, doctype, "); |
|
320 |
sql.append("user_owner, user_updated, server_location, rev,date_created"); |
|
321 |
sql.append(", date_updated, public_access) values ('"); |
|
322 |
sql.append(docid).append("','"); |
|
323 |
sql.append(docname).append("','"); |
|
324 |
sql.append(doctype).append("','"); |
|
325 |
sql.append(user).append("','"); |
|
326 |
sql.append(user).append("','"); |
|
327 |
sql.append(serverCode).append("','"); |
|
328 |
sql.append(rev).append("',"); |
|
329 |
sql.append(sqlDateString).append(","); |
|
330 |
sql.append(sqlDateString).append(","); |
|
331 |
sql.append("'0')"); |
|
320 |
if (action != null && action.equals("insert")) |
|
321 |
{ |
|
322 |
sql.append("insert into xml_documents (docid, docname, doctype, "); |
|
323 |
sql.append("user_owner, user_updated, server_location, rev,date_created"); |
|
324 |
sql.append(", date_updated, public_access) values ('"); |
|
325 |
sql.append(docid).append("','"); |
|
326 |
sql.append(docname).append("','"); |
|
327 |
sql.append(doctype).append("','"); |
|
328 |
sql.append(user).append("','"); |
|
329 |
sql.append(user).append("','"); |
|
330 |
sql.append(serverCode).append("','"); |
|
331 |
sql.append(rev).append("',"); |
|
332 |
sql.append(sqlDateString).append(","); |
|
333 |
sql.append(sqlDateString).append(","); |
|
334 |
sql.append("'0')"); |
|
335 |
} |
|
336 |
else if (action != null && action.equals("update")) |
|
337 |
{ |
|
338 |
sql.append("update xml_documents set docname ='"); |
|
339 |
sql.append(docname).append("', "); |
|
340 |
sql.append("user_updated='"); |
|
341 |
sql.append(user).append("', "); |
|
342 |
sql.append("server_location='"); |
|
343 |
sql.append(serverCode).append("',"); |
|
344 |
sql.append("rev='"); |
|
345 |
sql.append(rev).append("',"); |
|
346 |
sql.append("date_updated="); |
|
347 |
sql.append(sqlDateString); |
|
348 |
sql.append(" where docid='"); |
|
349 |
sql.append(docid).append("'"); |
|
350 |
} |
|
332 | 351 |
pstmt = dbconn.prepareStatement(sql.toString()); |
333 |
MetaCatUtil.debugMessage("2, new sql for todate:================== "+ |
|
334 |
sql.toString(), 1); |
|
335 | 352 |
pstmt.execute(); |
336 | 353 |
pstmt.close(); |
337 | 354 |
//dbconn.close(); |
... | ... | |
384 | 401 |
//MetaCatUtil util = new MetaCatUtil(); |
385 | 402 |
AccessionNumber ac; |
386 | 403 |
PreparedStatement pstmt = null; |
404 |
String action = null; |
|
387 | 405 |
try { |
388 | 406 |
//dbconn = util.openDBConnection(); |
389 | 407 |
dbconn=DBConnectionPool. |
... | ... | |
399 | 417 |
{ |
400 | 418 |
|
401 | 419 |
ac = new AccessionNumber(accnum, "insert"); |
420 |
action = "insert"; |
|
402 | 421 |
} |
403 | 422 |
//rev is greater the last revsion number and revInDataBase isn't -1 |
404 | 423 |
// it is a updated data file |
... | ... | |
408 | 427 |
//archive the old entry |
409 | 428 |
archiveDocRevision(docIdWithoutRev, user); |
410 | 429 |
//delete the old entry in xml_documents |
411 |
deleteXMLDocuments(docIdWithoutRev); |
|
430 |
//deleteXMLDocuments(docIdWithoutRev);
|
|
412 | 431 |
ac = new AccessionNumber(accnum, "update"); |
432 |
action = "update"; |
|
413 | 433 |
} |
414 | 434 |
// local server has newer version, then notify the remote server |
415 | 435 |
else if ( userSpecifyRev < revInDataBase && revInDataBase > 0) |
... | ... | |
427 | 447 |
} |
428 | 448 |
String docid = ac.getDocid(); |
429 | 449 |
String rev = ac.getRev(); |
430 |
SimpleDateFormat formatter = new SimpleDateFormat ("yy-MM-dd HH:mm:ss");
|
|
450 |
/*SimpleDateFormat formatter = new SimpleDateFormat ("MM/dd/yy HH:mm:ss");
|
|
431 | 451 |
Date localtime = new Date(); |
432 | 452 |
String dateString = formatter.format(localtime); |
433 |
|
|
434 |
/*String sqlDateString = "to_date('" + dateString + |
|
435 |
"', 'YY-MM-DD HH24:MI:SS')";*/ |
|
436 |
String sqlDateString=dbAdapter.toDate(dateString, "YY-MM-DD HH24:MI:SS"); |
|
453 |
String sqlDateString=dbAdapter.toDate(dateString, "MM/DD/YY HH24:MI:SS");*/ |
|
454 |
String sqlDateString = dbAdapter.getDateTimeFunction(); |
|
455 |
|
|
437 | 456 |
StringBuffer sql = new StringBuffer(); |
438 |
sql.append("insert into xml_documents (docid, docname, doctype, "); |
|
439 |
sql.append("user_owner, user_updated, server_location, rev,date_created"); |
|
440 |
sql.append(", date_updated, public_access) values ('"); |
|
441 |
sql.append(docid).append("','"); |
|
442 |
sql.append(docname).append("','"); |
|
443 |
sql.append(doctype).append("','"); |
|
444 |
sql.append(user).append("','"); |
|
445 |
sql.append(user).append("','"); |
|
446 |
sql.append(serverCode).append("','"); |
|
447 |
sql.append(rev).append("',"); |
|
448 |
sql.append(sqlDateString).append(","); |
|
449 |
sql.append(sqlDateString).append(","); |
|
450 |
sql.append("'0')"); |
|
457 |
if (action != null && action.equals("insert")) |
|
458 |
{ |
|
459 |
sql.append("insert into xml_documents (docid, docname, doctype, "); |
|
460 |
sql.append("user_owner, user_updated, server_location, rev,date_created"); |
|
461 |
sql.append(", date_updated, public_access) values ('"); |
|
462 |
sql.append(docid).append("','"); |
|
463 |
sql.append(docname).append("','"); |
|
464 |
sql.append(doctype).append("','"); |
|
465 |
sql.append(user).append("','"); |
|
466 |
sql.append(user).append("','"); |
|
467 |
sql.append(serverCode).append("','"); |
|
468 |
sql.append(rev).append("',"); |
|
469 |
sql.append(sqlDateString).append(","); |
|
470 |
sql.append(sqlDateString).append(","); |
|
471 |
sql.append("'0')"); |
|
472 |
} |
|
473 |
else if (action != null && action.equals("update")) |
|
474 |
{ |
|
475 |
sql.append("update xml_documents set docname ='"); |
|
476 |
sql.append(docname).append("', "); |
|
477 |
sql.append("user_updated='"); |
|
478 |
sql.append(user).append("', "); |
|
479 |
sql.append("server_location='"); |
|
480 |
sql.append(serverCode).append("',"); |
|
481 |
sql.append("rev='"); |
|
482 |
sql.append(rev).append("',"); |
|
483 |
sql.append("date_updated="); |
|
484 |
sql.append(sqlDateString); |
|
485 |
sql.append(" where docid='"); |
|
486 |
sql.append(docid).append("'"); |
|
487 |
} |
|
451 | 488 |
// Set auto commit fasle |
452 | 489 |
dbconn.setAutoCommit(false); |
453 | 490 |
pstmt = dbconn.prepareStatement(sql.toString()); |
Also available in: Unified diff
Fixed a bug in registryDataFile.