5d9b7ce5581bf31b714f14702c19160dc82fed25
[so.git] / adapters / mso-vfc-adapter / src / main / java / org / onap / so / adapters / vfc / model / NSResourceInputParameter.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
6  * Copyright (C) 2018 CMCC All rights reserved.
7  * Modifications Copyright (c) 2019 Samsung
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.so.adapters.vfc.model;
24
25 import java.io.ByteArrayOutputStream;
26
27 import javax.xml.bind.JAXBContext;
28 import javax.xml.bind.Marshaller;
29
30 import com.fasterxml.jackson.databind.ObjectMapper;
31 import com.fasterxml.jackson.databind.SerializationFeature;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34
35 /**
36  * NS Create Input Parameter For VFC Adapter<br>
37  * <p>
38  * </p>
39  * 
40  * @version ONAP Amsterdam Release 2017/1/7
41  */
42 public class NSResourceInputParameter {
43
44     private static final Logger logger = LoggerFactory.getLogger(NSResourceInputParameter.class);
45     
46     private NsOperationKey nsOperationKey;
47
48     private String nsServiceName;
49
50     private String nsServiceDescription;
51     
52     private String nsServiceModelUUID;
53
54     private NsParameters nsParameters;
55
56     private NsScaleParameters nsScaleParameters;
57
58     
59     /**
60      * @return Returns the nsServiceName.
61      */
62     public String getNsServiceName() {
63         return nsServiceName;
64     }
65
66     
67     /**
68      * @param nsServiceName The nsServiceName to set.
69      */
70     public void setNsServiceName(String nsServiceName) {
71         this.nsServiceName = nsServiceName;
72     }
73
74     
75     /**
76      * @return Returns the nsServiceDescription.
77      */
78     public String getNsServiceDescription() {
79         return nsServiceDescription;
80     }
81
82     
83     /**
84      * @param nsServiceDescription The nsServiceDescription to set.
85      */
86     public void setNsServiceDescription(String nsServiceDescription) {
87         this.nsServiceDescription = nsServiceDescription;
88     }
89
90     /**
91      * @return Returns the nsParameters.
92      */
93     public NsParameters getNsParameters() {
94         return nsParameters;
95     }
96
97     /**
98      * @param nsParameters The nsParameters to set.
99      */
100     public void setNsParameters(NsParameters nsParameters) {
101         this.nsParameters = nsParameters;
102     }
103
104     public NsOperationKey getNsOperationKey() {
105         return nsOperationKey;
106     }
107
108     public void setNsOperationKey(NsOperationKey nsOperationKey) {
109         this.nsOperationKey = nsOperationKey;
110     }
111     public String toJsonString() {
112         String jsonString = null;
113         try {
114             ObjectMapper mapper = new ObjectMapper();
115             mapper.enable(SerializationFeature.WRAP_ROOT_VALUE);
116             jsonString = mapper.writeValueAsString(this);
117         } catch (Exception e) {
118             logger.debug("Exception:", e);
119         }
120         return jsonString;
121     }
122
123     public String toXmlString() {
124         try {
125             ByteArrayOutputStream bs = new ByteArrayOutputStream();
126             JAXBContext context = JAXBContext.newInstance(this.getClass());
127             Marshaller marshaller = context.createMarshaller();
128             marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); //pretty print XML
129             marshaller.marshal(this, bs);
130             return bs.toString();
131         } catch (Exception e) {
132             logger.debug("Exception:", e);
133             return "";
134         }
135     }
136
137     public NsScaleParameters getNsScaleParameters() {
138         return nsScaleParameters;
139     }
140
141     public void setNsScaleParameters(NsScaleParameters nsScaleParameters) {
142         this.nsScaleParameters = nsScaleParameters;
143     }
144
145
146         public String getNsServiceModelUUID() {
147                 return nsServiceModelUUID;
148         }
149
150
151         public void setNsServiceModelUUID(String nsServiceModelUUID) {
152                 this.nsServiceModelUUID = nsServiceModelUUID;
153         }
154     
155 }