Search in sources :

Example 1 with MonitorBuilder

use of org.eyeseetea.malariacare.presentation.factory.monitor.MonitorBuilder in project pictureapp by EyeSeeTea.

the class MonitorService method prepareMonitorData.

private void prepareMonitorData() {
    Log.i(TAG, "Preparing monitor data...");
    //Take last 6 months sent surveys in order to create monitor stats on top of them.
    List<Survey> sentSurveysForMonitor = Survey.findSentSurveysAfterDate(TimePeriodCalculator.getInstance().getMinDateForMonitor());
    Log.i(TAG, String.format("Found %d surveys to build monitor info, aggregating data...", sentSurveysForMonitor.size()));
    MonitorBuilder monitorBuilder = new MonitorBuilder(getApplicationContext());
    monitorBuilder.addSurveys(sentSurveysForMonitor);
    //Since intents does NOT admit NON serializable as values we use Session instead
    Log.i(TAG, String.format("Monitor data calculated ok", sentSurveysForMonitor.size()));
    Session.putServiceValue(PREPARE_MONITOR_DATA, monitorBuilder);
    LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(PREPARE_MONITOR_DATA));
}
Also used : Survey(org.eyeseetea.malariacare.data.database.model.Survey) Intent(android.content.Intent) MonitorBuilder(org.eyeseetea.malariacare.presentation.factory.monitor.MonitorBuilder)

Aggregations

Intent (android.content.Intent)1 Survey (org.eyeseetea.malariacare.data.database.model.Survey)1 MonitorBuilder (org.eyeseetea.malariacare.presentation.factory.monitor.MonitorBuilder)1