X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=portal-BE%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportal%2Fservice%2FappFunction%2FEpAppFunctionService.java;fp=portal-BE%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportal%2Fservice%2FappFunction%2FEpAppFunctionService.java;h=23fd675eacf4167938df66089f1e7dad9a5b1e7a;hb=ca3d9f4b725774763f12488940033a294b778244;hp=aa5e258a8ed59fcc72f1798f9f43501caf6a94f8;hpb=4c6f6a443cb2e6effa995e77d56689c1c2dab4ad;p=portal.git diff --git a/portal-BE/src/main/java/org/onap/portal/service/appFunction/EpAppFunctionService.java b/portal-BE/src/main/java/org/onap/portal/service/appFunction/EpAppFunctionService.java index aa5e258a..23fd675e 100644 --- a/portal-BE/src/main/java/org/onap/portal/service/appFunction/EpAppFunctionService.java +++ b/portal-BE/src/main/java/org/onap/portal/service/appFunction/EpAppFunctionService.java @@ -45,8 +45,8 @@ import java.util.List; import java.util.Optional; import java.util.function.Function; import java.util.function.Predicate; -import java.util.stream.Collectors; +import javax.persistence.EntityManager; import org.onap.portal.domain.db.ep.EpAppFunction; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -55,21 +55,21 @@ import org.springframework.stereotype.Service; public class EpAppFunctionService { private final EpAppFunctionDao epAppFunctionDao; + private final EntityManager entityManager; @Autowired - public EpAppFunctionService(EpAppFunctionDao epAppFunctionDao) { + public EpAppFunctionService(final EpAppFunctionDao epAppFunctionDao,final EntityManager entityManager) { this.epAppFunctionDao = epAppFunctionDao; + this.entityManager = entityManager; } public List getAppRoleFunctionList(final Long roleId, final Long appId) { - return Optional.of(epAppFunctionDao.getAppRoleFunctionList(roleId, appId)) - .orElse(new ArrayList<>()) - .stream() - .filter(distinctByKey(EpAppFunction::getAppId)) - .filter(distinctByKey(EpAppFunction::getFunctionCd)) - .filter(distinctByKey(EpAppFunction::getFunctionName)) - .collect(Collectors.toList()); + .orElse(new ArrayList<>()); + } + + public Optional getForId(Long id){ + return epAppFunctionDao.findById(id); } private Predicate distinctByKey(Function keyExtractor) { @@ -77,7 +77,34 @@ public class EpAppFunctionService { return t -> seen.add(keyExtractor.apply(t)); } + public EpAppFunction save(final EpAppFunction epAppFunction){ + return epAppFunctionDao.save(epAppFunction); + } + public List saveAll(List epAppFunctions) { return epAppFunctionDao.saveAll(epAppFunctions); } + + public List getAllRoleFunctions(final Long appId){ + return epAppFunctionDao.getAllRoleFunctions(appId).orElse(new ArrayList<>()); + } + + public List getAppFunctionOnCodeAndAppId(final long appId, final String functionCd) { + return epAppFunctionDao.getAppFunctionOnCodeAndAppId(appId, functionCd); + } + + public List getRoleFunction(final String functionCd, final long appId) { + return epAppFunctionDao.getRoleFunction(functionCd, appId); + } + + public void deleteOne(EpAppFunction function){ + epAppFunctionDao.delete(function); + } + + public void deleteByAppIdAndFunctionCd(Long appId, String functionCd) { + entityManager.createQuery("DELETE FROM ep_app_function WHERE app_id = :appId and function_cd = :functionCd") + .setParameter("appId", appId) + .setParameter("functionCd", functionCd) + .executeUpdate(); + } }