Search in sources :

Example 1 with Translation

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

the class TreatmentTable method deleteOldTreatmentTable.

private void deleteOldTreatmentTable() throws IOException {
    List<TreatmentMatch> treatmentMatches = TreatmentMatch.getAllTreatmentMatches();
    for (TreatmentMatch treatmentMatch : treatmentMatches) {
        deleteRelatedTablesLines(treatmentMatch);
        treatmentMatch.delete();
    }
    List<Treatment> treatments = Treatment.getAllTreatments();
    for (Treatment treatment : treatments) {
        treatment.delete();
    }
    List<DrugCombination> drugCombinations = DrugCombination.getAllDrugCombination();
    for (DrugCombination drugCombination : drugCombinations) {
        drugCombination.delete();
    }
    List<StringKey> stringKeys = StringKey.getAllStringKeys();
    for (StringKey stringKey : stringKeys) {
        stringKey.delete();
    }
    List<Translation> translations = Translation.getAllTranslations();
    for (Translation translation : translations) {
        translation.delete();
    }
}
Also used : Translation(org.eyeseetea.malariacare.data.database.model.Translation) Treatment(org.eyeseetea.malariacare.data.database.model.Treatment) TreatmentMatch(org.eyeseetea.malariacare.data.database.model.TreatmentMatch) StringKey(org.eyeseetea.malariacare.data.database.model.StringKey) DrugCombination(org.eyeseetea.malariacare.data.database.model.DrugCombination)

Example 2 with Translation

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

the class UpdateDB method updateTranslations.

public static void updateTranslations(Context context, boolean updateCsv) throws IOException {
    if (updateCsv) {
        FileCsvs fileCsvs = new FileCsvs();
        fileCsvs.saveCsvFromAssetsToFile(PopulateDB.TRANSLATION_CSV);
    }
    List<Translation> translations = Translation.getAllTranslations();
    HashMap<Long, StringKey> stringKeyFK = RelationsIdCsvDB.getStringKeyIdRelationCsvDB(context);
    CSVReader reader = new CSVReader(new InputStreamReader(context.openFileInput(PopulateDB.TRANSLATION_CSV)), PopulateDB.SEPARATOR, PopulateDB.QUOTECHAR);
    String[] line;
    int i = 0;
    while ((line = reader.readNext()) != null) {
        if (i < translations.size()) {
            PopulateRow.populateTranslation(line, stringKeyFK, translations.get(i)).save();
        } else {
            PopulateRow.populateTranslation(line, stringKeyFK, null).insert();
        }
        i++;
    }
}
Also used : Translation(org.eyeseetea.malariacare.data.database.model.Translation) InputStreamReader(java.io.InputStreamReader) CSVReader(com.opencsv.CSVReader) StringKey(org.eyeseetea.malariacare.data.database.model.StringKey)

Example 3 with Translation

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

the class PopulateRow method populateTranslation.

public static Translation populateTranslation(String[] line, HashMap<Long, StringKey> stringKeyFK, Translation translation) {
    if (translation == null) {
        translation = new Translation();
    }
    translation.setId_string_key(stringKeyFK.get(Long.valueOf(line[1])).getId_string_key());
    translation.setTranslation(line[2]);
    translation.setLanguage(line[3]);
    return translation;
}
Also used : Translation(org.eyeseetea.malariacare.data.database.model.Translation)

Aggregations

Translation (org.eyeseetea.malariacare.data.database.model.Translation)3 StringKey (org.eyeseetea.malariacare.data.database.model.StringKey)2 CSVReader (com.opencsv.CSVReader)1 InputStreamReader (java.io.InputStreamReader)1 DrugCombination (org.eyeseetea.malariacare.data.database.model.DrugCombination)1 Treatment (org.eyeseetea.malariacare.data.database.model.Treatment)1 TreatmentMatch (org.eyeseetea.malariacare.data.database.model.TreatmentMatch)1