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.List;
24 import org.springframework.beans.factory.annotation.Autowired;
25 import org.springframework.context.annotation.EnableAspectJAutoProxy;
26 import org.springframework.stereotype.Service;
27 import org.springframework.transaction.annotation.Transactional;
29 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
30 import org.openecomp.portalsdk.core.service.DataAccessService;
31 import org.openecomp.portalapp.portal.domain.EPUser;
32 import org.openecomp.portalapp.portal.domain.PersUserWidgetSelection;
33 import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
35 @Service("persUserWidgetService")
37 @org.springframework.context.annotation.Configuration
38 @EnableAspectJAutoProxy
40 public class PersUserWidgetServiceImpl implements PersUserWidgetService{
42 private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PersUserAppServiceImpl.class);
45 private DataAccessService dataAccessService;
48 public void setPersUserAppValue(EPUser user, Long widgetId, boolean select) {
49 if (user == null || widgetId == null)
50 throw new IllegalArgumentException("setPersUserAppValue: Null values");
52 String filter = " where user_id = " + Long.toString(user.getId()) + " and widget_id = "
53 + Long.toString(widgetId);
54 @SuppressWarnings("unchecked")
55 List<PersUserWidgetSelection> persList = dataAccessService.getList(PersUserWidgetSelection.class, filter, null, null);
57 // Key constraint limits to 1 row
58 PersUserWidgetSelection persRow = null;
59 if (persList.size() == 1){
60 persRow = persList.get(0);
63 persRow = new PersUserWidgetSelection(null, user.getId(), widgetId, null);
66 if (persRow.getId() != null){
67 dataAccessService.deleteDomainObject(persRow, null);
69 persRow.setStatusCode("S"); // show
70 dataAccessService.saveDomainObject(persRow, null);
72 if (persRow.getId() != null){
73 dataAccessService.deleteDomainObject(persRow, null);
75 persRow.setStatusCode("H"); // Hide
76 dataAccessService.saveDomainObject(persRow, null);