Project

General

Profile

« Previous | Next » 

Revision 6331

provisional version of getOperationStatistics() -- not clear if we are meant to aggregate by hour or by day

View differences:

test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java
662 662
						startTime, 
663 663
						endTime, 
664 664
						session.getSubject(), 
665
						Event.READ, 
665
						Event.CREATE, 
666 666
						null //formatId
667 667
						);
668 668
			
src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
55 55
import org.dataone.service.types.Event;
56 56
import org.dataone.service.types.Group;
57 57
import org.dataone.service.types.Identifier;
58
import org.dataone.service.types.Log;
59
import org.dataone.service.types.LogEntry;
60
import org.dataone.service.types.MonitorInfo;
58 61
import org.dataone.service.types.MonitorList;
59 62
import org.dataone.service.types.Node;
60 63
import org.dataone.service.types.NodeHealth;
......
682 685
    throws NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest, 
683 686
    InsufficientResources, UnsupportedType {
684 687
    
685
		throw new NotImplemented("2080", "getOperationsStatistics not yet implemented");
688
	  MonitorList monitorList = new MonitorList();
689
	  
690
	  try {
691

  
692
		  // get log records first
693
		  Log logs = getLogRecords(session, startTime, endTime, event, 0, null);
694
		  
695
		  // TODO: aggregate by day or hour -- needs clarification
696
		  int count = 1;
697
		  for (LogEntry logEntry: logs.getLogEntryList()) {
698
			  Identifier pid = logEntry.getIdentifier();
699
			  Date logDate = logEntry.getDateLogged();
700
			  // if we are filtering by format
701
			  if (formatId != null) {
702
				  SystemMetadata sysmeta = IdentifierManager.getInstance().getSystemMetadata(pid.getValue());
703
				  if (!sysmeta.getObjectFormat().getFmtid().getValue().equals(formatId.getValue())) {
704
					  // does not match
705
					  continue;
706
				  }
707
			  }
708
			  MonitorInfo item = new MonitorInfo();
709
			  item.setCount(count);
710
			  item.setDate(new java.sql.Date(logDate.getTime()));
711
			  monitorList.addMonitorInfo(item);
712
			  
713
		  }
714
	} catch (Exception e) {
715
		e.printStackTrace();
716
		throw new ServiceFailure("2081", "Could not retrieve statistics: " + e.getMessage());
717
	}
718
	  
719
	return monitorList;
720
	  
686 721
  }
687 722

  
688 723
  /**

Also available in: Unified diff