78ad1b84d8a74fd49dfb672e881bd482ac304219
[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.res.service.entity;
18
19 import java.io.Serializable;
20
21 import org.apache.commons.lang3.StringUtils;
22 import org.onap.vfc.nfvo.res.common.util.JsonUtil;
23
24 import net.sf.json.JSONObject;
25
26 /**
27  * @author l00345485
28  * @date 2016-10-29
29  */
30 public class VnfStatusEntity implements Serializable {
31
32     /**  */
33     private String vnfInstanceId;
34
35     /**  */
36     private String jobId;
37
38     /**  */
39     private String nsId;
40
41     /**  */
42     private String vnfmId;
43
44     /**  */
45     private String responseDescriptor;
46
47     /**  */
48     private String status;
49
50     /**  */
51     private String progress;
52
53     /**  */
54     private String statusDescription;
55
56     /**  */
57     private String errorCode;
58
59     /**  */
60     private String responseId;
61
62     /**  */
63     private String responseHistoryList;
64
65     /**  */
66     private String addVm;
67
68     /**  */
69     private String delVm;
70
71     private static final long serialVersionUID = 1L;
72
73     public String getVnfInstanceId() {
74         return vnfInstanceId;
75     }
76
77     public void setVnfInstanceId(String vnfInstanceId) {
78         this.vnfInstanceId = vnfInstanceId;
79     }
80
81     public String getJobId() {
82         return jobId;
83     }
84
85     public void setJobId(String jobId) {
86         this.jobId = jobId;
87     }
88
89     public String getNsId() {
90         return nsId;
91     }
92
93     public void setNsId(String nsId) {
94         this.nsId = nsId;
95     }
96
97     public String getVnfmId() {
98         return vnfmId;
99     }
100
101     public void setVnfmId(String vnfmId) {
102         this.vnfmId = vnfmId;
103     }
104
105     public String getResponseDescriptor() {
106         return responseDescriptor;
107     }
108
109     public void setResponseDescriptor(String responseDescriptor) {
110         this.responseDescriptor = responseDescriptor;
111     }
112
113     public String getStatus() {
114         return status;
115     }
116
117     public void setStatus(String status) {
118         this.status = status;
119     }
120
121     public String getProgress() {
122         return progress;
123     }
124
125     public void setProgress(String progress) {
126         this.progress = progress;
127     }
128
129     public String getStatusDescription() {
130         return statusDescription;
131     }
132
133     public void setStatusDescription(String statusDescription) {
134         this.statusDescription = statusDescription;
135     }
136
137     public String getErrorCode() {
138         return errorCode;
139     }
140
141     public void setErrorCode(String errorCode) {
142         this.errorCode = errorCode;
143     }
144
145     public String getResponseId() {
146         return responseId;
147     }
148
149     public void setResponseId(String responseId) {
150         this.responseId = responseId;
151     }
152
153     public String getResponseHistoryList() {
154         return responseHistoryList;
155     }
156
157     public void setResponseHistoryList(String responseHistoryList) {
158         this.responseHistoryList = responseHistoryList;
159     }
160
161     public String getAddVm() {
162         return addVm;
163     }
164
165     public void setAddVm(String addVm) {
166         this.addVm = addVm;
167     }
168
169     public String getDelVm() {
170         return delVm;
171     }
172
173     public void setDelVm(String delVm) {
174         this.delVm = delVm;
175     }
176
177     public static VnfStatusEntity toEntity(JSONObject jsonObject) {
178         VnfStatusEntity vnfStatusEntity = new VnfStatusEntity();
179         vnfStatusEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId"));
180         vnfStatusEntity.setJobId(JsonUtil.getJsonFieldStr(jsonObject, "jobId"));
181         vnfStatusEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId"));
182         vnfStatusEntity.setVnfmId(JsonUtil.getJsonFieldStr(jsonObject, "vnfmId"));
183         vnfStatusEntity.setResponseDescriptor(JsonUtil.getJsonFieldStr(jsonObject, "responseDescriptor"));
184         vnfStatusEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status"));
185         vnfStatusEntity.setProgress(JsonUtil.getJsonFieldStr(jsonObject, "progress"));
186         vnfStatusEntity.setStatusDescription(JsonUtil.getJsonFieldStr(jsonObject, "statusDescription"));
187         vnfStatusEntity.setErrorCode(JsonUtil.getJsonFieldStr(jsonObject, "errorCode"));
188         vnfStatusEntity.setResponseId(JsonUtil.getJsonFieldStr(jsonObject, "responseId"));
189         vnfStatusEntity.setResponseHistoryList(JsonUtil.getJsonFieldStr(jsonObject, "responseHistoryList"));
190         vnfStatusEntity.setAddVm(JsonUtil.getJsonFieldStr(jsonObject, "addVm"));
191         vnfStatusEntity.setDelVm(JsonUtil.getJsonFieldStr(jsonObject, "delVm"));
192         return vnfStatusEntity;
193     }
194
195     @Override
196     public String toString() {
197         JSONObject vnfStatusResJson = new JSONObject();
198         vnfStatusResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId()));
199         vnfStatusResJson.put("jobId", StringUtils.trimToEmpty(this.getJobId()));
200         vnfStatusResJson.put("nsId", StringUtils.trimToEmpty(this.getNsId()));
201         vnfStatusResJson.put("vnfmId", StringUtils.trimToEmpty(this.getVnfmId()));
202         vnfStatusResJson.put("responseDescriptor", StringUtils.trimToEmpty(this.getResponseDescriptor()));
203         vnfStatusResJson.put("status", StringUtils.trimToEmpty(this.getStatus()));
204         vnfStatusResJson.put("progress", StringUtils.trimToEmpty(this.getProgress()));
205         vnfStatusResJson.put("statusDescription", StringUtils.trimToEmpty(this.getStatusDescription()));
206         vnfStatusResJson.put("errorCode", StringUtils.trimToEmpty(this.getErrorCode()));
207         vnfStatusResJson.put("responseId", StringUtils.trimToEmpty(this.getResponseId()));
208         vnfStatusResJson.put("responseHistoryList", StringUtils.trimToEmpty(this.getResponseHistoryList()));
209         vnfStatusResJson.put("addVm", StringUtils.trimToEmpty(this.getAddVm()));
210         vnfStatusResJson.put("delVm", StringUtils.trimToEmpty(this.getDelVm()));
211         return vnfStatusResJson.toString();
212     }
213 }