2 * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.usecaseui.server.service.impl;
18 import java.util.UUID;
20 import javax.transaction.Transactional;
22 import org.hibernate.Session;
23 import org.hibernate.SessionFactory;
24 import org.hibernate.Transaction;
25 import org.onap.usecaseui.server.bean.ActiveAlarmInfo;
26 import org.onap.usecaseui.server.service.AlarmService;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.context.annotation.EnableAspectJAutoProxy;
31 import org.springframework.stereotype.Service;
34 @Service("AlarmService")
36 @org.springframework.context.annotation.Configuration
37 @EnableAspectJAutoProxy
38 public class AlarmServiceImpl implements AlarmService
40 private static final Logger logger = LoggerFactory.getLogger(AlarmServiceImpl.class);
43 private SessionFactory sessionFactory;
52 public String saveActiveAlarmInfo(ActiveAlarmInfo acAlarmInfo)
56 if (null == acAlarmInfo)
58 logger.error("AlarmServiceImpl saveActiveAlarmInfo acAlarmInfo is null!");
60 logger.info("AlarmServiceImpl saveActiveAlarmInfo: acAlarmInfo={}", acAlarmInfo);
61 Session session = sessionFactory.openSession();
62 Transaction tx = session.beginTransaction();
63 acAlarmInfo.setId(UUID.randomUUID().toString());
64 session.save(acAlarmInfo);
71 logger.error("Exception occurred while performing AlarmServiceImpl saveActiveAlarmInfo. Details:" + e.getMessage());
74 return acAlarmInfo.getId();