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();
}
}
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++;
}
}
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;
}
Aggregations