Skip to content

Commit

Permalink
34 : Added Set of DynamicValue on Action
Browse files Browse the repository at this point in the history
  • Loading branch information
rehammuzzamil committed Jun 25, 2020
1 parent d1e116f commit cd5386f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/smartregister/domain/Action.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Action {

private String definitionUri;

private DynamicValue dynamicValue;
private Set<DynamicValue> dynamicValue;

@AllArgsConstructor
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.smartregister.domain.Action;
import org.smartregister.domain.DynamicValue;
import org.smartregister.domain.ExecutionPeriod;
import org.smartregister.domain.Task;
import org.smartregister.pathevaluator.PathEvaluatorLibrary;
Expand Down Expand Up @@ -45,11 +46,13 @@ public void generateTask(Resource resource, Action action, String planIdentifier
task.setExecutionEndDate(getDateTime(action.getTimingPeriod(), false));
task.setAuthoredOn(DateTime.now());
task.setLastModified(DateTime.now());
if (action.getDynamicValue() != null && action.getDynamicValue().getExpression() != null &&
action.getDynamicValue().getExpression().getName().equals("defaultBusinessStatus")) {
task.setBusinessStatus(action.getDynamicValue().getExpression().getExpression());
} else {
task.setBusinessStatus("Not Visited");
for (DynamicValue dynamicValue : action.getDynamicValue()) {
if (dynamicValue != null && dynamicValue.getExpression() != null &&
dynamicValue.getExpression().getName().equals("defaultBusinessStatus")) {
task.setBusinessStatus(dynamicValue.getExpression().getExpression());
} else {
task.setBusinessStatus("Not Visited");
}
}
task.setRequester(username);
task.setOwner(username);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/smartregister/pathevaluator/TestData.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ public class TestData {
+ "\"text\": \"Location\"\n"
+ "},\n"
+ "\"definitionUri\": \"zambia_family_register.json\",\n"
+ "\"dynamicValue\": {\n"
+ "\"dynamicValue\": [{\n"
+ "\"expression\": {\n"
+ "\"name\": \"defaultBusinessStatus\",\n"
+ "\"expression\": \"expression\"\n"
+ "}\n"
+ "}\n"
+ "}]\n"
+ "}]\n"
+ "}";

Expand Down

0 comments on commit cd5386f

Please sign in to comment.