Merge "update spring version in MSOCommonBPMN"
[so.git] / adapters / mso-catalog-db-adapter / src / main / java / org / openecomp / mso / adapters / catalogdb / catalogrest / QueryVfModules.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.openecomp.mso.adapters.catalogdb.catalogrest;
22
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import javax.xml.bind.annotation.XmlRootElement;
27
28 import org.codehaus.jackson.map.ObjectMapper;
29 import org.jboss.resteasy.annotations.providers.NoJackson;
30
31 import org.openecomp.mso.db.catalog.beans.VfModule;
32 import org.openecomp.mso.logger.MsoLogger;
33
34 @XmlRootElement(name = "vfModules")
35 @NoJackson
36 public class QueryVfModules {
37         private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
38         private List<VfModule> vfModules;
39
40         public QueryVfModules() { super(); vfModules = new ArrayList<>(); }
41         public QueryVfModules(List<VfModule> vlist) { 
42                 LOGGER.debug ("QueryVfModules:");
43                 vfModules = new ArrayList<>();
44                 for (VfModule o : vlist) {
45                         LOGGER.debug ("-- o is a vfModules ----");
46                         LOGGER.debug (o.toString());
47                         vfModules.add(o);
48                         LOGGER.debug ("-------------------");
49                 }
50         }
51
52         public List<VfModule> getVfModules(){ return this.vfModules; }
53
54         public void setVfModules(List<VfModule> v) { this.vfModules = v; }
55         
56         @Override
57         public String toString () {
58                 StringBuilder buf = new StringBuilder();
59
60                 boolean first = true;
61                 int i = 1;
62                 for (VfModule o : vfModules) {
63                         buf.append(i+"\t");
64                         if (!first) buf.append("\n"); first = false;
65                         buf.append(o);
66                 }
67                 return buf.toString();
68     }
69         
70         public String toJsonString() {
71                 String jsonString = null;
72                 try {
73                         ObjectMapper mapper = new ObjectMapper();
74                         jsonString = mapper.writeValueAsString(this);
75                         LOGGER.debug ("QueryVfModules jsonString: "+jsonString);
76                 }
77                 catch (Exception e) {
78                     LOGGER.debug ("Exception:", e);
79                         LOGGER.debug ("QueryVfModules jsonString exception:"+e.getMessage()); 
80                 }
81                 return jsonString;
82         }
83 }