5be697055473cc0e02479dbc8529981dfa6edfb7
[so.git] /
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP - SO\r
4  * ================================================================================\r
5  * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  *\r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 package org.openecomp.mso.adapters.catalogdb.catalogrest;\r
21 \r
22 import java.util.HashMap;\r
23 import java.util.Map;\r
24 \r
25 import org.openecomp.mso.db.catalog.beans.Recipe;\r
26 \r
27 /**\r
28  * serivce csar query support \r
29  * <br>\r
30  * <p>\r
31  * </p>\r
32  * \r
33  * @author\r
34  * @version     ONAP Beijing Release  2018-02-28\r
35  */\r
36 public class QueryResourceRecipe extends CatalogQuery{\r
37     \r
38     private Recipe resourceRecipe;\r
39     \r
40     public QueryResourceRecipe(Recipe resourceRecipe){\r
41         this.resourceRecipe =resourceRecipe;\r
42     }\r
43 \r
44     private final String template =\r
45             "\t{\n"+\r
46             "\t\t\"id\"                     : <ID>,\n"+\r
47             "\t\t\"action\"                 : <ACTION>,\n"+\r
48             "\t\t\"orchestrationUri\"       : <ORCHESTRATION_URI>,\n"+\r
49             "\t\t\"recipeTimeout\"          : <RECIPE_TIMEOUT>,\n"+\r
50             "\t\t\"paramXSD\"               : <PARAM_XSD>,\n"+\r
51             "\t\t\"description\"            : <DESCRIPTION>\n"+\r
52             "\t}";\r
53     \r
54     @Override\r
55     public String toString() {\r
56 \r
57         return resourceRecipe.toString();\r
58     }\r
59 \r
60     @Override\r
61     public String JSON2(boolean isArray, boolean isEmbed) {\r
62         Map<String, String> valueMap = new HashMap<>();\r
63         put(valueMap, "ID", null == resourceRecipe ? null : resourceRecipe.getId());\r
64         put(valueMap, "ACTION", null == resourceRecipe ? null : resourceRecipe.getAction());\r
65         put(valueMap, "ORCHESTRATION_URI", null == resourceRecipe ? null : resourceRecipe.getOrchestrationUri());\r
66         put(valueMap, "RECIPE_TIMEOUT", null == resourceRecipe ? null : resourceRecipe.getRecipeTimeout());\r
67         put(valueMap, "PARAM_XSD", null == resourceRecipe ? null : resourceRecipe.getParamXSD());\r
68         put(valueMap, "DESCRIPTION", null == resourceRecipe ? null : resourceRecipe.getDescription());\r
69         return this.setTemplate(template, valueMap);\r
70     }\r
71 \r
72 }\r