X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ecomp-portal-widget-ms%2Fwidget-ms%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportalapp%2Fwidget%2Fservice%2Fimpl%2FWidgetCatalogServiceImpl.java;h=76ca31a815d6dce79969de2419b390f766c436a3;hb=0547751f8b0b8b5a3e96fb04c266e23884f97b85;hp=8dd8628210bf118a96e637628d7478dbf7864050;hpb=21a8761f684745bb300e075c7e98ad897ace9eed;p=portal.git diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java index 8dd86282..76ca31a8 100644 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java +++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java @@ -1,3 +1,40 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * + */ package org.onap.portalapp.widget.service.impl; import java.util.List; @@ -111,9 +148,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService { @Override public WidgetCatalog getWidgetCatalog(Long widgetCatalogId) { Session session = sessionFactory.getCurrentSession(); - Transaction tx = session.beginTransaction(); WidgetCatalog widget = (WidgetCatalog) session.get(WidgetCatalog.class, widgetCatalogId); - tx.commit(); logger.debug("WidgetCatalogServiceImpl.getWidgetCatalog: getting widget={}", widget); return widget; } @@ -154,7 +189,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService { Transaction tx = session.beginTransaction(); session.save(newWidgetCatalog); tx.commit(); - session.flush(); + //session.flush(); session.close(); updateAppId(newWidgetCatalog.getId(), newWidgetCatalog.getWidgetRoles()); } @@ -180,7 +215,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService { Transaction tx = session.beginTransaction(); session.update(newWidgetCatalog); tx.commit(); - session.flush(); + //session.flush(); session.close(); updateAppId(newWidgetCatalog.getId(), newWidgetCatalog.getWidgetRoles()); }catch(Exception e){ @@ -207,16 +242,15 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService { logger.debug("WidgetCatalogServiceImpl.getWidgetCatalog: result={}", widgets); return widgets; } - - - - - + private void updateAppId(long widgetId, Set roles){ Session session = sessionFactory.openSession(); for(RoleApp role: roles){ - String sql = "UPDATE ep_widget_catalog_role SET app_id = " + role.getApp().getAppId() + " WHERE widget_id = " + widgetId + " AND ROLE_ID = " + role.getRoleId() ; + String sql = "UPDATE ep_widget_catalog_role SET app_id = :appId WHERE widget_id = :widgetId AND ROLE_ID = :roleId" ; Query query = session.createSQLQuery(sql); + query.setParameter("appId", role.getApp().getAppId()); + query.setParameter("widgetId", widgetId); + query.setParameter("roleId", role.getRoleId()); query.executeUpdate(); } session.flush(); @@ -232,7 +266,7 @@ public class WidgetCatalogServiceImpl implements WidgetCatalogService { List widgets = criteria.list(); logger.debug("WidgetCatalogServiceImpl.getWidgetIdByName: result={}", widgets); - session.flush(); +// session.flush(); session.close(); return (widgets.size() > 0) ? true : false;