From 623d93960d81d1461274dd95a30eb16f0107ba13 Mon Sep 17 00:00:00 2001 From: idelcano Date: Mon, 15 Oct 2018 13:08:15 +0200 Subject: [PATCH 1/2] fix merge error and avoid gent in progress as sent --- .../eyeseetea/malariacare/data/database/model/SurveyDB.java | 1 + .../java/org/eyeseetea/malariacare/services/SurveyService.java | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/eyeseetea/malariacare/data/database/model/SurveyDB.java b/app/src/main/java/org/eyeseetea/malariacare/data/database/model/SurveyDB.java index 6135985540..b0e9c94ec1 100644 --- a/app/src/main/java/org/eyeseetea/malariacare/data/database/model/SurveyDB.java +++ b/app/src/main/java/org/eyeseetea/malariacare/data/database/model/SurveyDB.java @@ -363,6 +363,7 @@ public static List getAllSurveysByProgram(String malariaProgramUid) { .eq(ProgramDB_Table.id_program.withTable(programAlias))) .where(ProgramDB_Table.uid_program.withTable(programAlias) .is(malariaProgramUid)) + .and(SurveyDB_Table.status.withTable(surveyAlias).isNot(Constants.SURVEY_IN_PROGRESS)) .orderBy(OrderBy.fromProperty(SurveyDB_Table.event_date.withTable(surveyAlias))) .orderBy(OrderBy.fromProperty( SurveyDB_Table.id_org_unit_fk.withTable(surveyAlias))).queryList(); diff --git a/app/src/main/java/org/eyeseetea/malariacare/services/SurveyService.java b/app/src/main/java/org/eyeseetea/malariacare/services/SurveyService.java index d49b1ba238..cd7ca0c92e 100644 --- a/app/src/main/java/org/eyeseetea/malariacare/services/SurveyService.java +++ b/app/src/main/java/org/eyeseetea/malariacare/services/SurveyService.java @@ -187,10 +187,9 @@ private void getAllUnsentSurveys() { @Override public void onSuccess(String uid) { List surveyDBs = SurveyServiceStrategy.getUnsentSurveys(uid); - List unsentSurveyDBs = new ArrayList(); //Since intents does NOT admit NON serializable as values we use Session instead - Session.putServiceValue(ALL_UNSENT_SURVEYS_ACTION, unsentSurveyDBs); + Session.putServiceValue(ALL_UNSENT_SURVEYS_ACTION, surveyDBs); //Returning result to anyone listening Intent resultIntent = new Intent(ALL_UNSENT_SURVEYS_ACTION); From 8690e1944c3ba166fce6f0cd24c971dc9807d22d Mon Sep 17 00:00:00 2001 From: idelcano Date: Mon, 15 Oct 2018 13:25:03 +0200 Subject: [PATCH 2/2] rename method --- .../malariacare/services/strategies/SurveyServiceStrategy.java | 2 +- .../org/eyeseetea/malariacare/data/database/model/SurveyDB.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/ereferrals/java/org/eyeseetea/malariacare/services/strategies/SurveyServiceStrategy.java b/app/src/ereferrals/java/org/eyeseetea/malariacare/services/strategies/SurveyServiceStrategy.java index 9df60d5424..acb8caa7cf 100644 --- a/app/src/ereferrals/java/org/eyeseetea/malariacare/services/strategies/SurveyServiceStrategy.java +++ b/app/src/ereferrals/java/org/eyeseetea/malariacare/services/strategies/SurveyServiceStrategy.java @@ -7,7 +7,7 @@ public class SurveyServiceStrategy extends ASurveyServiceStrategy { public static List getUnsentSurveys(String programUId){ - List surveyDBs = SurveyDB.getAllSurveysByProgram(programUId); + List surveyDBs = SurveyDB.getAllNotInProgressSurveysByProgram(programUId); return surveyDBs; } } diff --git a/app/src/main/java/org/eyeseetea/malariacare/data/database/model/SurveyDB.java b/app/src/main/java/org/eyeseetea/malariacare/data/database/model/SurveyDB.java index b0e9c94ec1..3e01a1a2ea 100644 --- a/app/src/main/java/org/eyeseetea/malariacare/data/database/model/SurveyDB.java +++ b/app/src/main/java/org/eyeseetea/malariacare/data/database/model/SurveyDB.java @@ -356,7 +356,7 @@ public static List getAllUnsentMalariaSurveys(String malariaProgramUid SurveyDB_Table.id_org_unit_fk.withTable(surveyAlias))).queryList(); } - public static List getAllSurveysByProgram(String malariaProgramUid) { + public static List getAllNotInProgressSurveysByProgram(String malariaProgramUid) { return new Select().from(SurveyDB.class).as(surveyName).join(ProgramDB.class, Join.JoinType.LEFT_OUTER).as(programName) .on(SurveyDB_Table.id_program_fk.withTable(surveyAlias)