X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=portal-BE%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportal%2Fservice%2FCentralizedAppService.java;fp=portal-BE%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportal%2Fservice%2FCentralizedAppService.java;h=d4f3e0df0c800d5232c997965a7ce3ea1fbb5a45;hb=7929b78e2d59904a847f4498242a55096eb2dac8;hp=0000000000000000000000000000000000000000;hpb=457d999e8272aab60177ae2acfddb41cce1062dd;p=portal.git diff --git a/portal-BE/src/main/java/org/onap/portal/service/CentralizedAppService.java b/portal-BE/src/main/java/org/onap/portal/service/CentralizedAppService.java new file mode 100644 index 00000000..d4f3e0df --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/service/CentralizedAppService.java @@ -0,0 +1,29 @@ +package org.onap.portal.service; + +import java.util.List; +import javax.persistence.EntityManager; +import org.onap.portal.domain.dto.ecomp.CentralizedApp; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class CentralizedAppService { + + private final EntityManager entityManager; + + @Autowired + public CentralizedAppService(EntityManager entityManager) { + this.entityManager = entityManager; + } + + public List getCentralizedAppsOfUser(final String userId) { + String query = "select distinct fa.app_id, fa.app_name " + + "from fn_role fr, fn_user_role fur, fn_app fa, fn_user fu " + + "Where fu.user_id = fur.user_id and fur.role_id = fr.role_id and fa.app_id = fur.app_id " + + "and fu.org_user_id = :userId and (fur.role_id = 999 or fur.role_id = 1) and fr.active_yn='Y' and ((fa.enabled = 'Y' and fa.auth_central='Y') or fa.app_id =1)"; + + return entityManager.createQuery(query).getResultList(); + } +}