Search in sources :

Example 6 with Organisation

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

the class ConvertFromSDKVisitor method visit.

@Override
public void visit(CategoryOptionGroupExtended categoryOptionGroupExtended) {
    Organisation organisationUser = null;
    List<Organisation> organisations = Organisation.getAllOrganisations();
    User me = User.getLoggedUser();
    for (Organisation organisation : organisations) {
        if (organisation.getName().equals(categoryOptionGroupExtended.getName())) {
            organisationUser = organisation;
            organisationUser.setUid(categoryOptionGroupExtended.getUid());
            organisationUser.save();
            me.setOrganisation(organisationUser.getId_organisation());
            me.save();
            break;
        }
    }
    if (me.getOrganisation() == null) {
        organisationUser = Organisation.getDefaultOrganization();
        organisationUser.setUid(PreferencesState.getInstance().getContext().getString(R.string.category_option_group_matrix_uid));
        organisationUser.save();
        me.setOrganisation(organisationUser.getId_organisation());
        me.save();
    }
}
Also used : User(org.eyeseetea.malariacare.data.database.model.User) Organisation(org.eyeseetea.malariacare.data.database.model.Organisation)

Aggregations

Organisation (org.eyeseetea.malariacare.data.database.model.Organisation)6 CSVReader (com.opencsv.CSVReader)4 InputStreamReader (java.io.InputStreamReader)4 StringKey (org.eyeseetea.malariacare.data.database.model.StringKey)2 Treatment (org.eyeseetea.malariacare.data.database.model.Treatment)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Answer (org.eyeseetea.malariacare.data.database.model.Answer)1 Drug (org.eyeseetea.malariacare.data.database.model.Drug)1 Header (org.eyeseetea.malariacare.data.database.model.Header)1 Match (org.eyeseetea.malariacare.data.database.model.Match)1 Option (org.eyeseetea.malariacare.data.database.model.Option)1 OptionAttribute (org.eyeseetea.malariacare.data.database.model.OptionAttribute)1 Program (org.eyeseetea.malariacare.data.database.model.Program)1 Question (org.eyeseetea.malariacare.data.database.model.Question)1 QuestionOption (org.eyeseetea.malariacare.data.database.model.QuestionOption)1 QuestionRelation (org.eyeseetea.malariacare.data.database.model.QuestionRelation)1 QuestionThreshold (org.eyeseetea.malariacare.data.database.model.QuestionThreshold)1 Tab (org.eyeseetea.malariacare.data.database.model.Tab)1 TreatmentMatch (org.eyeseetea.malariacare.data.database.model.TreatmentMatch)1