Search in sources :

Example 1 with InstanceAccessor

use of eu.esdihumboldt.hale.common.instance.groovy.InstanceAccessor in project hale by halestudio.

the class PropertiesMergeHandler method getMergeKey.

@Override
protected DeepIterableKey getMergeKey(Instance instance, PropertiesMergeConfig mergeConfig) {
    if (mergeConfig.keyProperties.isEmpty()) {
        // merge all instances
        return DeepIterableKey.KEY_ALL;
    }
    List<Object> valueList = new ArrayList<Object>(mergeConfig.keyProperties.size());
    for (List<QName> propertyPath : mergeConfig.keyProperties) {
        // retrieve values from instance
        // XXX should nulls be listed?
        InstanceAccessor accessor = new InstanceAccessor(instance);
        for (QName name : propertyPath) {
            accessor.findChildren(name.getLocalPart(), Collections.singletonList(name.getNamespaceURI()));
        }
        valueList.add(accessor.list(true));
    }
    return new DeepIterableKey(valueList);
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) InstanceAccessor(eu.esdihumboldt.hale.common.instance.groovy.InstanceAccessor) DeepIterableKey(eu.esdihumboldt.hale.common.instance.index.DeepIterableKey)

Aggregations

InstanceAccessor (eu.esdihumboldt.hale.common.instance.groovy.InstanceAccessor)1 DeepIterableKey (eu.esdihumboldt.hale.common.instance.index.DeepIterableKey)1 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1