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