use of org.eyeseetea.malariacare.data.database.model.OrgUnitLevel in project pictureapp by EyeSeeTea.
the class PopulateDB method populateDummyData.
public static void populateDummyData(Context context) throws IOException {
//Reset inner references
cleanDummyLists();
for (String table : tables2populateDummy) {
Log.i(TAG, "Loading csv: " + table);
CSVReader reader = new CSVReader(new InputStreamReader(context.openFileInput(table)), SEPARATOR, QUOTECHAR);
String[] line;
while ((line = reader.readNext()) != null) {
switch(table) {
case ORG_UNIT_LEVEL_CSV:
OrgUnitLevel orgUnitLevel = new OrgUnitLevel();
orgUnitLevel.setName(line[1]);
orgUnitLevel.save();
orgUnitLevelList.put(Integer.valueOf(line[0]), orgUnitLevel);
break;
case ORG_UNIT_CSV:
OrgUnit orgUnit = new OrgUnit();
orgUnit.setUid(line[1]);
orgUnit.setName(line[2]);
orgUnit.setOrgUnit(Long.valueOf(line[3]));
orgUnit.setOrgUnitLevel(orgUnitLevelList.get(Integer.valueOf(line[4])));
orgUnit.save();
orgUnitList.put(Integer.valueOf(line[0]), orgUnit);
break;
}
}
reader.close();
}
//Free references since the maps are static
cleanDummyLists();
}
Aggregations