Search in sources :

Example 26 with Survey

use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.

the class DashboardUnsentFragment method reloadSurveys.

public void reloadSurveys(List<Survey> newListSurveys) {
    Log.d(TAG, "reloadSurveys (Thread: " + Thread.currentThread().getId() + "): " + newListSurveys.size());
    this.surveys.clear();
    for (Survey survey : newListSurveys) {
        if (!survey.isStockSurvey()) {
            this.surveys.add(survey);
        }
    }
    this.adapter.notifyDataSetChanged();
    if (viewCreated) {
        LayoutUtils.measureListViewHeightBasedOnChildren(getListView());
        setListShown(true);
    }
}
Also used : Survey(org.eyeseetea.malariacare.data.database.model.Survey)

Example 27 with Survey

use of org.eyeseetea.malariacare.data.database.model.Survey 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)

Example 28 with Survey

use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.

the class SurveyService method getAllUncompletedSurveys.

private void getAllUncompletedSurveys() {
    Log.d(TAG, "getAllUncompletedSurveys (Thread:" + Thread.currentThread().getId() + ")");
    //Select surveys from sql
    List<Survey> surveys = Survey.getAllUncompletedSurveys();
    //Load %completion in every survey (it takes a while so it can NOT be done in UI Thread)
    for (Survey survey : surveys) {
        survey.getAnsweredQuestionRatio();
    }
    //Since intents does NOT admit NON serializable as values we use Session instead
    Session.putServiceValue(ALL_UNCOMPLETED_SURVEYS_ACTION, surveys);
    //Returning result to anyone listening
    Intent resultIntent = new Intent(ALL_UNCOMPLETED_SURVEYS_ACTION);
    LocalBroadcastManager.getInstance(this).sendBroadcast(resultIntent);
}
Also used : Survey(org.eyeseetea.malariacare.data.database.model.Survey) Intent(android.content.Intent)

Example 29 with Survey

use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.

the class SurveyService method getAllCompletedSurveys.

private void getAllCompletedSurveys() {
    Log.d(TAG, "getAllCompletedSurveys (Thread:" + Thread.currentThread().getId() + ")");
    //Select surveys from sql
    List<Survey> surveys = Survey.getAllCompletedSurveys();
    //Load %completion in every survey (it takes a while so it can NOT be done in UI Thread)
    for (Survey survey : surveys) {
        survey.getAnsweredQuestionRatio();
    }
    //Since intents does NOT admit NON serializable as values we use Session instead
    Session.putServiceValue(ALL_SENT_SURVEYS_ACTION, surveys);
    //Returning result to anyone listening
    Intent resultIntent = new Intent(ALL_SENT_SURVEYS_ACTION);
    LocalBroadcastManager.getInstance(this).sendBroadcast(resultIntent);
}
Also used : Survey(org.eyeseetea.malariacare.data.database.model.Survey) Intent(android.content.Intent)

Example 30 with Survey

use of org.eyeseetea.malariacare.data.database.model.Survey in project pictureapp by EyeSeeTea.

the class SurveyService method getAllSentSurveys.

/**
     * Selects all sent surveys from database
     */
private void getAllSentSurveys() {
    Log.d(TAG, "getAllSentMalariaSurveys (Thread:" + Thread.currentThread().getId() + ")");
    //Select surveys from sql
    List<Survey> surveys = Survey.getAllSentMalariaSurveys();
    //Since intents does NOT admit NON serializable as values we use Session instead
    Session.putServiceValue(ALL_SENT_SURVEYS_ACTION, surveys);
    //Returning result to anyone listening
    Intent resultIntent = new Intent(ALL_SENT_SURVEYS_ACTION);
    LocalBroadcastManager.getInstance(this).sendBroadcast(resultIntent);
}
Also used : Survey(org.eyeseetea.malariacare.data.database.model.Survey) Intent(android.content.Intent)

Aggregations

Survey (org.eyeseetea.malariacare.data.database.model.Survey)39 Date (java.util.Date)8 Intent (android.content.Intent)7 Value (org.eyeseetea.malariacare.data.database.model.Value)6 ArrayList (java.util.ArrayList)4 Program (org.eyeseetea.malariacare.data.database.model.Program)3 Question (org.eyeseetea.malariacare.data.database.model.Question)3 Session.getMalariaSurvey (org.eyeseetea.malariacare.data.database.utils.Session.getMalariaSurvey)3 Option (org.eyeseetea.malariacare.data.database.model.Option)2 OrgUnit (org.eyeseetea.malariacare.data.database.model.OrgUnit)2 EventExtended (org.eyeseetea.malariacare.data.sync.importer.models.EventExtended)2 ImportSummaryErrorException (org.eyeseetea.malariacare.domain.exception.ImportSummaryErrorException)2 DialogInterface (android.content.DialogInterface)1 NonNull (android.support.annotation.NonNull)1 View (android.view.View)1 ListView (android.widget.ListView)1 TableRow (android.widget.TableRow)1 Calendar (java.util.Calendar)1 HashSet (java.util.HashSet)1 CompositeScore (org.eyeseetea.malariacare.data.database.model.CompositeScore)1