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