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============================================
38 package org.onap.portalsdk.analytics.system.fusion.service;
40 import java.util.List;
43 import org.onap.portalsdk.analytics.system.fusion.domain.CR_Report;
44 import org.onap.portalsdk.core.service.DataAccessService;
45 import org.onap.portalsdk.core.service.support.FusionService;
46 import org.springframework.context.ApplicationContext;
48 public class RaptorServiceImpl extends FusionService implements RaptorService {
50 private DataAccessService dataAccessService;
52 private int totalSize;
54 public DataAccessService getDataAccessService() {
55 return dataAccessService;
58 public void setDataAccessService(DataAccessService dataAccessService) {
59 this.dataAccessService = dataAccessService;
62 private ApplicationContext applicationContext;
64 //raptorSearchAllReportsCount
66 public int executeCountQuery(Class entity, String query, Map params, String whereClause) {
67 List l = getDataAccessService().executeNamedCountQuery(entity, query, whereClause, params);
68 //List l = getDataAccessService().executeNamedQuery(query, params, null);
72 searchCount = (((Long) l.get(0))).intValue();
75 totalSize = searchCount;
79 //raptorSearchAllReports
80 public List executeGridQuery(String query, Map params, Integer fromIndex, Integer toIndex) {
81 return getDataAccessService().executeNamedQuery(query, params, fromIndex, toIndex, null);
84 public List executeGridQueryOrderByWithLimit(Class entity, String query, Map params, String _orderBy, boolean asc, Integer fromIndex, Integer toIndex) {
85 return getDataAccessService().executeNamedQueryWithOrderBy(entity, query, params, _orderBy, asc, fromIndex, toIndex, null);
89 public List executeGridQuery(Class entity, String query, String whereClause, Map params, Integer fromIndex, Integer toIndex) {
90 return getDataAccessService().executeNamedQuery(entity, query, whereClause, params, fromIndex, toIndex, null);
93 public List executeGridQueryOrderByWithLimit(Class entity, String query, String whereClause, Map params, String _orderBy, boolean asc, Integer fromIndex, Integer toIndex) {
94 return getDataAccessService().executeNamedQueryWithOrderBy(entity, query, whereClause, params, _orderBy, asc, fromIndex, toIndex, null);
98 public int getUserReportsCount(Map params) {
99 List l = getDataAccessService().executeNamedQuery("raptorSearchUserReportsCount", params, null);
103 Object[] result = (Object[]) l.get(0);
104 count = ((Long)result[0]).intValue();
111 public List getUserReports(Map params, Integer fromIndex, Integer toIndex) {
112 return getDataAccessService().executeNamedQuery("raptorSearchUserReports", params, fromIndex, toIndex, null);
115 public int getPublicReportsCount(Map params) {
116 List l = getDataAccessService().executeNamedQuery("raptorPublicUserReportsCount", params, null);
120 Object[] result = (Object[]) l.get(0);
121 count = ((Long)result[0]).intValue();
128 public List getPublicReports(Map params, Integer fromIndex, Integer toIndex) {
129 return getDataAccessService().executeNamedQuery("raptorPublicUserReports", params, fromIndex, toIndex, null);
132 public int getFavReportsCount(Map params) {
133 List l = getDataAccessService().executeNamedQuery("raptorSearchFavReportsCount", params, null);
137 Object[] result = (Object[]) l.get(0);
138 count = ((Long)result[0]).intValue();
145 public List getFavReports(Map params, Integer fromIndex, Integer toIndex) {
146 return getDataAccessService().executeNamedQuery("raptorSearchFavReports", params, fromIndex, toIndex, null);
149 public int getTotalSize() {
153 public void deleteReport(Long reportId) {
154 getDataAccessService().deleteDomainObject(getDataAccessService().getDomainObject(CR_Report.class, reportId, null), null);
157 public List getReportInfo(Map params) {
158 return getDataAccessService().executeNamedQuery("raptorInfoQuery", params, null);
161 /* public List executeGridQueryWithOrderBy(String query, Map params, String _orderBy, boolean asc, Integer fromIndex, Integer toIndex) {
162 query = String.format(query, _orderBy, asc ? "ASC" : "DESC", fromIndex, toIndex);
163 DataSource ds = (DataSource)getApplicationContext().getBean(searchBean.getDatasourceName());
164 NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(ds);
168 * @return the applicationContext
170 public ApplicationContext getApplicationContext() {
171 return applicationContext;
175 * @param applicationContext the applicationContext to set
177 public void setApplicationContext(ApplicationContext applicationContext) {
178 this.applicationContext = applicationContext;