@Test public void testConvertToAlarmEntity() { Timestamp raisedTime = new Timestamp(System.currentTimeMillis()); AlarmInfo info = new AlarmInfo(QName.create("namespace", "hello").toString(), MODEL_NODE_ID, raisedTime, AlarmSeverity.MAJOR, DB_ID, null); Alarm alarm = AlarmUtil.convertToAlarmEntity(info, DB_ID); assertEquals(info.getTime(), alarm.getRaisedTime()); assertEquals(info.getAlarmText(), alarm.getAlarmText()); assertEquals(info.getSeverity(), alarm.getSeverity()); assertEquals(DB_ID, alarm.getSourceObject()); }
public static Alarm convertToAlarmEntity(AlarmInfo alarmInfo, String dbId) { Alarm alarmEntity = new Alarm(); if (alarmInfo.getSourceObject() != null) { alarmEntity.setSourceObject(dbId); alarmEntity.setYangResource(true); String sourceObjectNamespaces = alarmInfo.getSourceObjectNamespaces(); if (sourceObjectNamespaces != null) { alarmEntity.setResourceNamespaces(sourceObjectNamespaces); alarmEntity.setResourceName(alarmInfo.getSourceObjectString()); } } else { alarmEntity.setSourceObject(alarmInfo.getSourceObjectString()); alarmEntity.setYangResource(false); } alarmEntity.setAlarmTypeId(alarmInfo.getAlarmTypeId()); alarmEntity.setAlarmTypeQualifier(alarmInfo.getAlarmTypeQualifier()); alarmEntity.setRaisedTime(alarmInfo.getTime()); alarmEntity.setSeverity(alarmInfo.getSeverity()); alarmEntity.setAlarmText(alarmInfo.getAlarmText()); alarmEntity.setDeviceId(alarmInfo.getDeviceName()); return alarmEntity; }
AlarmUtil { public static Alarm convertToAlarmEntity(AlarmInfo alarmInfo, String dbId) { Alarm alarmEntity = new Alarm(); if (alarmInfo.getSourceObject() != null) { alarmEntity.setSourceObject(dbId); alarmEntity.setYangResource(true); String sourceObjectNamespaces = alarmInfo.getSourceObjectNamespaces(); if (sourceObjectNamespaces != null) { alarmEntity.setResourceNamespaces(sourceObjectNamespaces); alarmEntity.setResourceName(alarmInfo.getSourceObjectString()); } } else { alarmEntity.setSourceObject(alarmInfo.getSourceObjectString()); alarmEntity.setYangResource(false); } alarmEntity.setAlarmTypeId(alarmInfo.getAlarmTypeId()); alarmEntity.setAlarmTypeQualifier(alarmInfo.getAlarmTypeQualifier()); alarmEntity.setRaisedTime(alarmInfo.getTime()); alarmEntity.setSeverity(alarmInfo.getSeverity()); alarmEntity.setAlarmText(alarmInfo.getAlarmText()); alarmEntity.setDeviceId(alarmInfo.getDeviceName()); return alarmEntity; } }
AlarmUtil { public static Alarm convertToAlarmEntity(AlarmInfo alarmInfo, String dbId) { Alarm alarmEntity = new Alarm(); if (alarmInfo.getSourceObject() != null) { alarmEntity.setSourceObject(dbId); alarmEntity.setYangResource(true); String sourceObjectNamespaces = alarmInfo.getSourceObjectNamespaces(); if (sourceObjectNamespaces != null) { alarmEntity.setResourceNamespaces(sourceObjectNamespaces); alarmEntity.setResourceName(alarmInfo.getSourceObjectString()); } } else { alarmEntity.setSourceObject(alarmInfo.getSourceObjectString()); alarmEntity.setYangResource(false); } alarmEntity.setAlarmTypeId(alarmInfo.getAlarmTypeId()); alarmEntity.setAlarmTypeQualifier(alarmInfo.getAlarmTypeQualifier()); alarmEntity.setRaisedTime(alarmInfo.getTime()); alarmEntity.setSeverity(alarmInfo.getSeverity()); alarmEntity.setAlarmText(alarmInfo.getAlarmText()); alarmEntity.setDeviceId(alarmInfo.getDeviceName()); return alarmEntity; } private  AlarmUtil(); }
AlarmUtil { public static Alarm convertToAlarmEntity(AlarmInfo alarmInfo, String dbId) { Alarm alarmEntity = new Alarm(); if (alarmInfo.getSourceObject() != null) { alarmEntity.setSourceObject(dbId); alarmEntity.setYangResource(true); String sourceObjectNamespaces = alarmInfo.getSourceObjectNamespaces(); if (sourceObjectNamespaces != null) { alarmEntity.setResourceNamespaces(sourceObjectNamespaces); alarmEntity.setResourceName(alarmInfo.getSourceObjectString()); } } else { alarmEntity.setSourceObject(alarmInfo.getSourceObjectString()); alarmEntity.setYangResource(false); } alarmEntity.setAlarmTypeId(alarmInfo.getAlarmTypeId()); alarmEntity.setAlarmTypeQualifier(alarmInfo.getAlarmTypeQualifier()); alarmEntity.setRaisedTime(alarmInfo.getTime()); alarmEntity.setSeverity(alarmInfo.getSeverity()); alarmEntity.setAlarmText(alarmInfo.getAlarmText()); alarmEntity.setDeviceId(alarmInfo.getDeviceName()); return alarmEntity; } 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 Alarm convertToAlarmEntity(AlarmInfo alarmInfo, String dbId) { Alarm alarmEntity = new Alarm(); if (alarmInfo.getSourceObject() != null) { alarmEntity.setSourceObject(dbId); alarmEntity.setYangResource(true); String sourceObjectNamespaces = alarmInfo.getSourceObjectNamespaces(); if (sourceObjectNamespaces != null) { alarmEntity.setResourceNamespaces(sourceObjectNamespaces); alarmEntity.setResourceName(alarmInfo.getSourceObjectString()); } } else { alarmEntity.setSourceObject(alarmInfo.getSourceObjectString()); alarmEntity.setYangResource(false); } alarmEntity.setAlarmTypeId(alarmInfo.getAlarmTypeId()); alarmEntity.setAlarmTypeQualifier(alarmInfo.getAlarmTypeQualifier()); alarmEntity.setRaisedTime(alarmInfo.getTime()); alarmEntity.setSeverity(alarmInfo.getSeverity()); alarmEntity.setAlarmText(alarmInfo.getAlarmText()); alarmEntity.setDeviceId(alarmInfo.getDeviceName()); return alarmEntity; } 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);  }