2 * Copyright 2016-2017 ZTE Corporation.
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.aai.esr.handle;
18 import org.onap.aai.esr.common.ExtSysResuorceType;
19 import org.onap.aai.esr.common.Parameters;
20 import org.onap.aai.esr.entity.aai.EmsData;
21 import org.onap.aai.esr.exception.ExtsysException;
22 import org.onap.aai.esr.util.HqlFactory;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 import java.util.HashMap;
28 import java.util.List;
32 public class EmsHandler extends BaseHandler<EmsData> {
33 private static final Logger logger = LoggerFactory.getLogger(EmsHandler.class);
36 public boolean validity(EmsData data) throws ExtsysException {
40 public List<EmsData> getAll() throws ExtsysException {
41 Map<String, String> query = new HashMap<String, String>();
42 return query(query, ExtSysResuorceType.EMS.name());
48 public List<EmsData> getEmsById(String id) throws ExtsysException {
49 Map<String, String> query = new HashMap<String, String>();
50 query.put(Parameters.id.name(), id);
51 return query(query, ExtSysResuorceType.EMS.name());
55 * update ems list by id.
57 public EmsData update(EmsData emsData, String id) throws ExtsysException {
58 update(emsData, HqlFactory.getOidFilter(Parameters.id.name(), id),
59 ExtSysResuorceType.EMS.name());
60 List<EmsData> list = getEmsById(id);
61 if (list.size() <= 0) {
62 logger.error("update ems info error.");
63 throw new ExtsysException("0000", "update ems info error");
68 public EmsData add(EmsData emsData) throws ExtsysException {
70 return create(emsData, ExtSysResuorceType.EMS.name());
74 * delete ems list by id.
76 public void delete(String id) throws ExtsysException {
77 EmsData ems = new EmsData();
79 delete(ems, ExtSysResuorceType.EMS.name());