Device dev = getDevice(did); DeviceDescription desc = (dev == null) ? null : BasicDeviceOperator.descriptionOf(dev); desc = BasicDeviceOperator.combine(cfg, desc); if (desc != null && dp != null) { de = store.createOrUpdateDevice(dp.id(), did, desc); Device dev = getDevice(did); DeviceDescription desc = (dev == null) ? null : BasicDeviceOperator.descriptionOf(dev); Optional<Config> prevConfig = event.prevConfig(); desc = deviceAnnotationOp.combine(did, desc, prevConfig);
deviceDescription = BasicDeviceOperator.combine(cfg, deviceDescription); DeviceAnnotationConfig annoConfig = networkConfigService.getConfig(deviceId, DeviceAnnotationConfig.class); if (annoConfig != null) {
/** * Generates an annotation from an existing annotation and DeviceConfig. * * @param cfg the device config entity from network config * @param an the annotation * @return annotation combining both sources */ public static SparseAnnotations combine(BasicDeviceConfig cfg, SparseAnnotations an) { DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); builder.putAll(an); if (!Objects.equals(cfg.driver(), an.value(AnnotationKeys.DRIVER))) { builder.set(AnnotationKeys.DRIVER, cfg.driver()); } combineElementAnnotations(cfg, builder); if (cfg.managementAddress() != null) { builder.set(AnnotationKeys.MANAGEMENT_ADDRESS, cfg.managementAddress()); } return builder.build(); }
SparseAnnotations sa = combine(cfg, descr.annotations()); return new DefaultDeviceDescription(descr.deviceUri(), type, manufacturer, hwVersion, swVersion,