2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the “License”);
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
36 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
38 package org.onap.portalsdk.analytics.system.fusion.service;
40 import java.io.BufferedInputStream;
41 import java.io.BufferedOutputStream;
42 import java.io.FileOutputStream;
43 import java.io.IOException;
44 import java.io.InputStream;
45 import java.io.OutputStream;
46 import java.math.BigDecimal;
47 import java.util.Date;
48 import java.util.HashMap;
49 import java.util.List;
53 import javax.sql.DataSource;
55 import org.hibernate.Query;
56 import org.hibernate.Session;
57 import org.onap.portalsdk.analytics.system.fusion.domain.CR_Report;
58 import org.onap.portalsdk.core.domain.Role;
59 import org.onap.portalsdk.core.service.DataAccessService;
60 import org.onap.portalsdk.core.service.support.FusionService;
61 import org.onap.portalsdk.core.util.SystemProperties;
62 import org.onap.portalsdk.core.web.support.UserUtils;
63 import org.springframework.context.ApplicationContext;
64 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
65 import org.springframework.orm.hibernate3.SessionFactoryUtils;
66 import org.springframework.web.multipart.MultipartFile;
68 public class RaptorServiceImpl extends FusionService implements RaptorService {
70 private DataAccessService dataAccessService;
72 private int totalSize;
74 public DataAccessService getDataAccessService() {
75 return dataAccessService;
78 public void setDataAccessService(DataAccessService dataAccessService) {
79 this.dataAccessService = dataAccessService;
82 private ApplicationContext applicationContext;
84 //raptorSearchAllReportsCount
86 public int executeCountQuery(Class entity, String query, Map params, String whereClause) {
87 List l = getDataAccessService().executeNamedCountQuery(entity, query, whereClause, params);
88 //List l = getDataAccessService().executeNamedQuery(query, params, null);
92 searchCount = (((Long) l.get(0))).intValue();
95 totalSize = searchCount;
99 //raptorSearchAllReports
100 public List executeGridQuery(String query, Map params, Integer fromIndex, Integer toIndex) {
101 return getDataAccessService().executeNamedQuery(query, params, fromIndex, toIndex, null);
104 public List executeGridQueryOrderByWithLimit(Class entity, String query, Map params, String _orderBy, boolean asc, Integer fromIndex, Integer toIndex) {
105 return getDataAccessService().executeNamedQueryWithOrderBy(entity, query, params, _orderBy, asc, fromIndex, toIndex, null);
109 public List executeGridQuery(Class entity, String query, String whereClause, Map params, Integer fromIndex, Integer toIndex) {
110 return getDataAccessService().executeNamedQuery(entity, query, whereClause, params, fromIndex, toIndex, null);
113 public List executeGridQueryOrderByWithLimit(Class entity, String query, String whereClause, Map params, String _orderBy, boolean asc, Integer fromIndex, Integer toIndex) {
114 return getDataAccessService().executeNamedQueryWithOrderBy(entity, query, whereClause, params, _orderBy, asc, fromIndex, toIndex, null);
118 public int getUserReportsCount(Map params) {
119 List l = getDataAccessService().executeNamedQuery("raptorSearchUserReportsCount", params, null);
123 Object[] result = (Object[]) l.get(0);
124 count = ((Long)result[0]).intValue();
131 public List getUserReports(Map params, Integer fromIndex, Integer toIndex) {
132 return getDataAccessService().executeNamedQuery("raptorSearchUserReports", params, fromIndex, toIndex, null);
135 public int getPublicReportsCount(Map params) {
136 List l = getDataAccessService().executeNamedQuery("raptorPublicUserReportsCount", params, null);
140 Object[] result = (Object[]) l.get(0);
141 count = ((Long)result[0]).intValue();
148 public List getPublicReports(Map params, Integer fromIndex, Integer toIndex) {
149 return getDataAccessService().executeNamedQuery("raptorPublicUserReports", params, fromIndex, toIndex, null);
152 public int getFavReportsCount(Map params) {
153 List l = getDataAccessService().executeNamedQuery("raptorSearchFavReportsCount", params, null);
157 Object[] result = (Object[]) l.get(0);
158 count = ((Long)result[0]).intValue();
165 public List getFavReports(Map params, Integer fromIndex, Integer toIndex) {
166 return getDataAccessService().executeNamedQuery("raptorSearchFavReports", params, fromIndex, toIndex, null);
169 public int getTotalSize() {
173 public void deleteReport(Long reportId) {
174 getDataAccessService().deleteDomainObject(getDataAccessService().getDomainObject(CR_Report.class, reportId, null), null);
177 public List getReportInfo(Map params) {
178 return getDataAccessService().executeNamedQuery("raptorInfoQuery", params, null);
181 /* public List executeGridQueryWithOrderBy(String query, Map params, String _orderBy, boolean asc, Integer fromIndex, Integer toIndex) {
182 query = String.format(query, _orderBy, asc ? "ASC" : "DESC", fromIndex, toIndex);
183 DataSource ds = (DataSource)getApplicationContext().getBean(searchBean.getDatasourceName());
184 NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(ds);
188 * @return the applicationContext
190 public ApplicationContext getApplicationContext() {
191 return applicationContext;
195 * @param applicationContext the applicationContext to set
197 public void setApplicationContext(ApplicationContext applicationContext) {
198 this.applicationContext = applicationContext;