2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
20 package org.openecomp.portalapp.portal.service;
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.TreeSet;
27 import org.openecomp.portalapp.portal.domain.EPApp;
28 import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
29 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
30 import org.openecomp.portalsdk.core.service.DataAccessService;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.context.annotation.EnableAspectJAutoProxy;
33 import org.springframework.stereotype.Service;
34 import org.springframework.transaction.annotation.Transactional;
36 @Service("epAppService")
38 @org.springframework.context.annotation.Configuration
39 @EnableAspectJAutoProxy
41 public class EPAppServiceImpl extends EPAppCommonServiceImpl implements EPAppService {
43 private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPAppServiceImpl.class);
46 private DataAccessService dataAccessService;
49 public List<EPApp> getUserRemoteApps(String id) {
51 StringBuilder query = new StringBuilder();
53 query.append("SELECT * FROM FN_APP join FN_USER_ROLE ON FN_USER_ROLE.APP_ID = FN_APP.APP_ID where ");
55 "FN_USER_ROLE.USER_ID = " + id + " AND FN_USER_ROLE.ROLE_ID != " + SUPER_ADMIN_ROLE_ID);
56 query.append(" AND FN_APP.ENABLED = 'Y'");
58 TreeSet<EPApp> distinctApps = new TreeSet<EPApp>();
60 @SuppressWarnings("unchecked")
61 List<EPApp> adminApps = dataAccessService.executeSQLQuery(query.toString(), EPApp.class, null);
62 for (EPApp app : adminApps) {
63 distinctApps.add(app);
66 List<EPApp> userApps = new ArrayList<EPApp>();
67 userApps.addAll(distinctApps);