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;
25 import org.onap.so.db.catalog.beans.ToscaCsar;
28 * serivce csar query support
34 * @version ONAP Beijing Release 2018-02-28
36 public class QueryServiceCsar extends CatalogQuery{
38 private ToscaCsar toscaCsar;
40 public QueryServiceCsar(ToscaCsar toscaCsar){
41 this.toscaCsar = toscaCsar;
44 private final String template =
46 "\t\t\"artifactUUID\" : <ARTIFACT_UUID>,\n"+
47 "\t\t\"name\" : <NAME>,\n"+
48 "\t\t\"version\" : <VERSION>,\n"+
49 "\t\t\"artifactChecksum\" : <ARTIFACT_CHECK_SUM>,\n"+
50 "\t\t\"url\" : <URL>,\n"+
51 "\t\t\"description\" : <DESCRIPTION>\n"+
55 public String toString() {
57 return toscaCsar.toString();
61 public String JSON2(boolean isArray, boolean isEmbed) {
62 Map<String, String> valueMap = new HashMap<>();
63 put(valueMap, "ARTIFACT_UUID", null == toscaCsar ? null : toscaCsar.getArtifactUUID());
64 put(valueMap, "NAME", null == toscaCsar ? null : toscaCsar.getName());
65 put(valueMap, "VERSION", null == toscaCsar ? null : toscaCsar.getVersion());
66 put(valueMap, "ARTIFACT_CHECK_SUM", null == toscaCsar ? null : toscaCsar.getArtifactChecksum());
67 put(valueMap, "URL", null == toscaCsar ? null : toscaCsar.getUrl());
68 put(valueMap, "DESCRIPTION", null == toscaCsar ? null : toscaCsar.getDescription());
69 return this.setTemplate(template, valueMap);