Search in sources :

Example 6 with StringKey

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

the class UpdateDB method updateStringKeys.

public static void updateStringKeys(Context context, boolean updateCSV) throws IOException {
    if (updateCSV) {
        FileCsvs fileCsvs = new FileCsvs();
        fileCsvs.saveCsvFromAssetsToFile(PopulateDB.STRING_KEY_CSV);
    }
    List<StringKey> stringKeys = StringKey.getAllStringKeys();
    CSVReader reader = new CSVReader(new InputStreamReader(context.openFileInput(PopulateDB.STRING_KEY_CSV)), PopulateDB.SEPARATOR, PopulateDB.QUOTECHAR);
    String[] line;
    int i = 0;
    while ((line = reader.readNext()) != null) {
        if (i < stringKeys.size()) {
            PopulateRow.populateStringKey(line, stringKeys.get(i)).save();
        } else {
            PopulateRow.populateStringKey(line, null).insert();
        }
        i++;
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) CSVReader(com.opencsv.CSVReader) StringKey(org.eyeseetea.malariacare.data.database.model.StringKey)

Aggregations

StringKey (org.eyeseetea.malariacare.data.database.model.StringKey)6 CSVReader (com.opencsv.CSVReader)5 InputStreamReader (java.io.InputStreamReader)5 Treatment (org.eyeseetea.malariacare.data.database.model.Treatment)3 Organisation (org.eyeseetea.malariacare.data.database.model.Organisation)2 Translation (org.eyeseetea.malariacare.data.database.model.Translation)2 TreatmentMatch (org.eyeseetea.malariacare.data.database.model.TreatmentMatch)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 DrugCombination (org.eyeseetea.malariacare.data.database.model.DrugCombination)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