use of org.openkilda.store.linkstore.dao.entity.LinkStoreRequestUrlsEntity in project open-kilda by telstra.
the class StoreService method saveOrUpdateLinkStoreConfig.
/**
* Save or update link store config.
*
* @param linkStoreConfigDto the link store config dto
*
* @return the link store config dto
*/
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public LinkStoreConfigDto saveOrUpdateLinkStoreConfig(final LinkStoreConfigDto linkStoreConfigDto) {
LOGGER.info("Save or update link store configuration");
saveOrUpdateStoreTypeEntity(StoreType.LINK_STORE.getCode());
List<LinkStoreRequestUrlsEntity> linkStoreRequestUrlsEntitiesList = new ArrayList<LinkStoreRequestUrlsEntity>();
List<LinkStoreRequestUrlsEntity> linkStoreRequestUrlsEntities = linkStoreRequestUrlsRepository.findAll();
for (Entry<String, UrlDto> urlEntrySet : linkStoreConfigDto.getUrls().entrySet()) {
if (linkStoreRequestUrlsEntities != null) {
LinkStoreRequestUrlsEntity linkStoreRequestUrlsEntity = null;
for (LinkStoreRequestUrlsEntity linkStoreRequestUrlsEntityObj : linkStoreRequestUrlsEntities) {
if (linkStoreRequestUrlsEntityObj.getUrlEntity().getName().equalsIgnoreCase(urlEntrySet.getValue().getName())) {
linkStoreRequestUrlsEntity = linkStoreRequestUrlsEntityObj;
break;
}
}
if (linkStoreRequestUrlsEntity == null) {
linkStoreRequestUrlsEntity = new LinkStoreRequestUrlsEntity();
}
linkStoreRequestUrlsEntity.setUrlEntity(UrlConverter.toUrlEntity(urlEntrySet.getKey(), urlEntrySet.getValue(), linkStoreRequestUrlsEntity.getUrlEntity()));
linkStoreRequestUrlsEntitiesList.add(linkStoreRequestUrlsEntity);
}
}
linkStoreRequestUrlsEntitiesList = linkStoreRequestUrlsRepository.save(linkStoreRequestUrlsEntitiesList);
Map<String, UrlDto> urls = new HashMap<String, UrlDto>();
for (LinkStoreRequestUrlsEntity linkStoreRequestUrlsEntity : linkStoreRequestUrlsEntitiesList) {
urls.put(linkStoreRequestUrlsEntity.getUrlEntity().getName(), UrlConverter.toUrlDto(linkStoreRequestUrlsEntity.getUrlEntity()));
}
linkStoreConfigDto.setUrls(urls);
return linkStoreConfigDto;
}
use of org.openkilda.store.linkstore.dao.entity.LinkStoreRequestUrlsEntity in project open-kilda by telstra.
the class StoreService method getLinkStoreConfig.
/**
* Gets the link store config.
*
* @return the link store config
*/
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public LinkStoreConfigDto getLinkStoreConfig() {
LOGGER.info("Get link store configuration");
LinkStoreConfigDto linkStoreConfigDto = new LinkStoreConfigDto();
List<LinkStoreRequestUrlsEntity> linkStoreRequestUrlsEntitiesList = linkStoreRequestUrlsRepository.findAll();
Map<String, UrlDto> urls = new HashMap<String, UrlDto>();
for (LinkStoreRequestUrlsEntity linkStoreRequestUrlsEntity : linkStoreRequestUrlsEntitiesList) {
urls.put(linkStoreRequestUrlsEntity.getUrlEntity().getName(), UrlConverter.toUrlDto(linkStoreRequestUrlsEntity.getUrlEntity()));
}
linkStoreConfigDto.setUrls(urls);
return linkStoreConfigDto;
}
use of org.openkilda.store.linkstore.dao.entity.LinkStoreRequestUrlsEntity in project open-kilda by telstra.
the class StoreService method getUrl.
/**
* Gets the url.
*
* @param storeType the store type
*
* @param url the url
*
* @return the url
*/
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public UrlDto getUrl(final StoreType storeType, final Url url) {
LOGGER.info("Get urls for store type");
UrlDto urlDto = null;
if (storeType == StoreType.LINK_STORE) {
LinkStoreRequestUrlsEntity urlsEntity = linkStoreRequestUrlsRepository.findByUrlEntity_name(url.getName());
urlDto = UrlConverter.toUrlDto(urlsEntity.getUrlEntity());
}
if (storeType == StoreType.SWITCH_STORE) {
SwitchStoreRequestUrlsEntity urlsEntity = switchStoreRequestUrlsRepository.findByUrlEntity_name(url.getName());
urlDto = UrlConverter.toUrlDto(urlsEntity.getUrlEntity());
}
return urlDto;
}
Aggregations