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.portal.service;
22 import java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.List;
27 import org.hibernate.criterion.Criterion;
28 import org.hibernate.criterion.Restrictions;
29 import org.openecomp.portalapp.portal.domain.WidgetCatalogParameter;
30 import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
31 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
32 import org.openecomp.portalsdk.core.service.DataAccessService;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.context.annotation.EnableAspectJAutoProxy;
35 import org.springframework.stereotype.Service;
37 @Service("widgetParameterService")
38 @EnableAspectJAutoProxy
40 public class WidgetParameterServiceImpl implements WidgetParameterService{
41 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetParameterServiceImpl.class);
44 private DataAccessService dataAccessService;
46 @SuppressWarnings("unchecked")
48 public WidgetCatalogParameter getUserParamById(Long widgetId, Long userId, Long paramId) {
49 List<Criterion> restrictionsList = new ArrayList<Criterion>();
50 Criterion widgetIdCrit = Restrictions.eq("widgetId", widgetId);
51 restrictionsList.add(widgetIdCrit);
52 Criterion attIdCrit = Restrictions.eq("userId", userId);
53 restrictionsList.add(attIdCrit);
54 Criterion paramIdCrit = Restrictions.eq("paramId", paramId);
55 restrictionsList.add(paramIdCrit);
58 WidgetCatalogParameter widgetParam = null;
59 List<WidgetCatalogParameter> list = (List<WidgetCatalogParameter>) dataAccessService
60 .getList(WidgetCatalogParameter.class, null, restrictionsList, null);
62 widgetParam = list.get(0);
63 logger.debug(EELFLoggerDelegate.debugLogger,
64 "getUserParamById: widget parameters: " + widgetParam);
69 public void saveUserParameter(WidgetCatalogParameter newParameter) {
70 dataAccessService.saveDomainObject(newParameter, null);
73 @SuppressWarnings("unchecked")
75 public List<WidgetCatalogParameter> getUserParameterById(Long paramId) {
76 List<Criterion> restrictionsList = new ArrayList<Criterion>();
77 Criterion paramIdCrit = Restrictions.eq("paramId", paramId);
78 restrictionsList.add(paramIdCrit);
79 List<WidgetCatalogParameter> list = (List<WidgetCatalogParameter>) dataAccessService
80 .getList(WidgetCatalogParameter.class, null, restrictionsList, null);
85 public void deleteUserParameterById(Long paramId) {
86 Map<String, String> params = new HashMap<String, String>();
87 params.put("paramId", Long.toString(paramId));
88 dataAccessService.executeNamedQuery("deleteWidgetCatalogParameter", params, null);
89 dataAccessService.executeNamedQuery("deleteMicroserviceParameterById", params, null);