diff options
author | 2017-02-07 15:03:57 -0500 | |
---|---|---|
committer | 2017-02-07 15:05:15 -0500 | |
commit | 4ad39a5c96dd99acf819ce189b13fec946d7506b (patch) | |
tree | a1449286441947cc3d07a45227fa0d6f978e1a7d /ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash | |
parent | 5500448cbd1f374d0ac743ee2fd636fe2d3c0027 (diff) |
Initial OpenECOMP Portal commit
Change-Id: I804b80e0830c092e307da1599bd9fbb5c3e2da77
Signed-off-by: talasila <talasila@research.att.com>
Diffstat (limited to 'ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash')
7 files changed, 778 insertions, 0 deletions
diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/controller/KpiDashboardController.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/controller/KpiDashboardController.java new file mode 100644 index 00000000..b3a4f0cb --- /dev/null +++ b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/controller/KpiDashboardController.java @@ -0,0 +1,268 @@ +/*- + * ================================================================================ + * eCOMP Portal + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +package org.openecomp.portalapp.kpidash.controller; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.portalapp.controller.EPRestrictedBaseController; +import org.openecomp.portalapp.kpidash.model.KpiApiStats; +import org.openecomp.portalapp.kpidash.model.KpiServiceSupported; +import org.openecomp.portalapp.kpidash.model.KpiUserStoryStats; +import org.openecomp.portalapp.kpidash.service.KpiDashboardService; +import org.openecomp.portalapp.portal.domain.EPUser; +import org.openecomp.portalapp.portal.logging.aop.EPAuditLog; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalapp.util.EPUserUtils; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@RestController +//@RequestMapping("/") +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPAuditLog +//public class KpiDashboardController extends EPUnRestrictedBaseController { +public class KpiDashboardController extends EPRestrictedBaseController { + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(KpiDashboardController.class); + + @Autowired + KpiDashboardService service; + + @SuppressWarnings("unchecked") + @RequestMapping(value = { "/portalApi/get_user_stories_stats" }, method = RequestMethod.GET, produces = "application/json") + public List<KpiUserStoryStats> getUserStories(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List<KpiUserStoryStats> userStories = null; + + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserApps"); + } else { + userStories = (List<KpiUserStoryStats>) service.getUserStories(); + EcompPortalUtils.logAndSerializeObject("/portalApi/get_user_stories_stats", "GET result =", userStories); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing getUserApps operation, Details: " + EcompPortalUtils.getStackTrace(e)); + } + return userStories; + } + + @RequestMapping(value = { "/portalApi/save_user_stories_stats" }, method = RequestMethod.GET, produces = "application/json") + public void saveUserStories(@RequestBody KpiUserStoryStats kpiUserStoryStats) { + service.saveUserStories(kpiUserStoryStats); + } + + @SuppressWarnings("unchecked") + @RequestMapping(value = { "/portalApi/update_user_stories_stats" }, method = RequestMethod.POST) + public List<KpiUserStoryStats> updateUserStories(@RequestBody KpiUserStoryStats kpiUserStoryStats) { + service.updateUserStories(kpiUserStoryStats); + return (List<KpiUserStoryStats>) service.getUserStories(); + } + + @SuppressWarnings("unchecked") + @RequestMapping(value = { "/portalApi/get_user_api_stats" }, method = RequestMethod.GET, produces = "application/json") + public List<KpiApiStats> getUserApis(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List<KpiApiStats> apiStats = null; + + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserApps"); + } else { + apiStats = (List<KpiApiStats>) service.getUserApis(); + EcompPortalUtils.logAndSerializeObject("/portalApi/get_user_api_stats", "GET result =", apiStats); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing getUserApps operation, Details: " + EcompPortalUtils.getStackTrace(e)); + } + return apiStats; + } + + @SuppressWarnings("unchecked") + @RequestMapping(value = { "/portalApi/get_kpi_service_supported" }, method = RequestMethod.GET, produces = "application/json") + public List<KpiServiceSupported> getKpiServiceSupported(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List<KpiServiceSupported> kpiServiceSupported = null; + + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserApps"); + } else { + kpiServiceSupported = (List<KpiServiceSupported>) service.getKpiServiceSupported(); + EcompPortalUtils.logAndSerializeObject("/portalApi/get_kpi_service_supported", "GET result =", kpiServiceSupported); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing getUserApps operation, Details: " + EcompPortalUtils.getStackTrace(e)); + } + return kpiServiceSupported; +// return (List<KpiServiceSupported>) service.getKpiServiceSupported(); + } + + @SuppressWarnings("unchecked") + @RequestMapping(value = { "/portalApi/update_user_api_stats" }, method = RequestMethod.POST) + public List<KpiApiStats> updateUserApis(@RequestBody KpiApiStats kpiApiStats) { + service.updateUserApis(kpiApiStats); + return (List<KpiApiStats>) service.getUserApis(); + } + + @SuppressWarnings("unchecked") + @RequestMapping(value = { "/portalApi/execute_get_published_delivered" }, method = RequestMethod.GET, produces = "application/json") + public List<String> getPublishedDelivered(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List<String> publishedDelivered = null; + + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserApps"); + } else { + publishedDelivered = service.executeGetBytesPublishedDelivered(); + EcompPortalUtils.logAndSerializeObject("/portalApi/execute_get_published_delivered", "GET result =", publishedDelivered); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing getLOCStatsCat operation, Details: " + EcompPortalUtils.getStackTrace(e)); + } + return publishedDelivered; + // return service.executeGetBytesPublishedDelivered(); + } + + @SuppressWarnings("unchecked") + @RequestMapping(value = { "/portalApi/execute_get_feed_stats" }, method = RequestMethod.GET, produces = "application/json") + public List<Long> getFeedStats(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List<Long> feedStats= null; + + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserApps"); + } else { + feedStats = service.executeGetFeedStats(); + EcompPortalUtils.logAndSerializeObject("/portalApi/execute_get_feed_stats", "GET result =", feedStats); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing getLOCStatsCat operation, Details: " + EcompPortalUtils.getStackTrace(e)); + } + return feedStats; +// return service.executeGetFeedStats(); + } + + @SuppressWarnings("unchecked") + @RequestMapping(value = { "/portalApi/get_loc_stats_cat" }, method = RequestMethod.GET, produces = "application/json") + public List<String> getLOCStatsCat(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List<String> LOCStatsCat = null; + + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserApps"); + } else { + LOCStatsCat = service.getLOCStatsCat(); + EcompPortalUtils.logAndSerializeObject("/portalApi/get_loc_stats_cat", "GET result =", LOCStatsCat); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing getLOCStatsCat operation, Details: " + EcompPortalUtils.getStackTrace(e)); + } + return LOCStatsCat; + } + + @SuppressWarnings("unchecked") + @RequestMapping(value = { "/portalApi/get_loc_stats" }, method = RequestMethod.GET, produces = "application/json") + public List<Long> getLOCStats(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + List<Long> LOCStats = null; + + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserApps"); + } else { + LOCStats = service.getLOCStats(); + EcompPortalUtils.logAndSerializeObject("/portalApi/get_loc_stats", "GET result =", LOCStats); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing getLOCStats operation, Details: " + EcompPortalUtils.getStackTrace(e)); + } + return LOCStats; + } + + @RequestMapping(value = { "/portalApi/get_geo_map_url" }, method = RequestMethod.GET, produces = "text/plain") + public String getGeoMapUrl(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + String geoMapUrl = null; + + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserApps"); + } else { + geoMapUrl = service.getGeoMapUrl(); + EcompPortalUtils.logAndSerializeObject("/portalApi/get_geo_map_url", "GET result =", geoMapUrl); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing getGeoMapUrl operation, Details: " + EcompPortalUtils.getStackTrace(e)); + } + + return geoMapUrl; + } + + @RequestMapping(value = { "/portalApi/get_rcloud_a_url" }, method = RequestMethod.GET, produces = "text/plain") + public String getRCloudAUrl(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + String rcloudUrl = null; + + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserApps"); + } else { + rcloudUrl = service.getRCloudAUrl(); + EcompPortalUtils.logAndSerializeObject("/portalApi/get_rcloud_a_url", "GET result =", rcloudUrl); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing getGeoMapUrl operation, Details: " + EcompPortalUtils.getStackTrace(e)); + } + + return rcloudUrl; + } + + @RequestMapping(value = { "/portalApi/get_geo_map_api_url" }, method = RequestMethod.GET, produces = "text/plain") + public String getGeoMapApiUrl(HttpServletRequest request, HttpServletResponse response) { + EPUser user = EPUserUtils.getUserSession(request); + String geoMapApiUrl = null; + + try { + if (user == null) { + EcompPortalUtils.setBadPermissions(user, response, "getUserApps"); + } else { + geoMapApiUrl = service.getGeoMapApiUrl(); + EcompPortalUtils.logAndSerializeObject("/portalApi/get_geo_map_api_url", "GET result =", geoMapApiUrl); + } + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, "Exception occurred while performing getGeoMapApiUrl operation, Details: " + EcompPortalUtils.getStackTrace(e)); + } + + return geoMapApiUrl; + } +} diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpiApiStats.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpiApiStats.java new file mode 100644 index 00000000..fb646ef5 --- /dev/null +++ b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpiApiStats.java @@ -0,0 +1,74 @@ +/*- + * ================================================================================ + * eCOMP Portal + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +package org.openecomp.portalapp.kpidash.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +@Entity +@Table(name = "kpi_api_stats") +public class KpiApiStats extends DomainVo { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "api_type") + private String apiType; + + @Column(name = "total_api") + private Long totalApi; + + @Column(name = "comment") + private String comment; + + public KpiApiStats() { + } + + public String getApiType() { + return apiType; + } + + public void setApiType(String apiType) { + this.apiType = apiType; + } + + public Long getTotalApi() { + return totalApi; + } + + public void setTotalApi(Long totalApi) { + this.totalApi = totalApi; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + +} diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpiServiceSupported.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpiServiceSupported.java new file mode 100644 index 00000000..1e768390 --- /dev/null +++ b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpiServiceSupported.java @@ -0,0 +1,60 @@ +/*- + * ================================================================================ + * eCOMP Portal + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +package org.openecomp.portalapp.kpidash.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +@Entity +@Table(name = "kpi_service_supported") +public class KpiServiceSupported extends DomainVo { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "service_type") + private String serviceType; + + @Column(name = "total_count") + private Long totalCount; + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public Long getTotalCount() { + return totalCount; + } + + public void setTotalCount(Long totalCount) { + this.totalCount = totalCount; + } + +} diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpiUserStoryStats.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpiUserStoryStats.java new file mode 100644 index 00000000..e4337cca --- /dev/null +++ b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpiUserStoryStats.java @@ -0,0 +1,107 @@ +/*- + * ================================================================================ + * eCOMP Portal + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +package org.openecomp.portalapp.kpidash.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.openecomp.portalsdk.core.domain.support.DomainVo; + +@Entity +@Table(name = "kpi_user_story_stats1") +public class KpiUserStoryStats extends DomainVo { + /** + * + */ + private static final long serialVersionUID = -1193197465342848502L; + + @Id + @Column(name = "release_key") + private String releaseKey; + + @Column(name = "delivered") + private Long delivered; + + @Column(name = "in_progress") + private Long inProgress; + + @Column(name = "IST_progress_readiness") + private String ISTProgressReadiness; + + @Column(name = "E2E_progress_readiness") + private String E2EProgressReadiness; + + @Column(name = "Key_Highlights") + private String KeyHighlights; + + public KpiUserStoryStats() { + } + + public String getReleaseKey() { + return releaseKey; + } + + public void setReleaseKey(String releaseKey) { + this.releaseKey = releaseKey; + } + + public Long getDelivered() { + return delivered; + } + + public void setDelivered(Long delivered) { + this.delivered = delivered; + } + + public Long getInProgress() { + return inProgress; + } + + public void setInProgress(Long inProgress) { + this.inProgress = inProgress; + } + + public String getISTProgressReadiness() { + return ISTProgressReadiness; + } + + public void setISTProgressReadiness(String iSTProgressReadiness) { + ISTProgressReadiness = iSTProgressReadiness; + } + + public String getE2EProgressReadiness() { + return E2EProgressReadiness; + } + + public void setE2EProgressReadiness(String e2eProgressReadiness) { + E2EProgressReadiness = e2eProgressReadiness; + } + + public String getKeyHighlights() { + return KeyHighlights; + } + + public void setKeyHighlights(String keyHighlights) { + KeyHighlights = keyHighlights; + } + +} diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpidashProperties.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpidashProperties.java new file mode 100644 index 00000000..a6f81f4f --- /dev/null +++ b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/model/KpidashProperties.java @@ -0,0 +1,33 @@ +/*- + * ================================================================================ + * eCOMP Portal + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +package org.openecomp.portalapp.kpidash.model; + +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +@Configuration +@PropertySource(value = { "${container.classpath:}/WEB-INF/conf/kpidash.properties" }) + +public class KpidashProperties extends SystemProperties { + public static final String GEO_MAP_URL = "url.sectiona"; + public static final String RCLOUD_A_URL = "url.sectionb"; + public static final String GEO_API_URL = "url.geomapapiurl"; +} diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/service/KpiDashboardService.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/service/KpiDashboardService.java new file mode 100644 index 00000000..14892f67 --- /dev/null +++ b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/service/KpiDashboardService.java @@ -0,0 +1,56 @@ +/*- + * ================================================================================ + * eCOMP Portal + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +package org.openecomp.portalapp.kpidash.service; + +import java.util.List; + +import org.openecomp.portalapp.kpidash.model.KpiApiStats; +import org.openecomp.portalapp.kpidash.model.KpiUserStoryStats; + +@SuppressWarnings("rawtypes") +public interface KpiDashboardService { + public List getUserStories(); + + public void saveUserStories(KpiUserStoryStats kpiUserStoryStats); + + public void updateUserStories(KpiUserStoryStats kpiUserStoryStats); + + public List getUserApis(); + + public void saveUserApis(KpiApiStats kpiApiStats); + + public void updateUserApis(KpiApiStats kpiApiStats); + + public List getKpiServiceSupported(); + + public List executeGetBytesPublishedDelivered(); + + public List executeGetFeedStats(); + + public List getLOCStatsCat(); + + public List getLOCStats(); + + public String getGeoMapUrl(); + + public String getRCloudAUrl(); + + public String getGeoMapApiUrl(); +} diff --git a/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/service/KpiDashboardServiceImpl.java b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/service/KpiDashboardServiceImpl.java new file mode 100644 index 00000000..edbc54af --- /dev/null +++ b/ecomp-portal-BE/src/main/java/org/openecomp/portalapp/kpidash/service/KpiDashboardServiceImpl.java @@ -0,0 +1,180 @@ +/*- + * ================================================================================ + * eCOMP Portal + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ================================================================================ + */ +package org.openecomp.portalapp.kpidash.service; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +import org.openecomp.portalapp.kpidash.model.KpiApiStats; +import org.openecomp.portalapp.kpidash.model.KpiServiceSupported; +import org.openecomp.portalapp.kpidash.model.KpiUserStoryStats; +import org.openecomp.portalapp.kpidash.model.KpidashProperties; +import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog; +import org.openecomp.portalapp.portal.utils.EcompPortalUtils; +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.portalsdk.core.service.DataAccessService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@SuppressWarnings("rawtypes") +@Service("kpiDashboardService") +@Transactional +@org.springframework.context.annotation.Configuration +@EnableAspectJAutoProxy +@EPMetricsLog +public class KpiDashboardServiceImpl implements KpiDashboardService { + + EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(KpiDashboardServiceImpl.class); + + @Autowired + private DataAccessService dataAccessService; + + @Override + public void saveUserStories(KpiUserStoryStats kpiUserStoryStats) { + dataAccessService.saveDomainObject(kpiUserStoryStats, null); + } + + @Override + public void updateUserStories(KpiUserStoryStats kpiUserStoryStats) { + dataAccessService.saveDomainObject(kpiUserStoryStats, null); + } + + @Override + public List getUserStories() { + return dataAccessService.getList(KpiUserStoryStats.class, null); + } + + @Override + public List getUserApis() { + return dataAccessService.getList(KpiApiStats.class, null); + } + + @Override + public void saveUserApis(KpiApiStats kpiApiStats) { + // TODO Auto-generated method stub + + } + + @Override + public void updateUserApis(KpiApiStats kpiApiStats) { + dataAccessService.saveDomainObject(kpiApiStats, null); + } + + @Override + public List getKpiServiceSupported() { + return dataAccessService.getList(KpiServiceSupported.class, null); + } + + @Override + public List<String> executeGetBytesPublishedDelivered() { + List list = dataAccessService.executeNamedQuery("getBytesPublishedDelivered", null, null); + List<String> newStringList = new ArrayList<String>(); + if (list != null && list.size() > 0) { + Object[] retunVals = (Object[]) list.get(0); // current entry in + // VSPEntAdmin table + newStringList.add((String) retunVals[0]); + newStringList.add((String) retunVals[1]); + } + return newStringList; + } + + @Override + public List<Long> executeGetFeedStats() { + List list = dataAccessService.executeNamedQuery("getDataRouterFeedStats", null, null); + List<Long> newLongList = new ArrayList<Long>(); + if (list != null && list.size() > 0) { + Object[] retunVals = (Object[]) list.get(0); // current entry in + // VSPEntAdmin table + newLongList.add((Long) retunVals[0]); + newLongList.add((Long) retunVals[1]); + newLongList.add((Long) retunVals[2]); + } + return newLongList; + } + + @Override + public List<String> getLOCStatsCat() { + List list = dataAccessService.executeNamedQuery("getLOCStatsCat", null, null); + List<String> newStringList = new ArrayList<String>(); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + /* Object[] retunVals = (Object[]) list.get(i); */// current + // entry in + // VSPEntAdmin + // table + newStringList.add((String) list.get(i)); + } + } + return newStringList; + }; + + @Override + public List<Long> getLOCStats() { + List list = dataAccessService.executeNamedQuery("getLOCStats", null, null); + List<Long> newLongList = new ArrayList<Long>(); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + /* Object[] retunVals = (Object[]) list.get(i); */// current + // entry in + // VSPEntAdmin + // table + newLongList.add(((BigDecimal) list.get(i)).longValue()); + } + } + return newLongList; + }; + + @Override + public String getGeoMapUrl() { + String newURL = ""; + try { + newURL = KpidashProperties.getProperty(KpidashProperties.GEO_MAP_URL); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } + return newURL; + } + + @Override + public String getRCloudAUrl() { + String newURL = ""; + try { + newURL = KpidashProperties.getProperty(KpidashProperties.RCLOUD_A_URL); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } + return newURL; + } + + @Override + public String getGeoMapApiUrl() { + String newURL = ""; + try { + newURL = KpidashProperties.getProperty(KpidashProperties.GEO_API_URL); + } catch (Exception e) { + logger.error(EELFLoggerDelegate.errorLogger, EcompPortalUtils.getStackTrace(e)); + } + return newURL; + } + +} |