47625b554bd16eb75692cf203744001a74140620
[vfc/nfvo/resmanagement.git] /
1 /*
2  * Copyright 2016 Huawei Technologies Co., Ltd.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.onap.vfc.nfvo.resmanagement.service.entity;
18
19 import org.apache.commons.lang.StringUtils;
20 import org.onap.vfc.nfvo.resmanagement.common.util.JsonUtil;
21
22 import net.sf.json.JSONObject;
23
24 /**
25  *
26  * Network entity class.<br>
27  * <p>
28  * </p>
29  *
30  * @author
31  * @version     NFVO 0.5  Sep 10, 2016
32  */
33 public class NetworkEntity {
34
35     /**
36      * This field corresponds to the database column network.ID
37      */
38     private String id;
39
40     /**
41      * This field corresponds to the database column network.NAME
42      */
43     private String name;
44
45     /**
46      * This field corresponds to the database column network.TENANT_ID
47      */
48     private String tenantId;
49
50     /**
51      * This field corresponds to the database column network.VIM_ID
52      */
53     private String vimId;
54
55     /**
56      * This field corresponds to the database column ivm.VIM_NAME
57      */
58     private String vimName;
59
60     /**
61      * This field corresponds to the database column network.STATUS
62      */
63     private String status;
64
65     /**
66      * This field corresponds to the database column network.PHYSICAL_NETWORK
67      */
68
69     private String physicalNetwork;
70
71     /**
72      * This field corresponds to the database column network.NETWORK_TYPE
73      */
74     private String networkType;
75
76     /**
77      * This field corresponds to the database column network.SEGMENTATION_ID
78      */
79     private String segmentationId;
80
81     /**
82      * return the value of network.ID
83      */
84     public String getId() {
85         return id;
86     }
87
88     /**
89      * This method sets the value of the database column network.ID
90      *
91      * @param id
92      *            the value for network.ID
93      */
94     public void setId(String id) {
95         this.id = id == null ? null : id.trim();
96     }
97
98     /**
99      * return the value of network.NAME
100      */
101     public String getName() {
102         return name;
103     }
104
105     /**
106      * This method sets the value of the database column network.NAME
107      *
108      * @param name
109      *            the value for network.NAME
110      */
111     public void setName(String name) {
112         this.name = name == null ? null : name.trim();
113     }
114
115     /**
116      * return the value of network.TENANT_ID
117      */
118     public String getTenantId() {
119         return tenantId;
120     }
121
122     /**
123      * This method sets the value of the database column network.TENANT_ID
124      *
125      * @param tenantId
126      *            the value for network.TENANT_ID
127      */
128     public void setTenantId(String tenantId) {
129         this.tenantId = tenantId == null ? null : tenantId.trim();
130     }
131
132     /**
133      * return the value of network.VIM_ID
134      */
135     public String getVimId() {
136         return vimId;
137     }
138
139     /**
140      * This method sets the value of the database column network.VIM_ID
141      *
142      * @param networkVimId
143      *            the value for network.VIM_ID
144      */
145     public void setVimId(String networkVimId) {
146         this.vimId = networkVimId == null ? null : networkVimId.trim();
147     }
148
149     /**
150      * return the value of ivm.VIM_NAME
151      */
152     public String getVimName() {
153         return vimName;
154     }
155
156     /**
157      * This method sets the value of the database column ivm.VIM_NAME
158      *
159      * @param networkVimName
160      *            the value for ivm.VIM_NAME
161      */
162     public void setVimName(String networkVimName) {
163         this.vimName = networkVimName == null ? null : networkVimName.trim();
164     }
165
166     /**
167      * return the value of network.STATUS
168      */
169     public String getStatus() {
170         return status;
171     }
172
173     /**
174      * This method sets the value of the database column network.STATUS
175      *
176      * @param networkStatus
177      *            the value for network.STATUS
178      */
179     public void setStatus(String networkStatus) {
180         this.status = networkStatus == null ? null : networkStatus.trim().toLowerCase();
181     }
182
183     /**
184      * return the value of network.PHYSICAL_NETWORK
185      */
186     public String getPhysicalNetwork() {
187         return physicalNetwork;
188     }
189
190     /**
191      * This method sets the value of the database column
192      * network.PHYSICAL_NETWORK
193      *
194      * @param physicalNetwork
195      *            the value for network.PHYSICAL_NETWORK
196      */
197     public void setPhysicalNetwork(String physicalNetwork) {
198         this.physicalNetwork = physicalNetwork == null ? null : physicalNetwork.trim();
199     }
200
201     /**
202      * return the value of network.NETWORK_TYPE
203      */
204     public String getNetworkType() {
205         return networkType;
206     }
207
208     /**
209      * This method sets the value of the database column network.NETWORK_TYPE
210      *
211      * @param networkType
212      *            the value for network.NETWORK_TYPE
213      */
214     public void setNetworkType(String networkType) {
215         this.networkType = networkType == null ? null : networkType.trim();
216     }
217
218     /**
219      * return the value of network.SEGMENTATION_ID
220      */
221     public String getSegmentationId() {
222         return segmentationId;
223     }
224
225     /**
226      * This method sets the value of the database column network.SEGMENTATION_ID
227      *
228      * @param segmentationId
229      *            the value for network.SEGMENTATION_ID
230      */
231     public void setSegmentationId(String segmentationId) {
232         this.segmentationId = segmentationId == null ? null : segmentationId.trim();
233     }
234
235     /**
236      *
237      * To Entity.<br>
238      *
239      * @param jsonObject
240      * @return
241      * @since  NFVO 0.5
242      */
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"));
254         return sitesEntity;
255     }
256
257     @Override
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();
270     }
271 }