@Override
protected void adaptForPathImpl(final InstanceIdentifier<?> augTarget, final DataNodeContainer ctxNode) {
- Optional<ChoiceNode> newChoice = BindingSchemaContextUtils.findInstantiatedChoice(ctxNode, choiceType);
tryToLoadImplementations();
+ Optional<ChoiceNode> newChoice = BindingSchemaContextUtils.findInstantiatedChoice(ctxNode, choiceType);
+ if(!newChoice.isPresent()) {
+ // Choice is nested inside other choice, so we need to look two levels deep.
+ in_choices: for(DataSchemaNode child : ctxNode.getChildNodes()) {
+ if(child instanceof ChoiceNode) {
+ Optional<ChoiceNode> potential = findChoiceInChoiceCases((ChoiceNode) child, choiceType);
+ if(potential.isPresent()) {
+ newChoice = potential;
+ break in_choices;
+ }
+ }
+ }
+ }
+
Preconditions.checkState(newChoice.isPresent(), "BUG: Unable to find instantiated choice node in schema.");
for (@SuppressWarnings("rawtypes")
Entry<Class, ChoiceCaseCodecImpl<?>> codec : getImplementations().entrySet()) {
}
}
+ private Optional<ChoiceNode> findChoiceInChoiceCases(ChoiceNode choice, Class<?> choiceType) {
+ for(ChoiceCaseNode caze : choice.getCases()) {
+ Optional<ChoiceNode> potential = BindingSchemaContextUtils.findInstantiatedChoice(caze, choiceType);
+ if(potential.isPresent()) {
+ return potential;
+ }
+ }
+ return Optional.absent();
+ }
+
@Override
public String toString() {
return "DispatchChoiceCodecImpl [choiceType=" + choiceType + "]";
import org.opendaylight.yangtools.yang.binding.RpcService;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.Node;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.Node;
import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
Document doc = builder.parse(inputStream);
Element rootElement = doc.getDocumentElement();
Node<?> domNode = XmlDocumentUtils.toDomNode(rootElement, Optional.of(dataSchema),
- Optional.<XmlCodecProvider> absent());
+ Optional.<XmlCodecProvider> absent(), Optional.of(schemaContext));
DataObject dataObject = mappingService.dataObjectFromDataDom(path, (CompositeNode) domNode); // getDataFromResponse
return dataObject;
} catch (DeserializationException e) {