2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.onap.so.adapters.catalogdb.catalogrest;
22 import java.util.HashMap;
24 import org.onap.so.db.catalog.beans.ToscaCsar;
27 * serivce csar query support <br>
32 * @version ONAP Beijing Release 2018-02-28
34 public class QueryServiceCsar extends CatalogQuery {
36 private static final String TEMPLATE = "\t{\n" + "\t\t\"artifactUUID\" : <ARTIFACT_UUID>,\n"
37 + "\t\t\"name\" : <NAME>,\n" + "\t\t\"version\" : <VERSION>,\n"
38 + "\t\t\"artifactChecksum\" : <ARTIFACT_CHECK_SUM>,\n" + "\t\t\"url\" : <URL>,\n"
39 + "\t\t\"description\" : <DESCRIPTION>\n" + "\t}";
41 private ToscaCsar toscaCsar;
43 public QueryServiceCsar(ToscaCsar toscaCsar) {
44 this.toscaCsar = toscaCsar;
48 public String toString() {
49 return toscaCsar.toString();
53 public String JSON2(boolean isArray, boolean isEmbed) {
54 Map<String, String> valueMap = new HashMap<>();
55 put(valueMap, "ARTIFACT_UUID", null == toscaCsar ? null : toscaCsar.getArtifactUUID());
56 put(valueMap, "NAME", null == toscaCsar ? null : toscaCsar.getName());
57 put(valueMap, "VERSION", null == toscaCsar ? null : toscaCsar.getVersion());
58 put(valueMap, "ARTIFACT_CHECK_SUM", null == toscaCsar ? null : toscaCsar.getArtifactChecksum());
59 put(valueMap, "URL", null == toscaCsar ? null : toscaCsar.getUrl());
60 put(valueMap, "DESCRIPTION", null == toscaCsar ? null : toscaCsar.getDescription());
61 return this.setTemplate(TEMPLATE, valueMap);