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.db.VnfmData;
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;
26 import java.util.HashMap;
27 import java.util.List;
31 public class VnfmHandler extends BaseHandler<VnfmData> {
32 private static final Logger logger = LoggerFactory.getLogger(VnfmHandler.class);
35 public boolean validity(VnfmData data) throws ExtsysException {
39 public List<VnfmData> getAll() throws ExtsysException {
40 Map<String, String> query = new HashMap<String, String>();
41 return query(query, ExtSysResuorceType.VNFM.name());
45 * query vnfm list by id.
47 public List<VnfmData> getVnfmById(String id) throws ExtsysException {
48 Map<String, String> query = new HashMap<String, String>();
49 query.put(Parameters.id.name(), id);
50 return query(query, ExtSysResuorceType.VNFM.name());
54 * update vnfm list by id.
56 public VnfmData update(VnfmData vnfmData, String id) throws ExtsysException {
57 update(vnfmData, HqlFactory.getOidFilter(Parameters.id.name(), id),
58 ExtSysResuorceType.VNFM.name());
59 List<VnfmData> list = getVnfmById(id);
60 if (list.size() <= 0) {
61 logger.error("update vnfm info error.");
62 throw new ExtsysException("0000", "update vnfm info error");
67 public VnfmData add(VnfmData vnfmData) throws ExtsysException {
68 return create(vnfmData, ExtSysResuorceType.VNFM.name());
72 * delete vnfm list by id.
74 public void delete(String id) throws ExtsysException {
75 VnfmData vnfm = new VnfmData();
77 delete(vnfm, ExtSysResuorceType.VNFM.name());