HealthCheckController up
[portal.git] / portal-BE / src / main / java / org / onap / portal / service / CentralizedAppService.java
1 package org.onap.portal.service;
2
3 import java.util.List;
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;
9
10 @Service
11 @Transactional
12 public class CentralizedAppService {
13
14     private final EntityManager entityManager;
15
16     @Autowired
17     public CentralizedAppService(EntityManager entityManager) {
18         this.entityManager = entityManager;
19     }
20
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)";
26
27         return entityManager.createQuery(query).getResultList();
28     }
29 }