/** * Metoda zwraca œrednia liczbê zebranch ankiet na dzieñ przez wybranego ankietera, licz¹ siê * tylko te dni, wktórych pracowa³. * * @param surveys * @param interviewer * @param from * @param to * @return */ public float getMeanFilledSurveysOnADay( List<Survey> surveys, Interviewer interviewer, GregorianCalendar from, GregorianCalendar to) { float mean; float days = numberOfDaysInWork(interviewer, from, to); long numberOfSurveys = 0; for (Survey survey : surveys) { if (survey.getFinishTime().compareTo(from) >= 0 && survey.getFinishTime().compareTo(to) <= 0) { numberOfSurveys += 1; } } mean = numberOfSurveys / days; return mean; }
/** * Metoda zwraca liczbê wype³nionych ankiet. * * @param surveys * @return */ public int getAmountOfFilledSurveys(List<Survey> surveys) { int amount = 0; if (surveys != null) { for (Survey survey : surveys) { if (survey.getFinishTime() != null) { amount += 1; } } return amount; } else { return 0; } }
/** * Metoda zwraca œredni¹ liczbê zebranych ankiet przez ankietera na dzieñ w ci¹gu okresu, wktórym * pracowa³ * * @param surveys * @param interviewer * @return */ public float getMeanFilledSurveysOnADay(List<Survey> surveys, Interviewer interviewer) { float mean; float days = numberOfDaysInWork(interviewer); long numberOfSurveys = 0; if (surveys != null) { for (Survey survey : surveys) { if (survey.getFinishTime() != null) { numberOfSurveys += 1; } } mean = numberOfSurveys / days; return mean; } else { return 0; } }
/** * Metoda zwraca mapê, która zawiera jako klucze poszczególne dni w których ankieter zebra³ jakieœ * ankiety, zaœ wartoœciami s¹ liczby zebranych ankiet w tym dniu. * * @param surveys * @param interviewer * @return */ public HashMap<GregorianCalendar, Integer> getAmountOfFilledSurveysInDays( List<Survey> surveys, Interviewer interviewer) { HashMap<GregorianCalendar, Integer> filledSurveysInDays = new HashMap<GregorianCalendar, Integer>(); for (Survey survey : surveys) { GregorianCalendar data = survey.getFinishTime(); int year = data.get(Calendar.YEAR); int month = data.get(Calendar.MONTH); int day = data.get(Calendar.DAY_OF_MONTH); GregorianCalendar date = new GregorianCalendar(year, month, day); if (!filledSurveysInDays.containsKey(date)) { filledSurveysInDays.put(date, 1); } else { filledSurveysInDays.put(date, filledSurveysInDays.get(date) + 1); } } return filledSurveysInDays; }