From 955eb3ae506de6244c5fc0e7515a4843dfe65c6f Mon Sep 17 00:00:00 2001 From: Steph Date: Sun, 15 Oct 2023 21:06:54 -0400 Subject: [PATCH 1/5] retrieve dynamic search for query request --- src/cli/java/org/commcare/util/screen/QueryScreen.java | 6 ++++++ .../java/org/commcare/suite/model/RemoteQueryDatum.java | 6 ++++++ src/main/java/org/commcare/xml/SessionDatumParser.java | 5 +++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/cli/java/org/commcare/util/screen/QueryScreen.java b/src/cli/java/org/commcare/util/screen/QueryScreen.java index ca18fcc855..64bf8d6be8 100644 --- a/src/cli/java/org/commcare/util/screen/QueryScreen.java +++ b/src/cli/java/org/commcare/util/screen/QueryScreen.java @@ -62,6 +62,8 @@ public class QueryScreen extends Screen { private boolean defaultSearch; + private boolean dynamicSearch; + public QueryScreen(String domainedUsername, String password, PrintStream out, VirtualDataInstanceStorage instanceStorage, SessionUtils sessionUtils) { this.domainedUsername = domainedUsername; @@ -214,6 +216,10 @@ public String getDescriptionText() { return description; } + public boolean getDynamicSearch() { + return dynamicSearch; + } + @Override public boolean prompt(PrintStream out) { if (doDefaultSearch()) { diff --git a/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java b/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java index c31b16d7f3..043fef00f6 100644 --- a/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java +++ b/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java @@ -30,6 +30,7 @@ public class RemoteQueryDatum extends SessionDatum { private OrderedHashtable userQueryPrompts; private boolean useCaseTemplate; private boolean defaultSearch; + private boolean dynamicSearch; private Text title; private Text description; @@ -51,6 +52,7 @@ public RemoteQueryDatum(URL url, String storageInstance, this.userQueryPrompts = userQueryPrompts; this.useCaseTemplate = useCaseTemplate; this.defaultSearch = defaultSearch; + this.dynamicSearch = dynamicSearch; this.title = title; this.description = description; } @@ -81,6 +83,10 @@ public boolean doDefaultSearch() { return defaultSearch; } + public boolean doDynamicSearch() { + return dynamicSearch; + } + public Text getTitleText() { return title; } diff --git a/src/main/java/org/commcare/xml/SessionDatumParser.java b/src/main/java/org/commcare/xml/SessionDatumParser.java index 9dcb161fb8..a841188065 100644 --- a/src/main/java/org/commcare/xml/SessionDatumParser.java +++ b/src/main/java/org/commcare/xml/SessionDatumParser.java @@ -126,6 +126,7 @@ private RemoteQueryDatum parseRemoteQueryDatum() } boolean defaultSearch = "true".equals(parser.getAttributeValue(null, "default_search")); + boolean dynamicSearch = "true".equals(parser.getAttributeValue(null, "dynamic_search")); Text title = null; Text description = null; ArrayList hiddenQueryValues = new ArrayList(); @@ -144,7 +145,7 @@ private RemoteQueryDatum parseRemoteQueryDatum() description = new TextParser(parser).parse(); } } - return new RemoteQueryDatum(queryUrl, queryResultStorageInstance, - hiddenQueryValues, userQueryPrompts, useCaseTemplate, defaultSearch, title, description); + return new RemoteQueryDatum(queryUrl, queryResultStorageInstance, hiddenQueryValues, + userQueryPrompts, useCaseTemplate, defaultSearch, dynamicSearch, title, description); } } From 8bfbc6f54aa0b5eb32a1c7c493cafa7022cb0390 Mon Sep 17 00:00:00 2001 From: Steph Date: Tue, 24 Oct 2023 17:28:57 -0400 Subject: [PATCH 2/5] sets value of dynamicSearch for QueryScreen --- src/cli/java/org/commcare/util/screen/QueryScreen.java | 5 +++++ .../org/commcare/session/RemoteQuerySessionManager.java | 4 ++++ .../java/org/commcare/suite/model/RemoteQueryDatum.java | 6 +++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cli/java/org/commcare/util/screen/QueryScreen.java b/src/cli/java/org/commcare/util/screen/QueryScreen.java index 64bf8d6be8..b0226439dd 100644 --- a/src/cli/java/org/commcare/util/screen/QueryScreen.java +++ b/src/cli/java/org/commcare/util/screen/QueryScreen.java @@ -284,6 +284,11 @@ public boolean doDefaultSearch() { return remoteQuerySessionManager.doDefaultSearch(); } + public boolean hasDynamicSearch() { + return remoteQuerySessionManager.hasDynamicSearch(); + } + + public RemoteQueryDatum getQueryDatum() { return remoteQuerySessionManager.getQueryDatum(); } diff --git a/src/main/java/org/commcare/session/RemoteQuerySessionManager.java b/src/main/java/org/commcare/session/RemoteQuerySessionManager.java index 7553bae0ea..827c10bf1a 100644 --- a/src/main/java/org/commcare/session/RemoteQuerySessionManager.java +++ b/src/main/java/org/commcare/session/RemoteQuerySessionManager.java @@ -306,6 +306,10 @@ public boolean doDefaultSearch() { return queryDatum.doDefaultSearch(); } + public boolean hasDynamicSearch() { + return queryDatum.hasDynamicSearch(); + } + // Converts a string containing space separated list of choices // into a string array of individual choices public static String[] extractMultipleChoices(String answer) { diff --git a/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java b/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java index 043fef00f6..016d9cef81 100644 --- a/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java +++ b/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java @@ -46,7 +46,7 @@ public RemoteQueryDatum() { public RemoteQueryDatum(URL url, String storageInstance, List hiddenQueryValues, OrderedHashtable userQueryPrompts, - boolean useCaseTemplate, boolean defaultSearch, Text title, Text description) { + boolean useCaseTemplate, boolean defaultSearch, boolean dynamicSearch, Text title, Text description) { super(storageInstance, url.toString()); this.hiddenQueryValues = hiddenQueryValues; this.userQueryPrompts = userQueryPrompts; @@ -83,7 +83,7 @@ public boolean doDefaultSearch() { return defaultSearch; } - public boolean doDynamicSearch() { + public boolean hasDynamicSearch() { return dynamicSearch; } @@ -108,7 +108,7 @@ public void readExternal(DataInputStream in, PrototypeFactory pf) description = (Text) ExtUtil.read(in, new ExtWrapNullable(Text.class), pf); useCaseTemplate = ExtUtil.readBool(in); defaultSearch = ExtUtil.readBool(in); - + dynamicSearch = ExtUtil.readBool(in); } @Override From d35d47f54e54849a44d0a7341ee5b1568e97b901 Mon Sep 17 00:00:00 2001 From: Steph Date: Tue, 7 Nov 2023 11:31:00 -0500 Subject: [PATCH 3/5] add write for dynamicSearch to match read --- src/main/java/org/commcare/suite/model/RemoteQueryDatum.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java b/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java index 016d9cef81..bfea26b2c8 100644 --- a/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java +++ b/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java @@ -120,6 +120,7 @@ public void writeExternal(DataOutputStream out) throws IOException { ExtUtil.write(out, new ExtWrapNullable(description)); ExtUtil.writeBool(out, useCaseTemplate); ExtUtil.writeBool(out, defaultSearch); + ExtUtil.writeBool(out, dynamicSearch); } } From 6c1c042ecbf8a902f17b7a4e272a984e4fcf6853 Mon Sep 17 00:00:00 2001 From: Steph Date: Tue, 7 Nov 2023 17:20:40 -0500 Subject: [PATCH 4/5] change has to get for getDynamicSearch and change so able to send to HQ --- src/cli/java/org/commcare/util/screen/QueryScreen.java | 5 +---- .../java/org/commcare/session/RemoteQuerySessionManager.java | 4 ++-- src/main/java/org/commcare/suite/model/RemoteQueryDatum.java | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/cli/java/org/commcare/util/screen/QueryScreen.java b/src/cli/java/org/commcare/util/screen/QueryScreen.java index 3a93ad4ee9..4b415763f4 100644 --- a/src/cli/java/org/commcare/util/screen/QueryScreen.java +++ b/src/cli/java/org/commcare/util/screen/QueryScreen.java @@ -93,6 +93,7 @@ public void init(SessionWrapper sessionWrapper) throws CommCareSessionException mTitle = getTitleLocaleString(); description = getDescriptionLocaleString(); + dynamicSearch = getQueryDatum().getDynamicSearch(); } private String getTitleLocaleString() { @@ -281,10 +282,6 @@ public boolean doDefaultSearch() { return remoteQuerySessionManager.doDefaultSearch(); } - public boolean hasDynamicSearch() { - return remoteQuerySessionManager.hasDynamicSearch(); - } - public RemoteQueryDatum getQueryDatum() { return remoteQuerySessionManager.getQueryDatum(); diff --git a/src/main/java/org/commcare/session/RemoteQuerySessionManager.java b/src/main/java/org/commcare/session/RemoteQuerySessionManager.java index 827c10bf1a..8e35859ee8 100644 --- a/src/main/java/org/commcare/session/RemoteQuerySessionManager.java +++ b/src/main/java/org/commcare/session/RemoteQuerySessionManager.java @@ -306,8 +306,8 @@ public boolean doDefaultSearch() { return queryDatum.doDefaultSearch(); } - public boolean hasDynamicSearch() { - return queryDatum.hasDynamicSearch(); + public boolean getDynamicSearch() { + return queryDatum.getDynamicSearch(); } // Converts a string containing space separated list of choices diff --git a/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java b/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java index bfea26b2c8..d25dc1cf87 100644 --- a/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java +++ b/src/main/java/org/commcare/suite/model/RemoteQueryDatum.java @@ -83,7 +83,7 @@ public boolean doDefaultSearch() { return defaultSearch; } - public boolean hasDynamicSearch() { + public boolean getDynamicSearch() { return dynamicSearch; } From e0e60cde51a29d7697a2472b3c1c08d0c0292304 Mon Sep 17 00:00:00 2001 From: Shubham Goyal Date: Wed, 8 Nov 2023 12:30:46 -0500 Subject: [PATCH 5/5] Adds a xml model test --- .../commcare/backend/suite/model/test/CaseClaimModelTests.java | 2 ++ src/test/resources/case_claim_example/suite.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/commcare/backend/suite/model/test/CaseClaimModelTests.java b/src/test/java/org/commcare/backend/suite/model/test/CaseClaimModelTests.java index a8ebc3f023..edfd279589 100644 --- a/src/test/java/org/commcare/backend/suite/model/test/CaseClaimModelTests.java +++ b/src/test/java/org/commcare/backend/suite/model/test/CaseClaimModelTests.java @@ -62,6 +62,8 @@ public void testRemoteQueryDatum() throws Exception { Text description = ((RemoteQueryDatum) datum).getDescriptionText(); Assert.assertEquals("Description text", description.evaluate()); + + Assert.assertTrue(((RemoteQueryDatum)datum).getDynamicSearch()); } @Test diff --git a/src/test/resources/case_claim_example/suite.xml b/src/test/resources/case_claim_example/suite.xml index ee0ba9c4ac..3aff510097 100644 --- a/src/test/resources/case_claim_example/suite.xml +++ b/src/test/resources/case_claim_example/suite.xml @@ -61,7 +61,7 @@ - + <text> <locale id="query.title"/>