[SO] Release so 1.13.0 image
[so.git] / adapters / mso-catalog-db-adapter / src / main / java / org / onap / so / adapters / catalogdb / catalogrest / QueryServiceCsar.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20 package org.onap.so.adapters.catalogdb.catalogrest;
21
22 import java.util.HashMap;
23 import java.util.Map;
24 import org.onap.so.db.catalog.beans.ToscaCsar;
25
26 /**
27  * serivce csar query support <br>
28  * <p>
29  * </p>
30  * 
31  * @author
32  * @version ONAP Beijing Release 2018-02-28
33  */
34 public class QueryServiceCsar extends CatalogQuery {
35
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}";
40
41     private ToscaCsar toscaCsar;
42
43     public QueryServiceCsar(ToscaCsar toscaCsar) {
44         this.toscaCsar = toscaCsar;
45     }
46
47     @Override
48     public String toString() {
49         return toscaCsar.toString();
50     }
51
52     @Override
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);
62     }
63
64 }