public List<TimeMeasurement> getTimeMeasurements( int procedureId, DateTime fromDate, DateTime toDate, TimeMeasurement.Field orderBy) throws NoSuchElementException { if (toDate == null) { toDate = new DateTime(); } Procedure procedure = logRepository.getProcedure(procedureId); if (procedure == null) { throw new NoSuchElementException(); } return logRepository.getTimeMeasurementsByProcedure(fromDate, toDate, procedure, orderBy); }
public TimeMeasurement getMaxDurationTimeMeasurement( int procedureId, DateTime from, DateTime to) { List<TimeMeasurement> timeMeasurements = logRepository.getTimeMeasurementsByProcedure( from, to, logRepository.getProcedure(procedureId)); Duration maxDuration = new Duration(0); Duration checkDuration; TimeMeasurement maxDurationTimeMeasurement = null; for (TimeMeasurement tm : timeMeasurements) { checkDuration = new Duration(tm.getDuration()); if (checkDuration.isLongerThan(maxDuration)) { maxDuration = checkDuration; maxDurationTimeMeasurement = tm; } } return maxDurationTimeMeasurement; }
public Map<String, Object>[] getPercentile( DateTime fromDate, DateTime toDate, int[] percentages) { List<ProcedureEntity> procedures = logRepository.getAllProcedures(); Map<String, Object>[] percentilesMap = new HashMap[procedures.size()]; int i = 0; for (Procedure procedure : procedures) { percentilesMap[i++] = getPercentileByProcedure(procedure.getId(), fromDate, toDate, percentages); } return percentilesMap; }
public Map<String, Object> getPercentileByProcedure( int procedureId, DateTime fromDate, DateTime toDate, int[] percentages) { Map<String, Object> percentilesMap = Maps.newHashMap(); List<TimeMeasurement> timeMeasurements = logRepository.getTimeMeasurementsByProcedure( fromDate, toDate, logRepository.getProcedure(procedureId), TimeMeasurement.Field.DURATION); Map<Integer, String> percentiles = Maps.newHashMap(); for (int i = 0; i < percentages.length; i++) { String percentile = new Duration((long) analyzer.percentile(timeMeasurements, percentages[i])).toString(); percentiles.put(percentages[i], percentile); } percentilesMap.put("id", procedureId); percentilesMap.put("percentiles", percentiles); return percentilesMap; }
public List<ProcedureEntity> getAllProcedures() { return logRepository.getAllProcedures(); }