HealthCheckController up
[portal.git] / portal-BE / src / main / java / org / onap / portal / service / LocalRoleService.java
1 package org.onap.portal.service;
2
3 import java.util.List;
4 import javax.persistence.EntityManager;
5 import javax.transaction.Transactional;
6 import org.onap.portal.domain.dto.transport.LocalRole;
7 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.stereotype.Service;
9
10 @Service
11 @Transactional
12 public class LocalRoleService {
13
14     private final EntityManager entityManager;
15
16     @Autowired
17     public LocalRoleService(EntityManager entityManager) {
18         this.entityManager = entityManager;
19     }
20
21     public List<LocalRole> getCurrentAppRoleFunctions(final long appId, final String functionCd){
22         final String query = "select distinct fr.role_id, fr.role_name  from fn_role fr, ep_app_function ef, ep_app_role_function epr where fr.role_id = epr.role_id and epr.function_cd = ef.function_cd\n"
23             + " and ef.function_cd =:functionCd and epr.app_id =:appId";
24         return entityManager.createNamedQuery(query).setParameter("appId", appId).setParameter("functionCd", functionCd).getResultList();
25     }
26 }