@Test public void testToNodeIdUsingNodeElement() throws NetconfMessageBuilderException { String alarmElement = "<alarms:alarm xmlns:alarms=\"urn:ietf:params:xml:ns:yang:ietf-alarms\">" + "<alarms:resource xmlns:if=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\" xmlns:baa=\"http: + "xmlns:adh=\"http: + "/adh:device[adh:ID='R1.S1.LT1.P1.ONT1']/adh:device-specific-data/if:interfaces/if:interface[if:name='xdsl-line:1/1/1/1']</alarms:resource>" + "</alarms:alarm>"; Element element = DocumentUtils.stringToDocument(alarmElement).getDocumentElement(); ModelNodeId actualNodeId = AlarmUtil.toNodeIdUsingNodeElement(DB_ID_WITH_INTF, (Element) element.getChildNodes().item(0)); assertEquals(INTF_MODEL_NODE_ID, actualNodeId); }
public static ModelNodeId toNodeIdUsingNodeElement(String dbId, Element element) { ModelNodeId modelNodeId = new ModelNodeId(); String moduleNamespace = null; LocationPath locationPath = AlarmUtil.buildLocationPath(dbId); Step[] steps = locationPath.getSteps(); for (Step stepNode : steps) { moduleNamespace = buildNodeIdUsingNodeElement(element, null, modelNodeId, stepNode, moduleNamespace); Expression[] predicates = stepNode.getPredicates(); if (predicates != null) { for (int predicateCount = 0; predicateCount < predicates.length; predicateCount++) { moduleNamespace = buildNodeIdUsingNodeElement(element, null, modelNodeId, predicates[predicateCount], moduleNamespace); } } } return modelNodeId; }
AlarmUtil { public static ModelNodeId toNodeIdUsingNodeElement(String dbId, Element element) { ModelNodeId modelNodeId = new ModelNodeId(); String moduleNamespace = null; LocationPath locationPath = AlarmUtil.buildLocationPath(dbId); Step[] steps = locationPath.getSteps(); for (Step stepNode : steps) { moduleNamespace = buildNodeIdUsingNodeElement(element, null, modelNodeId, stepNode, moduleNamespace); Expression[] predicates = stepNode.getPredicates(); if (predicates != null) { for (int predicateCount = 0; predicateCount < predicates.length; predicateCount++) { moduleNamespace = buildNodeIdUsingNodeElement(element, null, modelNodeId, predicates[predicateCount], moduleNamespace); } } } return modelNodeId; } }
AlarmUtil { public static ModelNodeId toNodeIdUsingNodeElement(String dbId, Element element) { ModelNodeId modelNodeId = new ModelNodeId(); String moduleNamespace = null; LocationPath locationPath = AlarmUtil.buildLocationPath(dbId); Step[] steps = locationPath.getSteps(); for (Step stepNode : steps) { moduleNamespace = buildNodeIdUsingNodeElement(element, null, modelNodeId, stepNode, moduleNamespace); Expression[] predicates = stepNode.getPredicates(); if (predicates != null) { for (int predicateCount = 0; predicateCount < predicates.length; predicateCount++) { moduleNamespace = buildNodeIdUsingNodeElement(element, null, modelNodeId, predicates[predicateCount], moduleNamespace); } } } return modelNodeId; } private  AlarmUtil(); }
AlarmUtil { public static ModelNodeId toNodeIdUsingNodeElement(String dbId, Element element) { ModelNodeId modelNodeId = new ModelNodeId(); String moduleNamespace = null; LocationPath locationPath = AlarmUtil.buildLocationPath(dbId); Step[] steps = locationPath.getSteps(); for (Step stepNode : steps) { moduleNamespace = buildNodeIdUsingNodeElement(element, null, modelNodeId, stepNode, moduleNamespace); Expression[] predicates = stepNode.getPredicates(); if (predicates != null) { for (int predicateCount = 0; predicateCount < predicates.length; predicateCount++) { moduleNamespace = buildNodeIdUsingNodeElement(element, null, modelNodeId, predicates[predicateCount], moduleNamespace); } } } return modelNodeId; } private  AlarmUtil(); static Step[] splitXpathByJXPath(String xPath); static Map<String, Pair<String, SchemaRegistry>> getPrefixToNsMap(ModelNodeId modelNodeId, ModelNodeDataStoreManager dsm,
                                                                             SchemaRegistry schemaRegistry, String mountKey); static ModelNodeId toNodeIdUsingNodeElement(String dbId, Element element); static ModelNodeId toNodeIdUsingRegistry(String dbId, SchemaRegistry registry); static Alarm convertToAlarmEntity(AlarmInfo alarmInfo, String dbId); static List<AlarmInfo> convertAlarmToAlarmInfoList(List<Alarm> existingBaaAlarms, SchemaRegistry schemaRegistry,
                                                              ModelNodeDataStoreManager dsm); static String xPathAlarmString(Map<String, Pair<String, SchemaRegistry>> prefixToNsMap, ModelNodeId modelNodeId); static String toDbId(SchemaRegistry schemaRegistry, ModelNodeDataStoreManager dsm, ModelNodeId modelNodeId,
                                Map<String, Pair<String, SchemaRegistry>> prefixToNsMap); static QName getNodeName(Step stepNode); static ModelNodeId toNodeId(SchemaRegistry schemaRegistry, ModelNodeDataStoreManager dsm, String dbId,
                                       String mountRegistryKey); static ModelNodeId toNodeId(SchemaRegistry schemaRegistry, ModelNodeDataStoreManager dsm, String dbId); static String xPathString(Map<String, Pair<String, SchemaRegistry>> prefixToNsMap, NamespaceContext nsContext,
                                     ModelNodeId modelNodeId); }
AlarmUtil { public static ModelNodeId toNodeIdUsingNodeElement(String dbId, Element element) { ModelNodeId modelNodeId = new ModelNodeId(); String moduleNamespace = null; LocationPath locationPath = AlarmUtil.buildLocationPath(dbId); Step[] steps = locationPath.getSteps(); for (Step stepNode : steps) { moduleNamespace = buildNodeIdUsingNodeElement(element, null, modelNodeId, stepNode, moduleNamespace); Expression[] predicates = stepNode.getPredicates(); if (predicates != null) { for (int predicateCount = 0; predicateCount < predicates.length; predicateCount++) { moduleNamespace = buildNodeIdUsingNodeElement(element, null, modelNodeId, predicates[predicateCount], moduleNamespace); } } } return modelNodeId; } private  AlarmUtil(); static Step[] splitXpathByJXPath(String xPath); static Map<String, Pair<String, SchemaRegistry>> getPrefixToNsMap(ModelNodeId modelNodeId, ModelNodeDataStoreManager dsm,
                                                                             SchemaRegistry schemaRegistry, String mountKey); static ModelNodeId toNodeIdUsingNodeElement(String dbId, Element element); static ModelNodeId toNodeIdUsingRegistry(String dbId, SchemaRegistry registry); static Alarm convertToAlarmEntity(AlarmInfo alarmInfo, String dbId); static List<AlarmInfo> convertAlarmToAlarmInfoList(List<Alarm> existingBaaAlarms, SchemaRegistry schemaRegistry,
                                                              ModelNodeDataStoreManager dsm); static String xPathAlarmString(Map<String, Pair<String, SchemaRegistry>> prefixToNsMap, ModelNodeId modelNodeId); static String toDbId(SchemaRegistry schemaRegistry, ModelNodeDataStoreManager dsm, ModelNodeId modelNodeId,
                                Map<String, Pair<String, SchemaRegistry>> prefixToNsMap); static QName getNodeName(Step stepNode); static ModelNodeId toNodeId(SchemaRegistry schemaRegistry, ModelNodeDataStoreManager dsm, String dbId,
                                       String mountRegistryKey); static ModelNodeId toNodeId(SchemaRegistry schemaRegistry, ModelNodeDataStoreManager dsm, String dbId); static String xPathString(Map<String, Pair<String, SchemaRegistry>> prefixToNsMap, NamespaceContext nsContext,
                                     ModelNodeId modelNodeId);  }