use of org.ehrbase.serialisation.walker.NodeId in project openEHR_SDK by ehrbase.
the class StdToCompositionWalker method extract.
@Override
protected Map<FlatPathDto, String> extract(Context<Map<FlatPathDto, String>> context, WebTemplateNode child, boolean isChoice, Integer count) {
context.getNodeDeque().push(child);
Integer oldCount = null;
if (count != null) {
oldCount = context.getCountMap().get(new NodeId(child));
context.getCountMap().put(new NodeId(child), count);
}
String path;
path = buildNamePathWithElementHandling(context);
context.getNodeDeque().remove();
context.getCountMap().remove(new NodeId(child));
if (oldCount != null) {
context.getCountMap().put(new NodeId(child), oldCount);
}
Map<FlatPathDto, String> subValues = context.getObjectDeque().peek().entrySet().stream().filter(e -> e.getKey().startsWith(path)).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
if (isChoice && !isMatchingNode(subValues, context, child, new FlatPathDto(path))) {
subValues = Collections.emptyMap();
}
if (!subValues.isEmpty()) {
return subValues;
} else {
return null;
}
}
use of org.ehrbase.serialisation.walker.NodeId in project openEHR_SDK by ehrbase.
the class StdToCompositionWalker method calculateSize.
@Override
protected int calculateSize(Context<Map<FlatPathDto, String>> context, WebTemplateNode childNode) {
Integer oldCount = context.getCountMap().get(new NodeId(childNode));
String namePath = context.getFlatHelper().buildNamePath(context, true);
String finalNamePath = namePath;
Integer count = context.getObjectDeque().peek().keySet().stream().filter(s -> s.startsWith(finalNamePath)).map(s -> FlatPathDto.removeStart(s, new FlatPathDto(finalNamePath))).filter(n -> n != null && n.getName().equals(childNode.getId())).map(n -> Optional.ofNullable(n.getCount()).orElse(0)).sorted().reduce((first, second) -> second).map(i -> i + 1).orElse(0);
if (oldCount != null) {
context.getCountMap().put(new NodeId(childNode), oldCount);
}
return count;
}
Aggregations