}
public DebugBlockApply createDebugBlockApply(BlockApply blockApply, RutaStream stream,
boolean addToIndex, boolean withMatches, Map<RutaElement, Long> timeInfo) {
JCas cas = stream.getJCas();
DebugBlockApply dba = new DebugBlockApply(cas);
List<DebugScriptApply> innerApply = new ArrayList<DebugScriptApply>();
// TODO refactor and remove counting hotfix
int applied = blockApply.getRuleApply().getApplied();
RutaElement element = blockApply.getElement();
String verbalize = "";
if(element instanceof RutaBlock) {
verbalize = verbalizer.verbalize((RutaBlock) element, false);
} else {
verbalize = verbalizer.verbalize(element);
}
if (applied > 1) {
List<ScriptApply> innerApplies = blockApply.getInnerApplies();
List<List<ScriptApply>> loops = new ArrayList<List<ScriptApply>>();
for (int i = 0; i < applied; i++) {
loops.add(new ArrayList<ScriptApply>());
}
int counter = 0;
int size = innerApplies.size();
int parts = size / applied;
for (ScriptApply each : innerApplies) {
int listIndex = Math.max(0, counter / parts);
List<ScriptApply> list = loops.get(listIndex);
list.add(each);
counter++;
}
counter = 0;
for (List<ScriptApply> list : loops) {
AbstractRuleMatch<? extends AbstractRule> ruleMatch = blockApply.getRuleApply().getList()
.get(counter);
DebugBlockApply dummyBlockApply = createDummyBlockApply((RuleMatch) ruleMatch, stream,
addToIndex, withMatches, timeInfo);
List<DebugRuleMatch> ruleMatches = new ArrayList<DebugRuleMatch>();
ruleMatches.add(createDebugRuleMatch(ruleMatch, stream, addToIndex, withMatches, timeInfo));
dummyBlockApply.setApplied(1);
dummyBlockApply.setTried(1);
dummyBlockApply.setRules(UIMAUtils.toFSArray(cas, ruleMatches));
List<DebugScriptApply> innerInnerApply = new ArrayList<DebugScriptApply>();
for (ScriptApply each : list) {
DebugScriptApply eachInnerInner = createDebugScriptApply(each, stream, addToIndex,
withMatches, timeInfo);
innerInnerApply.add(eachInnerInner);
}
dummyBlockApply.setInnerApply(UIMAUtils.toFSArray(cas, innerInnerApply));
innerApply.add(dummyBlockApply);
counter++;
}
dba.setInnerApply(UIMAUtils.toFSArray(cas, innerApply));
dba.setElement(verbalize);