nexus site path corrected
[portal.git] / ecomp-portal-BE / src / main / java / org / openecomp / portalapp / kpidash / service / KpiDashboardServiceImpl.java
1 /*-
2  * ================================================================================
3  * eCOMP Portal
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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  * ================================================================================
19  */
20 package org.openecomp.portalapp.kpidash.service;
21
22 import java.math.BigDecimal;
23 import java.util.ArrayList;
24 import java.util.List;
25
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;
38
39 @SuppressWarnings("rawtypes")
40 @Service("kpiDashboardService")
41 @Transactional
42 @org.springframework.context.annotation.Configuration
43 @EnableAspectJAutoProxy
44 @EPMetricsLog
45 public class KpiDashboardServiceImpl implements KpiDashboardService {
46
47         EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(KpiDashboardServiceImpl.class);
48         
49         @Autowired
50         private DataAccessService dataAccessService;
51
52         @Override
53         public void saveUserStories(KpiUserStoryStats kpiUserStoryStats) {
54                 dataAccessService.saveDomainObject(kpiUserStoryStats, null);
55         }
56
57         @Override
58         public void updateUserStories(KpiUserStoryStats kpiUserStoryStats) {
59                 dataAccessService.saveDomainObject(kpiUserStoryStats, null);
60         }
61
62         @Override
63         public List getUserStories() {
64                 return dataAccessService.getList(KpiUserStoryStats.class, null);
65         }
66
67         @Override
68         public List getUserApis() {
69                 return dataAccessService.getList(KpiApiStats.class, null);
70         }
71
72         @Override
73         public void saveUserApis(KpiApiStats kpiApiStats) {
74                 // TODO Auto-generated method stub
75
76         }
77
78         @Override
79         public void updateUserApis(KpiApiStats kpiApiStats) {
80                 dataAccessService.saveDomainObject(kpiApiStats, null);
81         }
82
83         @Override
84         public List getKpiServiceSupported() {
85                 return dataAccessService.getList(KpiServiceSupported.class, null);
86         }
87
88         @Override
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
94                                                                                                                         // VSPEntAdmin table
95                         newStringList.add((String) retunVals[0]);
96                         newStringList.add((String) retunVals[1]);
97                 }
98                 return newStringList;
99         }
100
101         @Override
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
107                                                                                                                         // VSPEntAdmin table
108                         newLongList.add((Long) retunVals[0]);
109                         newLongList.add((Long) retunVals[1]);
110                         newLongList.add((Long) retunVals[2]);
111                 }
112                 return newLongList;
113         }
114
115         @Override
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
122                                                                                                                                         // entry in
123                                                                                                                                         // VSPEntAdmin
124                                                                                                                                         // table
125                                 newStringList.add((String) list.get(i));
126                         }
127                 }
128                 return newStringList;
129         };
130
131         @Override
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
138                                                                                                                                         // entry in
139                                                                                                                                         // VSPEntAdmin
140                                                                                                                                         // table
141                                 newLongList.add(((BigDecimal) list.get(i)).longValue());
142                         }
143                 }
144                 return newLongList;
145         };
146
147         @Override
148         public String getGeoMapUrl() {
149                 String newURL = "";
150                 try {
151                         newURL = KpidashProperties.getProperty(KpidashProperties.GEO_MAP_URL);
152                 } catch (Exception e) {
153                         logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e));
154                 }
155                 return newURL;
156         }
157
158         @Override
159         public String getRCloudAUrl() {
160                 String newURL = "";
161                 try {
162                         newURL = KpidashProperties.getProperty(KpidashProperties.RCLOUD_A_URL);
163                 } catch (Exception e) {
164                         logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e));
165                 }
166                 return newURL;
167         }
168
169         @Override
170         public String getGeoMapApiUrl() {
171                 String newURL = "";
172                 try {
173                         newURL = KpidashProperties.getProperty(KpidashProperties.GEO_API_URL);
174                 } catch (Exception e) {
175                         logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e));
176                 }
177                 return newURL;
178         }
179
180 }