X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ncmp-service%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fcps%2Fncmp%2Fapi%2Fimpl%2Futils%2FYangDataConverter.java;h=1b190759ee68d6f2e5f457c0d214d358ba3dbb68;hb=7bacf478fc69fb97d2abf29c4678552f58575b74;hp=f8e06593c5b068fd5ac0e0e4f905c6c928c165b6;hpb=ef200d43e3d2dc2be292bd76a8963cbb711247e7;p=cps.git diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java index f8e06593c..1b190759e 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java @@ -30,9 +30,9 @@ import java.util.regex.Pattern; import lombok.AccessLevel; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.onap.cps.ncmp.api.impl.inventory.CompositeState; +import org.onap.cps.ncmp.api.impl.inventory.CompositeStateBuilder; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; -import org.onap.cps.ncmp.api.inventory.CompositeState; -import org.onap.cps.ncmp.api.inventory.CompositeStateBuilder; import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle; import org.onap.cps.spi.model.DataNode; @@ -90,40 +90,6 @@ public class YangDataConverter { ); } - /** - * This method convert cm handle data node to yang model cm handle without using NcmpServiceCmHandle. - * - * @param cmHandleDataNode the datanode of the cm handle - * @param cmHandleId the id of the cm handle - * @return yang model cm handle - */ - public static YangModelCmHandle convertCmHandleToYangModelWithoutNcmpServiceCmHandle( - final DataNode cmHandleDataNode, - final String cmHandleId) { - final Map dmiProperties = new LinkedHashMap<>(); - final Map publicProperties = new LinkedHashMap<>(); - final CompositeStateBuilder compositeStateBuilder = new CompositeStateBuilder(); - CompositeState compositeState = compositeStateBuilder.build(); - for (final DataNode childDataNode : cmHandleDataNode.getChildDataNodes()) { - if (childDataNode.getXpath().contains("/additional-properties[@name=")) { - addProperty(childDataNode, dmiProperties); - } else if (childDataNode.getXpath().contains("/public-properties[@name=")) { - addProperty(childDataNode, publicProperties); - } else if (childDataNode.getXpath().endsWith("/state")) { - compositeState = compositeStateBuilder.fromDataNode(childDataNode).build(); - } - } - return YangModelCmHandle.toYangModelCmHandleWithoutNcmpServiceHandle( - (String) cmHandleDataNode.getLeaves().get("dmi-service-name"), - (String) cmHandleDataNode.getLeaves().get("dmi-data-service-name"), - (String) cmHandleDataNode.getLeaves().get("dmi-model-service-name"), - cmHandleId, - dmiProperties, - publicProperties, - compositeState - ); - } - /** * This method convert cm handle data nodes to yang model cm handles. * @param cmHandleDataNodes the datanode of the cm handle @@ -134,21 +100,15 @@ public class YangDataConverter { final Collection yangModelCmHandles = new ArrayList<>(cmHandleDataNodes.size()); cmHandleDataNodes.forEach(dataNode -> { final String cmHandleId = extractCmHandleIdFromXpath(dataNode.getXpath()); - if (cmHandleId != null) { - yangModelCmHandles.add(convertCmHandleToYangModelWithoutNcmpServiceCmHandle(dataNode, cmHandleId)); - } + yangModelCmHandles.add(convertCmHandleToYangModel(dataNode, cmHandleId)); }); return yangModelCmHandles; } private static String extractCmHandleIdFromXpath(final String xpath) { final Matcher matcher = cmHandleIdInXpathPattern.matcher(xpath); - if (matcher.find()) { - return matcher.group(1); - } else { - log.error("Unexpected xpath {}", xpath); - } - return null; + matcher.find(); + return matcher.group(1); }