use of org.openkilda.dao.entity.SwitchNameEntity in project open-kilda by telstra.
the class SwitchIntegrationService method getCustomSwitchNameFromDatabase.
/**
* Gets the custom switch name from database.
*
* @return the custom switch name from database
*/
public Map<String, String> getCustomSwitchNameFromDatabase() {
Map<String, String> csNames = new HashMap<String, String>();
List<SwitchNameEntity> switchNames = switchNameRepository.findAll();
for (SwitchNameEntity name : switchNames) {
csNames.put(name.getSwitchDpid(), name.getSwitchName());
}
return csNames;
}
use of org.openkilda.dao.entity.SwitchNameEntity in project open-kilda by telstra.
the class SwitchService method saveOrUpdateSwitchName.
/**
* Save or update switch name.
*
* @param switchId the switch id
* @param switchName the switch name
* @return the SwitchInfo
*/
public SwitchInfo saveOrUpdateSwitchName(String switchId, String switchName) {
String storageType = applicationSettingService.getApplicationSetting(ApplicationSetting.SWITCH_NAME_STORAGE_TYPE);
if (storageType.equals(IConstants.StorageType.DATABASE_STORAGE.name())) {
SwitchNameEntity switchNameEntity = switchNameRepository.findBySwitchDpid(switchId);
if (switchNameEntity == null) {
switchNameEntity = new SwitchNameEntity();
}
switchNameEntity.setSwitchDpid(switchId);
switchNameEntity.setSwitchName(switchName);
switchNameEntity.setUpdatedDate(new Date());
switchNameRepository.save(switchNameEntity);
SwitchInfo switchInfo = new SwitchInfo();
switchInfo.setSwitchId(switchId);
switchInfo.setName(switchName);
return switchInfo;
} else {
throw new RequestValidationException("Storage-Type in Application Settings is not Database, " + "so switch name can not be updated");
}
}
Aggregations