2 * Copyright 2016 Huawei Technologies Co., Ltd.
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.
17 package org.onap.vfc.nfvo.resmanagement.service.entity;
19 import org.apache.commons.lang.StringUtils;
20 import org.onap.vfc.nfvo.resmanagement.common.util.JsonUtil;
22 import net.sf.json.JSONObject;
26 * Network entity class.<br>
31 * @version NFVO 0.5 Sep 10, 2016
33 public class NetworkEntity {
36 * This field corresponds to the database column network.ID
41 * This field corresponds to the database column network.NAME
46 * This field corresponds to the database column network.TENANT_ID
48 private String tenantId;
51 * This field corresponds to the database column network.VIM_ID
56 * This field corresponds to the database column ivm.VIM_NAME
58 private String vimName;
61 * This field corresponds to the database column network.STATUS
63 private String status;
66 * This field corresponds to the database column network.PHYSICAL_NETWORK
69 private String physicalNetwork;
72 * This field corresponds to the database column network.NETWORK_TYPE
74 private String networkType;
77 * This field corresponds to the database column network.SEGMENTATION_ID
79 private String segmentationId;
82 * return the value of network.ID
84 public String getId() {
89 * This method sets the value of the database column network.ID
92 * the value for network.ID
94 public void setId(String id) {
95 this.id = id == null ? null : id.trim();
99 * return the value of network.NAME
101 public String getName() {
106 * This method sets the value of the database column network.NAME
109 * the value for network.NAME
111 public void setName(String name) {
112 this.name = name == null ? null : name.trim();
116 * return the value of network.TENANT_ID
118 public String getTenantId() {
123 * This method sets the value of the database column network.TENANT_ID
126 * the value for network.TENANT_ID
128 public void setTenantId(String tenantId) {
129 this.tenantId = tenantId == null ? null : tenantId.trim();
133 * return the value of network.VIM_ID
135 public String getVimId() {
140 * This method sets the value of the database column network.VIM_ID
142 * @param networkVimId
143 * the value for network.VIM_ID
145 public void setVimId(String networkVimId) {
146 this.vimId = networkVimId == null ? null : networkVimId.trim();
150 * return the value of ivm.VIM_NAME
152 public String getVimName() {
157 * This method sets the value of the database column ivm.VIM_NAME
159 * @param networkVimName
160 * the value for ivm.VIM_NAME
162 public void setVimName(String networkVimName) {
163 this.vimName = networkVimName == null ? null : networkVimName.trim();
167 * return the value of network.STATUS
169 public String getStatus() {
174 * This method sets the value of the database column network.STATUS
176 * @param networkStatus
177 * the value for network.STATUS
179 public void setStatus(String networkStatus) {
180 this.status = networkStatus == null ? null : networkStatus.trim().toLowerCase();
184 * return the value of network.PHYSICAL_NETWORK
186 public String getPhysicalNetwork() {
187 return physicalNetwork;
191 * This method sets the value of the database column
192 * network.PHYSICAL_NETWORK
194 * @param physicalNetwork
195 * the value for network.PHYSICAL_NETWORK
197 public void setPhysicalNetwork(String physicalNetwork) {
198 this.physicalNetwork = physicalNetwork == null ? null : physicalNetwork.trim();
202 * return the value of network.NETWORK_TYPE
204 public String getNetworkType() {
209 * This method sets the value of the database column network.NETWORK_TYPE
212 * the value for network.NETWORK_TYPE
214 public void setNetworkType(String networkType) {
215 this.networkType = networkType == null ? null : networkType.trim();
219 * return the value of network.SEGMENTATION_ID
221 public String getSegmentationId() {
222 return segmentationId;
226 * This method sets the value of the database column network.SEGMENTATION_ID
228 * @param segmentationId
229 * the value for network.SEGMENTATION_ID
231 public void setSegmentationId(String segmentationId) {
232 this.segmentationId = segmentationId == null ? null : segmentationId.trim();
243 public static NetworkEntity toEntity(JSONObject jsonObject) {
244 NetworkEntity sitesEntity = new NetworkEntity();
245 sitesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
246 sitesEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));
247 sitesEntity.setTenantId(JsonUtil.getJsonFieldStr(jsonObject, "tenantId"));
248 sitesEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status"));
249 sitesEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId"));
250 sitesEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName"));
251 sitesEntity.setPhysicalNetwork(JsonUtil.getJsonFieldStr(jsonObject, "physicalNetwork"));
252 sitesEntity.setNetworkType(JsonUtil.getJsonFieldStr(jsonObject, "networkType"));
253 sitesEntity.setSegmentationId(JsonUtil.getJsonFieldStr(jsonObject, "segmentationId"));
258 public String toString() {
259 JSONObject networkJson = new JSONObject();
260 networkJson.put("id", StringUtils.trimToEmpty(this.getId()));
261 networkJson.put("name", StringUtils.trimToEmpty(this.getName()));
262 networkJson.put("tenant_id", StringUtils.trimToEmpty(this.getTenantId()));
263 networkJson.put("status", StringUtils.trimToEmpty(this.getStatus()));
264 networkJson.put("vimId", StringUtils.trimToEmpty(this.getVimId()));
265 networkJson.put("vimName", StringUtils.trimToEmpty(this.getVimName()));
266 networkJson.put("provider:physical_network", StringUtils.trimToEmpty(this.getPhysicalNetwork()));
267 networkJson.put("provider:network_type", StringUtils.trimToEmpty(this.getNetworkType()));
268 networkJson.put("provider:segmentation_id", StringUtils.trimToEmpty(this.getSegmentationId()));
269 return networkJson.toString();