X-Git-Url: https://gerrit.onap.org/r/gitweb?p=portal.git;a=blobdiff_plain;f=portal-BE%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportal%2Fservice%2Fep%2FEpWidgetCatalogParameterService.java;h=f2497f8555afac43c99ef604af7b02b05f170d1d;hp=8488e5adf02ff182d9c7bf327e65b484a67debfb;hb=e90cfa3b65b9879d22fc4522f45a22f1014e224e;hpb=f2805494b772201a94334e2c2f72315cacd8266b diff --git a/portal-BE/src/main/java/org/onap/portal/service/ep/EpWidgetCatalogParameterService.java b/portal-BE/src/main/java/org/onap/portal/service/ep/EpWidgetCatalogParameterService.java index 8488e5ad..f2497f85 100644 --- a/portal-BE/src/main/java/org/onap/portal/service/ep/EpWidgetCatalogParameterService.java +++ b/portal-BE/src/main/java/org/onap/portal/service/ep/EpWidgetCatalogParameterService.java @@ -42,13 +42,10 @@ package org.onap.portal.service.ep; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; +import javax.transaction.Transactional; import org.onap.portal.dao.ep.EpMicroserviceParameterDao; import org.onap.portal.dao.ep.EpWidgetCatalogParameterDao; -import org.onap.portal.dao.fn.EpWidgetCatalogDao; -import org.onap.portal.dao.fn.FnUserDao; import org.onap.portal.domain.db.ep.EpWidgetCatalogParameter; -import org.onap.portal.domain.dto.ecomp.WidgetCatalogParameter; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -60,23 +57,17 @@ public class EpWidgetCatalogParameterService { private final EpWidgetCatalogParameterDao epWidgetCatalogParameterDao; private final EpMicroserviceParameterDao epMicroserviceParameterDao; - private final EpWidgetCatalogDao epWidgetCatalogDao; - private final FnUserDao fnUserDao; @Autowired public EpWidgetCatalogParameterService( final EpWidgetCatalogParameterDao epWidgetCatalogParameterDao, - final EpMicroserviceParameterDao epMicroserviceParameterDao, - EpWidgetCatalogDao epWidgetCatalogDao, FnUserDao fnUserDao) { + final EpMicroserviceParameterDao epMicroserviceParameterDao) { this.epWidgetCatalogParameterDao = epWidgetCatalogParameterDao; this.epMicroserviceParameterDao = epMicroserviceParameterDao; - this.epWidgetCatalogDao = epWidgetCatalogDao; - this.fnUserDao = fnUserDao; } - public List getUserParameterById(Long paramId) { - return mapEpWidgetListToWidgetList( - epWidgetCatalogParameterDao.retrieveByParamId(paramId).orElse(new ArrayList<>())); + public List getUserParameterById(Long paramId) { + return epWidgetCatalogParameterDao.retrieveByParamId(paramId).orElse(new ArrayList<>()); } public void deleteUserParameterById(Long paramId) { @@ -84,11 +75,11 @@ public class EpWidgetCatalogParameterService { epMicroserviceParameterDao.deleteMicroserviceParameterById(paramId); } - public WidgetCatalogParameter getUserParamById(Long widgetId, Long userId, Long paramId) { - WidgetCatalogParameter widgetParam = null; - List list = mapEpWidgetListToWidgetList( - epWidgetCatalogParameterDao.getUserParamById(widgetId, userId, paramId) - .orElse(new ArrayList<>())); + public EpWidgetCatalogParameter getUserParamById(Long widgetId, Long userId, Long paramId) { + EpWidgetCatalogParameter widgetParam = null; + List list = epWidgetCatalogParameterDao + .getUserParamById(widgetId, userId, paramId) + .orElse(new ArrayList<>()); if (list.size() != 0) { widgetParam = list.get(0); } @@ -97,31 +88,8 @@ public class EpWidgetCatalogParameterService { return widgetParam; } - public void saveUserParameter(WidgetCatalogParameter newParameter) { - epWidgetCatalogParameterDao.saveAndFlush(mapToEpWidgetCatalogParameter(newParameter)); - } - - private EpWidgetCatalogParameter mapToEpWidgetCatalogParameter(WidgetCatalogParameter wcp){ - - return new EpWidgetCatalogParameter(wcp.getId(), epWidgetCatalogDao.findById(wcp.getWidgetId()).get(), - fnUserDao.findById(wcp.getUserId()).get(), - epMicroserviceParameterDao.findById(wcp.getParamId()).get(), - wcp.getUserValue()); - } - - private List mapToList(List list){ - return list.stream().map(this::mapToEpWidgetCatalogParameter).collect(Collectors.toList()); - } - - private WidgetCatalogParameter mapEpWidgetCatalogParametertoWidgetCatalogParameter( - EpWidgetCatalogParameter ewcp) { - return new WidgetCatalogParameter(ewcp.getId(), ewcp.getWidgetId().getWidgetId(), - ewcp.getUserId().getId(), ewcp.getParamId().getId(), ewcp.getUserValue()); - } - - private List mapEpWidgetListToWidgetList( - List epWidgetCatalogParameters) { - return epWidgetCatalogParameters.stream().map(this::mapEpWidgetCatalogParametertoWidgetCatalogParameter) - .collect(Collectors.toList()); + @Transactional + public void saveUserParameter(EpWidgetCatalogParameter newParameter) { + epWidgetCatalogParameterDao.save(newParameter); } }