2 * ============LICENSE_START=======================================================
\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
11 * http://www.apache.org/licenses/LICENSE-2.0
\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
20 package org.openecomp.mso.adapters.catalogdb.catalogrest;
\r
22 import java.util.HashMap;
\r
23 import java.util.Map;
\r
25 import org.openecomp.mso.db.catalog.beans.Recipe;
\r
27 import com.fasterxml.jackson.core.JsonProcessingException;
\r
28 import com.fasterxml.jackson.databind.ObjectMapper;
\r
29 import com.fasterxml.jackson.databind.SerializationFeature;
\r
32 * serivce csar query support
\r
38 * @version ONAP Beijing Release 2018-02-28
\r
40 public class QueryResourceRecipe extends CatalogQuery{
\r
42 private Recipe resourceRecipe;
\r
44 public QueryResourceRecipe(Recipe resourceRecipe){
\r
45 this.resourceRecipe =resourceRecipe;
\r
49 public String toString() {
\r
51 return resourceRecipe.toString();
\r
55 public String JSON2(boolean isArray, boolean isEmbed) {
\r
57 Map<String, String> valueMap = new HashMap<>();
\r
58 valueMap.put("id", null == resourceRecipe ? null :String.valueOf(resourceRecipe.getId()));
\r
59 valueMap.put("action", null == resourceRecipe ? null :resourceRecipe.getAction());
\r
60 valueMap.put("orchestrationUri", null == resourceRecipe ? null : resourceRecipe.getOrchestrationUri());
\r
61 valueMap.put("recipeTimeout", null == resourceRecipe ? null : String.valueOf(resourceRecipe.getRecipeTimeout()));
\r
62 valueMap.put("paramXSD", null == resourceRecipe ? null : resourceRecipe.getParamXSD());
\r
63 valueMap.put("description", null == resourceRecipe ? null : resourceRecipe.getDescription());
\r
64 ObjectMapper mapper = new ObjectMapper();
\r
65 mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
\r
66 String jsonStr = "";
\r
68 jsonStr = mapper.writeValueAsString(valueMap);
\r
69 } catch(JsonProcessingException e) {
\r
71 e.printStackTrace();
\r