1 package org.onap.portal.service;
4 import javax.persistence.EntityManager;
5 import org.onap.portal.domain.dto.ecomp.CentralizedApp;
6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.stereotype.Service;
8 import org.springframework.transaction.annotation.Transactional;
12 public class CentralizedAppService {
14 private final EntityManager entityManager;
17 public CentralizedAppService(EntityManager entityManager) {
18 this.entityManager = entityManager;
21 public List<CentralizedApp> getCentralizedAppsOfUser(final String userId) {
22 String query = "select distinct fa.app_id, fa.app_name "
23 + "from fn_role fr, fn_user_role fur, fn_app fa, fn_user fu "
24 + "Where fu.user_id = fur.user_id and fur.role_id = fr.role_id and fa.app_id = fur.app_id "
25 + "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)";
27 return entityManager.createQuery(query).getResultList();