use of com.opencsv.CSVReader in project pictureapp by EyeSeeTea.
the class RelationsIdCsvDB method getIdRelationCsvDB.
static HashMap<Long, Object> getIdRelationCsvDB(Context context, String CsvName, List<Object> allDBObjects) throws IOException {
HashMap<Long, Object> objectFK = new HashMap<>();
List<Long> csvIds = new ArrayList<>();
CSVReader reader = new CSVReader(new InputStreamReader(context.openFileInput(CsvName)), PopulateDB.SEPARATOR, PopulateDB.QUOTECHAR);
String[] idToAdd;
while ((idToAdd = reader.readNext()) != null) {
csvIds.add(Long.parseLong(idToAdd[0]));
}
for (int i = 0; i < allDBObjects.size() && i < csvIds.size(); i++) {
objectFK.put(csvIds.get(i), allDBObjects.get(i));
}
return objectFK;
}
use of com.opencsv.CSVReader in project pictureapp by EyeSeeTea.
the class RelationsIdCsvDB method getDrugIdRelationCsvDB.
static HashMap<Long, Drug> getDrugIdRelationCsvDB(Context context) throws IOException {
HashMap<Long, Drug> drugFK = new HashMap<>();
List<Drug> drugs = Drug.getAllDrugs();
List<Long> csvIds = new ArrayList<>();
CSVReader reader = new CSVReader(new InputStreamReader(context.openFileInput(PopulateDB.DRUGS_CSV)), PopulateDB.SEPARATOR, PopulateDB.QUOTECHAR);
String[] idToAdd;
while ((idToAdd = reader.readNext()) != null) {
csvIds.add(Long.parseLong(idToAdd[0]));
}
for (int i = 0; i < drugs.size() && i < csvIds.size(); i++) {
drugFK.put(csvIds.get(i), drugs.get(i));
}
return drugFK;
}
use of com.opencsv.CSVReader in project pictureapp by EyeSeeTea.
the class RelationsIdCsvDB method getProgramIdRelationCsvDB.
static HashMap<Long, Program> getProgramIdRelationCsvDB(Context context) throws IOException {
HashMap<Long, Program> programFK = new HashMap<>();
List<Program> programs = Program.getAllPrograms();
List<Long> csvIds = new ArrayList<>();
CSVReader reader = new CSVReader(new InputStreamReader(context.openFileInput(PopulateDB.PROGRAMS_CSV)), PopulateDB.SEPARATOR, PopulateDB.QUOTECHAR);
String[] idToAdd;
while ((idToAdd = reader.readNext()) != null) {
csvIds.add(Long.parseLong(idToAdd[0]));
}
for (int i = 0; i < programs.size() && i < csvIds.size(); i++) {
programFK.put(csvIds.get(i), programs.get(i));
}
return programFK;
}
use of com.opencsv.CSVReader in project pictureapp by EyeSeeTea.
the class RelationsIdCsvDB method getTreatmentIdRelationCsvDB.
static HashMap<Long, Treatment> getTreatmentIdRelationCsvDB(Context context) throws IOException {
HashMap<Long, Treatment> treatmentFK = new HashMap<>();
List<Treatment> treatments = Treatment.getAllTreatments();
List<Long> csvIds = new ArrayList<>();
CSVReader reader = new CSVReader(new InputStreamReader(context.openFileInput(PopulateDB.TREATMENT_CSV)), PopulateDB.SEPARATOR, PopulateDB.QUOTECHAR);
String[] idToAdd;
while ((idToAdd = reader.readNext()) != null) {
csvIds.add(Long.parseLong(idToAdd[0]));
}
for (int i = 0; i < treatments.size() && i < csvIds.size(); i++) {
treatmentFK.put(csvIds.get(i), treatments.get(i));
}
return treatmentFK;
}
use of com.opencsv.CSVReader in project pictureapp by EyeSeeTea.
the class RelationsIdCsvDB method getQuestionIdRelationCsvDB.
static HashMap<Long, Question> getQuestionIdRelationCsvDB(Context context) throws IOException {
HashMap<Long, Question> questionFK = new HashMap<>();
List<Question> questions = Question.getAllQuestions();
List<Long> csvIds = new ArrayList<>();
CSVReader reader = new CSVReader(new InputStreamReader(context.openFileInput(PopulateDB.QUESTIONS_CSV)), PopulateDB.SEPARATOR, PopulateDB.QUOTECHAR);
String[] idToAdd;
while ((idToAdd = reader.readNext()) != null) {
csvIds.add(Long.parseLong(idToAdd[0]));
}
for (int i = 0; i < questions.size() && i < csvIds.size(); i++) {
questionFK.put(csvIds.get(i), questions.get(i));
}
return questionFK;
}
Aggregations