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.AllottedResourceCustomization;
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 = "serviceAllottedResources")
33 public class QueryAllottedResourceCustomization extends CatalogQuery {
34 private List<AllottedResourceCustomization> allottedResourceCustomization;
35 private final String template =
36 "\t{ \"allottedResource\" : {\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\"modelInstanceName\" : <MODEL_INSTANCE_NAME>\n"+
45 public QueryAllottedResourceCustomization() { super(); allottedResourceCustomization = new ArrayList<AllottedResourceCustomization>(); }
46 public QueryAllottedResourceCustomization(List<AllottedResourceCustomization> vlist) { allottedResourceCustomization = vlist; }
48 public List<AllottedResourceCustomization> getServiceAllottedResources(){ return this.allottedResourceCustomization; }
49 public void setServiceAllottedResources(List<AllottedResourceCustomization> v) { this.allottedResourceCustomization = v; }
52 public String toString () {
53 StringBuffer buf = new StringBuffer();
57 for (AllottedResourceCustomization o : allottedResourceCustomization) {
59 if (!first) buf.append("\n"); first = false;
62 return buf.toString();
66 public String JSON2(boolean isArray, boolean isEmbed) {
67 StringBuffer buf = new StringBuffer();
68 if (!isEmbed && isArray) buf.append("{ ");
69 if (isArray) buf.append("\"serviceAllottedResources\": [");
70 Map<String, String> valueMap = new HashMap<String, String>();
74 for (AllottedResourceCustomization o : allottedResourceCustomization) {
75 if (first) buf.append("\n"); first = false;
77 put(valueMap, "MODEL_NAME", o.getModelName());
78 put(valueMap, "MODEL_UUID", o.getModelUuid());
79 put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantId());
80 put(valueMap, "MODEL_VERSION", o.getModelVersion());
81 put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid());
82 put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName());
84 buf.append(sep+ this.setTemplate(template, valueMap));
87 if (!first) buf.append("\n");
88 if (isArray) buf.append("]");
89 if (!isEmbed && isArray) buf.append("}");
90 return buf.toString();