Search in sources :

Example 1 with RmIntrospectConfig

use of org.ehrbase.webtemplate.parser.config.RmIntrospectConfig in project openEHR_SDK by ehrbase.

the class FlattFilter method skip.

@Override
protected boolean skip(WebTemplateNode node, WebTemplate context, Deque<WebTemplateNode> deque) {
    WebTemplateNode parent = deque.peek();
    if (isTrivialNode(node, parent)) {
        return true;
    } else {
        if (parent != null) {
            RMTypeInfo typeInfo = ARCHIE_RM_INFO_LOOKUP.getTypeInfo(parent.getRmType());
            Set<String> attributeNames = Optional.ofNullable(configMap.get(typeInfo.getJavaClass())).map(RmIntrospectConfig::getNonTemplateFields).orElse(Collections.emptySet()).stream().map(s -> new SnakeCase(s).camelToSnake()).collect(Collectors.toSet());
            attributeNames.add("context");
            attributeNames.add("timing");
            attributeNames.add("expiry_time");
            attributeNames.add("lower");
            attributeNames.add("upper");
            attributeNames.add("ism_transition");
            attributeNames.add("location");
            attributeNames.add("lower_included");
            attributeNames.add("upper_included");
            attributeNames.add("sample_count");
            deque.poll();
            if (!isTrivialNode(parent, deque.peek()) && Locatable.class.isAssignableFrom(typeInfo.getJavaClass())) {
                attributeNames.add("feeder_audit");
            }
            deque.push(parent);
            if (config.isAddNullFlavor()) {
                attributeNames.add("null_flavour");
            }
            SetUtils.SetView<String> difference = SetUtils.difference(typeInfo.getAttributes().keySet(), attributeNames);
            if (difference.contains(node.getName())) {
                return true;
            }
        }
        return false;
    }
}
Also used : WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) SnakeCase(org.ehrbase.serialisation.util.SnakeCase) ReflectionHelper(org.ehrbase.util.reflection.ReflectionHelper) RmIntrospectConfig(org.ehrbase.webtemplate.parser.config.RmIntrospectConfig) FlatPath(org.ehrbase.webtemplate.parser.FlatPath) java.util(java.util) Locatable(com.nedap.archie.rm.archetyped.Locatable) RMTypeInfo(com.nedap.archie.rminfo.RMTypeInfo) SetUtils(org.apache.commons.collections4.SetUtils) WebTemplateNode(org.ehrbase.webtemplate.model.WebTemplateNode) Collectors(java.util.stream.Collectors) Filter(org.ehrbase.webtemplate.filter.Filter) RMTypeInfo(com.nedap.archie.rminfo.RMTypeInfo) SetUtils(org.apache.commons.collections4.SetUtils) SnakeCase(org.ehrbase.serialisation.util.SnakeCase) WebTemplateNode(org.ehrbase.webtemplate.model.WebTemplateNode) RmIntrospectConfig(org.ehrbase.webtemplate.parser.config.RmIntrospectConfig) Locatable(com.nedap.archie.rm.archetyped.Locatable)

Aggregations

Locatable (com.nedap.archie.rm.archetyped.Locatable)1 RMTypeInfo (com.nedap.archie.rminfo.RMTypeInfo)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 SetUtils (org.apache.commons.collections4.SetUtils)1 SnakeCase (org.ehrbase.serialisation.util.SnakeCase)1 ReflectionHelper (org.ehrbase.util.reflection.ReflectionHelper)1 Filter (org.ehrbase.webtemplate.filter.Filter)1 WebTemplate (org.ehrbase.webtemplate.model.WebTemplate)1 WebTemplateNode (org.ehrbase.webtemplate.model.WebTemplateNode)1 FlatPath (org.ehrbase.webtemplate.parser.FlatPath)1 RmIntrospectConfig (org.ehrbase.webtemplate.parser.config.RmIntrospectConfig)1