public DeviceTypeVO convertTo() { DeviceTypeVO deviceTypeVO = new DeviceTypeVO(); deviceTypeVO.setName(name); deviceTypeVO.setDescription(description); return deviceTypeVO; } }
@Transactional public DeviceTypeVO createOrUpdateDeviceTypeByUser(UserVO user) { DeviceTypeVO deviceTypeVO = new DeviceTypeVO(); deviceTypeVO.setName(user.getLogin()); deviceTypeVO.setDescription(String.format("User %s default device type", user.getLogin())); return createOrUpdateDeviceTypeByUser(Optional.ofNullable(deviceTypeVO), user); }
@Transactional public DeviceTypeVO update(@NotNull Long deviceTypeId, DeviceTypeUpdate deviceTypeUpdate) { DeviceTypeVO existing = deviceTypeDao.find(deviceTypeId); if (existing == null) { throw new NoSuchElementException(String.format(Messages.DEVICE_TYPE_NOT_FOUND, deviceTypeId)); } if (deviceTypeUpdate.getName().isPresent()) { existing.setName(deviceTypeUpdate.getName().get()); } if (deviceTypeUpdate.getDescription().isPresent()) { existing.setDescription(deviceTypeUpdate.getDescription().get()); } hiveValidator.validate(existing); return deviceTypeDao.merge(existing); }
public static DeviceTypeVO convertDeviceType(DeviceType deviceType) { if (deviceType != null) { DeviceTypeVO vo = new DeviceTypeVO(); vo.setId(deviceType.getId()); vo.setName(deviceType.getName()); vo.setDescription(deviceType.getDescription()); vo.setEntityVersion(deviceType.getEntityVersion()); return vo; } return null; }