diff options
author | Lena Peuker <PeukerL@telekom.de> | 2022-11-29 15:38:00 +0100 |
---|---|---|
committer | Lena Peuker <PeukerL@telekom.de> | 2022-12-12 14:19:08 +0100 |
commit | e7f24d3f2f239e6bdc14a78eb01d07525650a960 (patch) | |
tree | 23fafc2c30f2dc1e862cbf978d4653ab0a48b1fc /cps-service/src/main/java/org | |
parent | f20b49940bb4dd381b689dfedbddbe80cb3968f7 (diff) |
Fix DataNodeBuilder for ChoiceNodes
Fix implemented to handle YangChoiceNode in right format
Issue-ID: CPS-1352
Signed-off-by: Lena Peuker <PeukerL@telekom.de>
Change-Id: I48d433bac96cfc647bc31c82817870995bace860
Diffstat (limited to 'cps-service/src/main/java/org')
-rw-r--r-- | cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java b/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java index eaa2d77f47..af820def0c 100644 --- a/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java +++ b/cps-service/src/main/java/org/onap/cps/spi/model/DataNodeBuilder.java @@ -33,6 +33,7 @@ import lombok.extern.slf4j.Slf4j; import org.onap.cps.spi.exceptions.DataValidationException; import org.onap.cps.utils.YangUtils; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; @@ -173,7 +174,9 @@ public class DataNodeBuilder { private static void addDataNodeFromNormalizedNode(final DataNode currentDataNode, final NormalizedNode normalizedNode) { - if (normalizedNode instanceof DataContainerNode) { + if (normalizedNode instanceof ChoiceNode) { + addChoiceNode(currentDataNode, (ChoiceNode) normalizedNode); + } else if (normalizedNode instanceof DataContainerNode) { addYangContainer(currentDataNode, (DataContainerNode) normalizedNode); } else if (normalizedNode instanceof MapNode) { addDataNodeForEachListElement(currentDataNode, (MapNode) normalizedNode); @@ -236,4 +239,13 @@ public class DataNodeBuilder { return newChildDataNode; } + private static void addChoiceNode(final DataNode currentDataNode, final ChoiceNode choiceNode) { + + final Collection<DataContainerChild> normalizedChildNodes = choiceNode.body(); + for (final NormalizedNode normalizedNode : normalizedChildNodes) { + addDataNodeFromNormalizedNode(currentDataNode, normalizedNode); + } + } + + } |