use of org.eyeseetea.malariacare.data.database.model.QuestionRelation in project pictureapp by EyeSeeTea.
the class ReviewFragment method getReviewValues.
private List<Value> getReviewValues() {
List<Value> reviewValues = new ArrayList<>();
Survey survey = Session.getMalariaSurvey();
List<Value> allValues = survey.getValuesFromDB();
for (Value value : allValues) {
boolean isReviewValue = true;
if (value.getQuestion() == null) {
continue;
}
for (QuestionRelation questionRelation : value.getQuestion().getQuestionRelations()) {
if (questionRelation.isACounter() || questionRelation.isAReminder() || questionRelation.isAWarning() || questionRelation.isAMatch()) {
isReviewValue = false;
}
}
int output = value.getQuestion().getOutput();
if (output == Constants.HIDDEN || output == Constants.DYNAMIC_STOCK_IMAGE_RADIO_BUTTON) {
isReviewValue = false;
}
if (isReviewValue) {
if (value.getQuestion() != null) {
reviewValues.add(value);
}
}
}
return reviewValues;
}
use of org.eyeseetea.malariacare.data.database.model.QuestionRelation in project pictureapp by EyeSeeTea.
the class PopulateRow method populateQuestionRelation.
static QuestionRelation populateQuestionRelation(String[] line, HashMap<Long, Question> questionFK, @Nullable QuestionRelation questionRelation) {
if (questionRelation == null) {
questionRelation = new QuestionRelation();
}
questionRelation.setOperation(Integer.valueOf(line[1]));
questionRelation.setQuestion(questionFK.get(Long.valueOf(line[2])));
return questionRelation;
}
use of org.eyeseetea.malariacare.data.database.model.QuestionRelation in project pictureapp by EyeSeeTea.
the class RelationsIdCsvDB method getQuestionRelationIdRelationCsvDB.
static HashMap<Long, QuestionRelation> getQuestionRelationIdRelationCsvDB(Context context) throws IOException {
HashMap<Long, QuestionRelation> questionRelationsFK = new HashMap<>();
List<QuestionRelation> questionRelations = QuestionRelation.listAll();
List<Long> csvIds = new ArrayList<>();
CSVReader reader = new CSVReader(new InputStreamReader(context.openFileInput(PopulateDB.QUESTION_RELATIONS_CSV)), PopulateDB.SEPARATOR, PopulateDB.QUOTECHAR);
String[] idToAdd;
while ((idToAdd = reader.readNext()) != null) {
csvIds.add(Long.parseLong(idToAdd[0]));
}
for (int i = 0; i < questionRelations.size() && i < csvIds.size(); i++) {
questionRelationsFK.put(csvIds.get(i), questionRelations.get(i));
}
return questionRelationsFK;
}
use of org.eyeseetea.malariacare.data.database.model.QuestionRelation in project pictureapp by EyeSeeTea.
the class ReminderStatusChecker method initRemainderTriggers.
private void initRemainderTriggers(Question reminderQuestion) {
this.reminderTriggers = new ArrayList<>();
// Look for a REMINDER relation which origin questionOption is activated
for (QuestionRelation questionRelation : reminderQuestion.getQuestionRelations()) {
if (!questionRelation.isAReminder()) {
continue;
}
// Find QuestionOption for this relation
QuestionOption questionOption = findQuestionOption(questionRelation);
if (questionOption == null) {
continue;
}
// Annotate questionOption to check
this.reminderTriggers.add(questionOption);
}
}
use of org.eyeseetea.malariacare.data.database.model.QuestionRelation in project pictureapp by EyeSeeTea.
the class PopulateDB method createMissingRelationInLao.
/**
* Migration used to add a new parent-child relation in lao
*/
public static void createMissingRelationInLao() {
// new match relation in csv
// 29;29
// new QuestionOption in csv
// 45;5;13;29
// new QuestionRelation in csv
// 29;1;6
Long childId = 6l;
Long parentId = 5l;
Long optionId = 13l;
QuestionRelation questionRelation = new QuestionRelation(Question.findByID(childId), QuestionRelation.PARENT_CHILD);
questionRelation.save();
Match match = new Match(questionRelation);
match.save();
QuestionOption questionOption = new QuestionOption(Option.findById(optionId), Question.findByID(parentId), match);
questionOption.save();
}
Aggregations