use of org.eyeseetea.malariacare.domain.exception.QuestionNotFoundException in project pictureapp by EyeSeeTea.
the class DataConverterStrategy method convertOrgUnitDataValue.
private void convertOrgUnitDataValue(ConvertFromSDKVisitor converter, EventExtended event) throws QuestionNotFoundException {
if (event.getProgramUId().equals(mContext.getString(R.string.stockProgramUID))) {
return;
}
Question orgUnitQuestion = Question.findByUID(ORG_UNIT_QUESTION_UID);
if (orgUnitQuestion == null) {
throw new QuestionNotFoundException(String.format("Question with uid %s not found", ORG_UNIT_QUESTION_UID));
}
DataValueExtended OrgUnitDataValue = new DataValueExtended();
OrgUnitDataValue.setEvent(event.getEvent());
OrgUnitDataValue.setDataElement(orgUnitQuestion.getUid());
OrgUnitDataValue.setValue(event.getOrganisationUnitId());
OrgUnitDataValue.accept(converter);
}
use of org.eyeseetea.malariacare.domain.exception.QuestionNotFoundException in project pictureapp by EyeSeeTea.
the class DataConverter method convert.
public void convert(IPullController.Callback callback, ConvertFromSDKVisitor converter) {
String orgUnitName = PreferencesState.getInstance().getOrgUnit();
List<OrgUnit> orgUnits = converter.getOrgUnits();
for (OrgUnit orgUnit : orgUnits) {
//Only events for the right ORGUNIT are loaded
if (!orgUnitName.isEmpty() && orgUnit.getName() != null && !orgUnit.getName().equals(orgUnitName)) {
continue;
}
List<Program> programs = Program.getAllPrograms();
for (Program program : programs) {
List<EventExtended> events = EventExtended.getExtendedList(SdkQueries.getEvents(orgUnit.getUid(), program.getUid()));
callback.onStep(BUILDING_SURVEYS);
for (EventExtended event : events) {
event.accept(converter);
}
callback.onStep(BUILDING_VALUES);
for (EventExtended event : events) {
List<DataValueExtended> dataValues = DataValueExtended.getExtendedList(SdkQueries.getDataValues(event.getUid()));
for (DataValueExtended dataValueExtended : dataValues) {
dataValueExtended.accept(converter);
}
try {
dataConverterStrategy.convert(converter, event);
} catch (QuestionNotFoundException e) {
callback.onError(e);
}
}
}
}
saveConvertedSurveys(callback, converter);
}
Aggregations