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.VimData;
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 VimHandler extends BaseHandler<VimData> {
32 private static final Logger logger = LoggerFactory.getLogger(VimHandler.class);
35 public boolean validity(VimData data) throws ExtsysException {
39 public List<VimData> getAll() throws ExtsysException {
40 Map<String, String> query = new HashMap<String, String>();
41 return query(query, ExtSysResuorceType.VIM.name());
45 * query vim list by id.
47 public List<VimData> getVimById(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.VIM.name());
54 * update vim list by id.
56 public VimData update(VimData vimData, String id) throws ExtsysException {
57 update(vimData, HqlFactory.getOidFilter(Parameters.id.name(), id),
58 ExtSysResuorceType.VIM.name());
59 List<VimData> list = getVimById(id);
60 if (list.size() <= 0) {
61 logger.error("update vim info error.");
62 throw new ExtsysException("0000", "update vim info error");
67 public VimData add(VimData vimData) throws ExtsysException {
68 return create(vimData, ExtSysResuorceType.VIM.name());
72 * delete vim list by id.
74 public void delete(String id) throws ExtsysException {
75 VimData vim = new VimData();
77 delete(vim, ExtSysResuorceType.VIM.name());