2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (c) 2019, CMCC Technologies Co., Ltd.
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=========================================================
21 package org.onap.so.adapters.catalogdb.catalogrest;
23 import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26 import javax.xml.bind.annotation.XmlRootElement;
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.List;
32 @XmlRootElement(name = "serviceProxyCustomizations")
33 public class QueryServiceProxyCustomization extends CatalogQuery {
35 protected static Logger logger = LoggerFactory.getLogger(QueryServiceProxyCustomization.class);
37 private List<ServiceProxyResourceCustomization> serviceProxyResourceCustomizationList;
39 private static final String TEMPLATE =
40 "\t{\n" + "\t\t\"modelInfo\" : {\n" + "\t\t\t\"modelName\" : <MODEL_NAME>,\n"
41 + "\t\t\t\"modelUuid\" : <MODEL_UUID>,\n"
42 + "\t\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_UUID>,\n"
43 + "\t\t\t\"modelVersion\" : <MODEL_VERSION>,\n"
44 + "\t\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>,\n"
45 + "\t\t\t\"modelInstanceName\" : <MODEL_INSTANCE_NAME>\n" + "\t},\n"
46 + "\t\t\"toscaNodeType\" : <TOSCA_NODE_TYPE>,\n"
47 + "\t\t\"description\" : <DESCRIPTION>,\n"
48 + "\t\t\"sourceModelUuid\" : <SOURCE_SERVICE_MODEL_UUID>\n" + "\t}";
50 public QueryServiceProxyCustomization() {
52 this.serviceProxyResourceCustomizationList = new ArrayList<>();
55 public QueryServiceProxyCustomization(
56 List<ServiceProxyResourceCustomization> serviceProxyResourceCustomizationList) {
57 this.serviceProxyResourceCustomizationList = serviceProxyResourceCustomizationList;
61 public String toString() {
62 StringBuilder sb = new StringBuilder();
66 for (ServiceProxyResourceCustomization o : serviceProxyResourceCustomizationList) {
67 sb.append(i).append("\t");
78 public String JSON2(boolean isArray, boolean isEmbed) {
79 StringBuilder sb = new StringBuilder();
80 if (!isEmbed && isArray)
83 sb.append("\"serviceProxy\": [");
84 Map<String, String> valueMap = new HashMap<>();
88 if (this.serviceProxyResourceCustomizationList != null) {
89 for (ServiceProxyResourceCustomization o : serviceProxyResourceCustomizationList) {
95 boolean arNull = o == null;
97 put(valueMap, "MODEL_CUSTOMIZATION_UUID", arNull ? null : o.getModelCustomizationUUID());
98 put(valueMap, "MODEL_INSTANCE_NAME", arNull ? null : o.getModelInstanceName());
99 put(valueMap, "MODEL_UUID", arNull ? null : o.getModelUUID());
100 put(valueMap, "MODEL_INVARIANT_UUID", arNull ? null : o.getModelInvariantUUID());
101 put(valueMap, "MODEL_VERSION", arNull ? null : o.getModelVersion());
102 put(valueMap, "MODEL_NAME", arNull ? null : o.getModelName());
103 put(valueMap, "TOSCA_NODE_TYPE", arNull ? null : o.getToscaNodeType());
104 put(valueMap, "DESCRIPTION", arNull ? null : o.getDescription());
105 put(valueMap, "SOURCE_SERVICE_MODEL_UUID", (String) (arNull ? null
106 : o.getSourceService() == null ? null : o.getSourceService().getModelUUID()));
108 sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
118 if (!isEmbed && isArray)
121 return sb.toString();