2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.openecomp.mso.adapters.catalogdb.catalogrest;
22 import org.openecomp.mso.db.catalog.beans.VfModule;
23 import org.jboss.resteasy.annotations.providers.NoJackson;
25 import javax.xml.bind.annotation.XmlRootElement;
26 import java.util.ArrayList;
27 import java.util.HashMap;
28 import java.util.List;
31 @XmlRootElement(name = "vfModules")
33 public class QueryVfModule extends CatalogQuery {
34 private List<VfModule> vfModules;
35 private final String template =
36 "\t{ \"vfModule\" : { \n"+
37 "\t\t\"modelName\" : <MODEL_NAME>,\n"+
38 "\t\t\"modelUuid\" : <MODEL_UUID>,\n"+
39 "\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_ID>,\n"+
40 "\t\t\"modelVersion\" : <MODEL_VERSION>,\n"+
41 "\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>,\n"+
42 "\t\t\"vfModuleType\" : <VF_MODULE_TYPE>,\n"+
43 "\t\t\"isBase\" : <IS_BASE>,\n"+
44 "\t\t\"vfModuleLabel\" : <VF_MODULE_LABEL>,\n"+
45 "\t\t\"initialCount\" : <INITIAL_COUNT>\n"+
48 public QueryVfModule() { super(); vfModules = new ArrayList<VfModule>(); }
49 public QueryVfModule(List<VfModule> vlist) {
50 LOGGER.debug ("QueryVfModule:");
51 vfModules = new ArrayList<VfModule>();
52 for (VfModule o : vlist) {
53 LOGGER.debug ("-- o is a vfModules ----");
54 LOGGER.debug (o.toString());
56 LOGGER.debug ("-------------------");
60 public List<VfModule> getVfModule(){ return this.vfModules; }
61 public void setVfModule(List<VfModule> v) { this.vfModules = v; }
64 public String toString () {
65 StringBuffer buf = new StringBuffer();
69 for (VfModule o : vfModules) {
71 if (!first) buf.append("\n"); first = false;
74 return buf.toString();
78 public String JSON2(boolean isArray, boolean x) {
79 StringBuffer buf = new StringBuffer();
80 if (isArray) buf.append("\"vfModules\": [");
81 Map<String, String> valueMap = new HashMap<String, String>();
85 for (VfModule o : vfModules) {
86 if (first) buf.append("\n"); first = false;
88 put(valueMap, "MODEL_NAME", o.getModelName());
89 put(valueMap, "MODEL_UUID", o.getModelUuid());
90 put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantId());
91 put(valueMap, "MODEL_VERSION", o.getModelVersion());
92 put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid());
93 put(valueMap, "VF_MODULE_TYPE", o.getVfModuleType());
94 put(valueMap, "IS_BASE", new Boolean(o.isBase()? true: false));
95 put(valueMap, "VF_MODULE_LABEL", o.getVfModuleLabel());
96 put(valueMap, "INITIAL_COUNT", o.getInitialCount());
98 buf.append(sep+ this.setTemplate(template, valueMap));
101 if (!first) buf.append("\n");
102 if (isArray) buf.append("]");
103 return buf.toString();