use of org.eyeseetea.malariacare.data.database.model.OrgUnit in project pictureapp by EyeSeeTea.
the class ConvertFromSDKVisitor method visit.
/**
* Turns an event into a sent survey
*/
@Override
public void visit(EventExtended sdkEventExtended) {
OrgUnit orgUnit = (OrgUnit) appMapObjects.get(sdkEventExtended.getOrganisationUnitId());
Program program = Program.getProgram(sdkEventExtended.getProgramUId());
Survey survey = new Survey();
//Any survey that comes from the pull has been sent
survey.setStatus(Constants.SURVEY_SENT);
//Set dates
survey.setCreationDate(sdkEventExtended.getCreationDate());
survey.setCompletionDate(sdkEventExtended.getEventDate());
survey.setEventDate(sdkEventExtended.getEventDate());
survey.setScheduledDate(sdkEventExtended.getScheduledDate());
//Set fks
survey.setOrgUnit(orgUnit);
survey.setProgram(program);
survey.setEventUid(sdkEventExtended.getUid());
mConvertFromSDKVisitorStrategy.visit(sdkEventExtended, survey);
surveys.add(survey);
//Annotate object in map
appMapObjects.put(sdkEventExtended.getUid(), survey);
}
use of org.eyeseetea.malariacare.data.database.model.OrgUnit 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);
}
use of org.eyeseetea.malariacare.data.database.model.OrgUnit in project pictureapp by EyeSeeTea.
the class OrgUnitToOptionConverter method convert.
public static void convert() {
List<Question> questions = Question.getAllQuestionsWithOrgUnitDropdownList();
if (questions.size() == 0) {
return;
}
List<OrgUnit> orgUnits = OrgUnit.getAllOrgUnit();
for (OrgUnit orgUnit : orgUnits) {
addOUOptionToQuestions(questions, orgUnit);
}
}
Aggregations