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.kpidash.service;
22 import java.math.BigDecimal;
23 import java.util.ArrayList;
24 import java.util.List;
26 import org.openecomp.portalapp.kpidash.model.KpiApiStats;
27 import org.openecomp.portalapp.kpidash.model.KpiServiceSupported;
28 import org.openecomp.portalapp.kpidash.model.KpiUserStoryStats;
29 import org.openecomp.portalapp.kpidash.model.KpidashProperties;
30 import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
31 import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
32 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
33 import org.openecomp.portalsdk.core.service.DataAccessService;
34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.context.annotation.EnableAspectJAutoProxy;
36 import org.springframework.stereotype.Service;
37 import org.springframework.transaction.annotation.Transactional;
39 @SuppressWarnings("rawtypes")
40 @Service("kpiDashboardService")
42 @org.springframework.context.annotation.Configuration
43 @EnableAspectJAutoProxy
45 public class KpiDashboardServiceImpl implements KpiDashboardService {
47 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(KpiDashboardServiceImpl.class);
50 private DataAccessService dataAccessService;
53 public void saveUserStories(KpiUserStoryStats kpiUserStoryStats) {
54 dataAccessService.saveDomainObject(kpiUserStoryStats, null);
58 public void updateUserStories(KpiUserStoryStats kpiUserStoryStats) {
59 dataAccessService.saveDomainObject(kpiUserStoryStats, null);
63 public List getUserStories() {
64 return dataAccessService.getList(KpiUserStoryStats.class, null);
68 public List getUserApis() {
69 return dataAccessService.getList(KpiApiStats.class, null);
73 public void saveUserApis(KpiApiStats kpiApiStats) {
74 // TODO Auto-generated method stub
79 public void updateUserApis(KpiApiStats kpiApiStats) {
80 dataAccessService.saveDomainObject(kpiApiStats, null);
84 public List getKpiServiceSupported() {
85 return dataAccessService.getList(KpiServiceSupported.class, null);
89 public List<String> executeGetBytesPublishedDelivered() {
90 List list = dataAccessService.executeNamedQuery("getBytesPublishedDelivered", null, null);
91 List<String> newStringList = new ArrayList<String>();
92 if (list != null && list.size() > 0) {
93 Object[] retunVals = (Object[]) list.get(0); // current entry in
95 newStringList.add((String) retunVals[0]);
96 newStringList.add((String) retunVals[1]);
102 public List<Long> executeGetFeedStats() {
103 List list = dataAccessService.executeNamedQuery("getDataRouterFeedStats", null, null);
104 List<Long> newLongList = new ArrayList<Long>();
105 if (list != null && list.size() > 0) {
106 Object[] retunVals = (Object[]) list.get(0); // current entry in
108 newLongList.add((Long) retunVals[0]);
109 newLongList.add((Long) retunVals[1]);
110 newLongList.add((Long) retunVals[2]);
116 public List<String> getLOCStatsCat() {
117 List list = dataAccessService.executeNamedQuery("getLOCStatsCat", null, null);
118 List<String> newStringList = new ArrayList<String>();
119 if (list != null && list.size() > 0) {
120 for (int i = 0; i < list.size(); i++) {
121 /* Object[] retunVals = (Object[]) list.get(i); */// current
125 newStringList.add((String) list.get(i));
128 return newStringList;
132 public List<Long> getLOCStats() {
133 List list = dataAccessService.executeNamedQuery("getLOCStats", null, null);
134 List<Long> newLongList = new ArrayList<Long>();
135 if (list != null && list.size() > 0) {
136 for (int i = 0; i < list.size(); i++) {
137 /* Object[] retunVals = (Object[]) list.get(i); */// current
141 newLongList.add(((BigDecimal) list.get(i)).longValue());
148 public String getGeoMapUrl() {
151 newURL = KpidashProperties.getProperty(KpidashProperties.GEO_MAP_URL);
152 } catch (Exception e) {
153 logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e));
159 public String getRCloudAUrl() {
162 newURL = KpidashProperties.getProperty(KpidashProperties.RCLOUD_A_URL);
163 } catch (Exception e) {
164 logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e));
170 public String getGeoMapApiUrl() {
173 newURL = KpidashProperties.getProperty(KpidashProperties.GEO_API_URL);
174 } catch (Exception e) {
175 logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e));