Search in sources :

Example 6 with OrgUnit

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

the class ConvertFromSDKVisitor method visit.

/**
     * Turns an event into a sent survey
     */
@Override
public void visit(EventExtended sdkEventExtended) {
    OrgUnit orgUnit = (OrgUnit) appMapObjects.get(sdkEventExtended.getOrganisationUnitId());
    Program program = Program.getProgram(sdkEventExtended.getProgramUId());
    Survey survey = new Survey();
    //Any survey that comes from the pull has been sent
    survey.setStatus(Constants.SURVEY_SENT);
    //Set dates
    survey.setCreationDate(sdkEventExtended.getCreationDate());
    survey.setCompletionDate(sdkEventExtended.getEventDate());
    survey.setEventDate(sdkEventExtended.getEventDate());
    survey.setScheduledDate(sdkEventExtended.getScheduledDate());
    //Set fks
    survey.setOrgUnit(orgUnit);
    survey.setProgram(program);
    survey.setEventUid(sdkEventExtended.getUid());
    mConvertFromSDKVisitorStrategy.visit(sdkEventExtended, survey);
    surveys.add(survey);
    //Annotate object in map
    appMapObjects.put(sdkEventExtended.getUid(), survey);
}
Also used : OrgUnit(org.eyeseetea.malariacare.data.database.model.OrgUnit) Survey(org.eyeseetea.malariacare.data.database.model.Survey) Program(org.eyeseetea.malariacare.data.database.model.Program)

Example 7 with OrgUnit

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

the class DataConverter method convert.

public void convert(IPullController.Callback callback, ConvertFromSDKVisitor converter) {
    String orgUnitName = PreferencesState.getInstance().getOrgUnit();
    List<OrgUnit> orgUnits = converter.getOrgUnits();
    for (OrgUnit orgUnit : orgUnits) {
        //Only events for the right ORGUNIT are loaded
        if (!orgUnitName.isEmpty() && orgUnit.getName() != null && !orgUnit.getName().equals(orgUnitName)) {
            continue;
        }
        List<Program> programs = Program.getAllPrograms();
        for (Program program : programs) {
            List<EventExtended> events = EventExtended.getExtendedList(SdkQueries.getEvents(orgUnit.getUid(), program.getUid()));
            callback.onStep(BUILDING_SURVEYS);
            for (EventExtended event : events) {
                event.accept(converter);
            }
            callback.onStep(BUILDING_VALUES);
            for (EventExtended event : events) {
                List<DataValueExtended> dataValues = DataValueExtended.getExtendedList(SdkQueries.getDataValues(event.getUid()));
                for (DataValueExtended dataValueExtended : dataValues) {
                    dataValueExtended.accept(converter);
                }
                try {
                    dataConverterStrategy.convert(converter, event);
                } catch (QuestionNotFoundException e) {
                    callback.onError(e);
                }
            }
        }
    }
    saveConvertedSurveys(callback, converter);
}
Also used : OrgUnit(org.eyeseetea.malariacare.data.database.model.OrgUnit) Program(org.eyeseetea.malariacare.data.database.model.Program) EventExtended(org.eyeseetea.malariacare.data.sync.importer.models.EventExtended) QuestionNotFoundException(org.eyeseetea.malariacare.domain.exception.QuestionNotFoundException) DataValueExtended(org.eyeseetea.malariacare.data.sync.importer.models.DataValueExtended)

Example 8 with OrgUnit

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

the class OrgUnitToOptionConverter method convert.

public static void convert() {
    List<Question> questions = Question.getAllQuestionsWithOrgUnitDropdownList();
    if (questions.size() == 0) {
        return;
    }
    List<OrgUnit> orgUnits = OrgUnit.getAllOrgUnit();
    for (OrgUnit orgUnit : orgUnits) {
        addOUOptionToQuestions(questions, orgUnit);
    }
}
Also used : OrgUnit(org.eyeseetea.malariacare.data.database.model.OrgUnit) Question(org.eyeseetea.malariacare.data.database.model.Question)

Aggregations

OrgUnit (org.eyeseetea.malariacare.data.database.model.OrgUnit)8 Program (org.eyeseetea.malariacare.data.database.model.Program)3 CSVReader (com.opencsv.CSVReader)2 InputStreamReader (java.io.InputStreamReader)2 Question (org.eyeseetea.malariacare.data.database.model.Question)2 Survey (org.eyeseetea.malariacare.data.database.model.Survey)2 EventExtended (org.eyeseetea.malariacare.data.sync.importer.models.EventExtended)2 Date (java.util.Date)1 Answer (org.eyeseetea.malariacare.data.database.model.Answer)1 Option (org.eyeseetea.malariacare.data.database.model.Option)1 OptionAttribute (org.eyeseetea.malariacare.data.database.model.OptionAttribute)1 OrgUnitLevel (org.eyeseetea.malariacare.data.database.model.OrgUnitLevel)1 QuestionOption (org.eyeseetea.malariacare.data.database.model.QuestionOption)1 DataValueExtended (org.eyeseetea.malariacare.data.sync.importer.models.DataValueExtended)1 QuestionNotFoundException (org.eyeseetea.malariacare.domain.exception.QuestionNotFoundException)1 DynamicStockImageRadioButtonSingleQuestionView (org.eyeseetea.malariacare.views.question.singlequestion.DynamicStockImageRadioButtonSingleQuestionView)1 ImageRadioButtonSingleQuestionView (org.eyeseetea.malariacare.views.question.singlequestion.ImageRadioButtonSingleQuestionView)1