Revision 9489
Added by Jing Tao almost 9 years ago
src/edu/ucsb/nceas/metacat/EventLog.java | ||
---|---|---|
83 | 83 |
private Logger logMetacat = Logger.getLogger(EventLog.class); |
84 | 84 |
private static final int USERAGENTLENGTH = 512; |
85 | 85 |
|
86 |
|
|
86 | 87 |
/** |
87 | 88 |
* A private constructor that initializes the class when getInstance() is |
88 | 89 |
* called. |
... | ... | |
404 | 405 |
public Log getD1Report(String[] ipAddress, String[] principal, String[] docid, |
405 | 406 |
String event, Timestamp startDate, Timestamp endDate, boolean anonymous, Integer start, Integer count) |
406 | 407 |
{ |
407 |
|
|
408 |
boolean isCreateEvent = false; |
|
408 | 409 |
Log log = new Log(); |
409 | 410 |
|
410 | 411 |
NodeReference memberNode = new NodeReference(); |
... | ... | |
475 | 476 |
subQueryFrom.append(") "); |
476 | 477 |
clauseAdded = true; |
477 | 478 |
} |
479 |
|
|
480 |
//please make sure the handling of event is just before the the startDate clause!!! |
|
478 | 481 |
if (event != null) { |
479 |
if (clauseAdded) {
|
|
480 |
subQueryFrom.append(" and ");
|
|
482 |
if (clauseAdded) {
|
|
483 |
subQueryFrom.append(" and ");
|
|
481 | 484 |
} else { |
482 |
subQueryFrom.append(" where ");
|
|
485 |
subQueryFrom.append(" where ");
|
|
483 | 486 |
} |
484 |
subQueryFrom.append("event in ("); |
|
485 |
subQueryFrom.append("?"); |
|
486 |
String eventString = event; |
|
487 |
if (eventString.equals(Event.CREATE.xmlValue())) { |
|
488 |
eventString = "(insert,INSERT,upload,UPLOAD,create)"; |
|
489 |
} |
|
490 |
paramValues.add(eventString); |
|
491 |
subQueryFrom.append(") "); |
|
487 |
subQueryFrom.append("event in ("); |
|
488 |
subQueryFrom.append("?"); |
|
489 |
String eventString = event; |
|
490 |
if (eventString.equals(Event.CREATE.xmlValue())) { |
|
491 |
isCreateEvent = true; //since the create event maps create, insert and et al, we handle it in different way |
|
492 |
subQueryFrom.append(",?");// for INSERT, the insert is handled by line 508 |
|
493 |
subQueryFrom.append(",?");// for upload |
|
494 |
subQueryFrom.append(",?");// for UPLOAD |
|
495 |
subQueryFrom.append(",?");// for create |
|
496 |
//eventString = "insert,INSERT,upload,UPLOAD,create"; |
|
497 |
} else { |
|
498 |
paramValues.add(eventString); |
|
499 |
} |
|
500 |
subQueryFrom.append(") "); |
|
492 | 501 |
clauseAdded = true; |
493 | 502 |
} |
494 |
|
|
503 |
|
|
495 | 504 |
if (startDate != null) { |
496 | 505 |
if (clauseAdded) { |
497 | 506 |
subQueryFrom.append(" and "); |
... | ... | |
510 | 519 |
subQueryFrom.append("date_logged < ?"); |
511 | 520 |
clauseAdded = true; |
512 | 521 |
} |
522 |
|
|
523 |
|
|
513 | 524 |
|
514 | 525 |
// count query |
515 | 526 |
String countSelect = "select count(*) "; |
... | ... | |
568 | 579 |
fieldsStmt.setString(parameterIndex, val); |
569 | 580 |
parameterIndex++; |
570 | 581 |
} |
582 |
|
|
583 |
if(isCreateEvent) { |
|
584 |
//handle the event mapping. If we add another event mapping, we need add a "?" in line 496 |
|
585 |
//those values are not in the paramValues. |
|
586 |
countStmt.setString(parameterIndex, "insert"); |
|
587 |
fieldsStmt.setString(parameterIndex, "insert"); |
|
588 |
parameterIndex++; |
|
589 |
countStmt.setString(parameterIndex, "INSERT"); |
|
590 |
fieldsStmt.setString(parameterIndex, "INSERT"); |
|
591 |
parameterIndex++; |
|
592 |
countStmt.setString(parameterIndex, "upload"); |
|
593 |
fieldsStmt.setString(parameterIndex, "upload"); |
|
594 |
parameterIndex++; |
|
595 |
countStmt.setString(parameterIndex, "UPLOAD"); |
|
596 |
fieldsStmt.setString(parameterIndex, "UPLOAD"); |
|
597 |
parameterIndex++; |
|
598 |
countStmt.setString(parameterIndex, "create"); |
|
599 |
fieldsStmt.setString(parameterIndex, "create"); |
|
600 |
parameterIndex++; |
|
601 |
} |
|
602 |
|
|
571 | 603 |
if (startDate != null) { |
572 | 604 |
countStmt.setTimestamp(parameterIndex, startDate); |
573 | 605 |
fieldsStmt.setTimestamp(parameterIndex, startDate); |
... | ... | |
578 | 610 |
fieldsStmt.setTimestamp(parameterIndex, endDate); |
579 | 611 |
parameterIndex++; |
580 | 612 |
} |
613 |
|
|
581 | 614 |
|
582 | 615 |
// for the return Log list |
583 | 616 |
List<LogEntry> logs = new Vector<LogEntry>(); |
Also available in: Unified diff
Add the dataone create event mapping to the select clause.