Skip to content

Commit

Permalink
Resolve reporting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ctsims committed Jul 17, 2017
1 parent 66aa6ce commit 2996dfb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
25 changes: 20 additions & 5 deletions src/main/java/org/javarosa/core/model/FormDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -1355,27 +1355,42 @@ public void populateDynamicChoices(ItemsetBinding itemset, TreeReference curQRef
ec.setQueryContext(newContext);

for (int i = 0; i < matches.size(); i++) {
choices.addElement(buildSelectChoice(matches.elementAt(i), itemset, formInstance, ec, i));
choices.addElement(buildSelectChoice(matches.elementAt(i), itemset, formInstance,
ec, reporter, i));
}
itemset.setChoices(choices);
}

private SelectChoice buildSelectChoice(TreeReference choiceRef, ItemsetBinding itemset,
DataInstance formInstance, EvaluationContext ec, int index) {
DataInstance formInstance, EvaluationContext ec,
ReducingTraceReporter reporter, int index) {

String label = itemset.labelExpr.evalReadable(formInstance,
new EvaluationContext(ec, choiceRef));

if(reporter != null) {
InstrumentationUtils.printAndClearTraces(reporter, "ItemSet [label] population");
}

String value = null;
TreeElement copyNode = null;

if (itemset.copyMode) {
copyNode = this.getMainInstance().resolveReference(itemset.copyRef.contextualize(choiceRef));
}

if (itemset.valueRef != null) {
value = itemset.valueExpr.evalReadable(formInstance,
new EvaluationContext(ec, choiceRef));
}

if(reporter != null) {
InstrumentationUtils.printAndClearTraces(reporter, "ItemSet [value] population");
}

SelectChoice choice = new SelectChoice(label, value != null ? value : "dynamic:" + index,
itemset.labelIsItext);

choice.setIndex(index);

if (itemset.copyMode) {
Expand All @@ -1388,11 +1403,11 @@ private SelectChoice buildSelectChoice(TreeReference choiceRef, ItemsetBinding i
choice.setSortProperty(evaluatedSortProperty);
}

return choice;

if(reporter != null) {
InstrumentationUtils.printAndClearTraces(reporter, "itemset population");
InstrumentationUtils.printAndClearTraces(reporter, "ItemSet [sort] population");
}

return choice;
}

public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ public void testLinearSub() {
public void run() {
holder[0] = Localizer.processArguments("${0}", new String[]{C});
}
});
}, "Argument processing: " + C);

assertEquals(holder[0], C);

Expand All @@ -653,7 +653,7 @@ public void run() {
public void run() {
holder[0] = Localizer.processArguments("${0}", new String[]{D});
}
});
}, "Argument processing: " + D);

assertEquals(holder[0], D);

Expand All @@ -662,7 +662,7 @@ public void run() {
public void run() {
holder[0] = Localizer.processArguments(holder[0], res);
}
});
}, "Argument processing: " + res[1] + res[0]);

assertEquals(holder[0], res[1] + res[0]);

Expand All @@ -671,13 +671,13 @@ public void run() {
public void run() {
holder[0] = Localizer.processArguments("$ {0} ${1}", res);
}
});
}, "Argument processing: " + "$ {0} " + res[1]);

assertEquals(holder[0], "$ {0} " + res[1]);

}

private void runAsync(Runnable test) {
private void runAsync(Runnable test, String label) {
Thread t = new Thread(test);
t.start();
try {
Expand All @@ -687,7 +687,7 @@ private void runAsync(Runnable test) {
}
if (t.isAlive()) {
t.stop();
throw new RuntimeException("Failed to return from recursive argument processing");
throw new RuntimeException("Failed to return from recursive argument processing: "+ label);
}
}

Expand Down

0 comments on commit 2996dfb

Please sign in to comment.