2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 package org.onap.clamp.clds.tosca.update.execution;
26 import com.att.eelf.configuration.EELFLogger;
27 import com.att.eelf.configuration.EELFManager;
28 import com.google.gson.JsonObject;
29 import java.util.HashMap;
31 import javax.annotation.PostConstruct;
32 import org.onap.clamp.clds.tosca.update.execution.cds.ToscaMetadataCdsProcess;
33 import org.onap.clamp.clds.tosca.update.execution.target.ToscaMetadataTargetProcess;
34 import org.onap.clamp.loop.service.Service;
35 import org.onap.clamp.tosca.DictionaryService;
36 import org.springframework.beans.factory.annotation.Autowired;
37 import org.springframework.stereotype.Component;
40 * This class is used to execute a code based on a key found in the metadata section.
43 public class ToscaMetadataExecutor {
45 private static final EELFLogger logger =
46 EELFManager.getInstance().getLogger(ToscaMetadataExecutor.class);
49 private DictionaryService dictionaryService;
51 private Map<String, ToscaMetadataProcess> mapOfProcesses = new HashMap<>();
54 * This method executes the required process specified in processInfo
56 * @param processInfo A String containing the process to execute, like "cds/param1:value1/param2:value2"
57 * @param childObject The jsonObject
58 * @param serviceModel The service model associated to do clamp enrichment
60 public void executeTheProcess(String processInfo, JsonObject childObject, Service serviceModel) {
61 String[] processParameters = (processInfo + "/ ").split("/");
62 logger.info("Executing the Tosca clamp process " + processParameters[0] + " with parameters "
63 + processParameters[1].trim());
64 mapOfProcesses.get(processParameters[0]).executeProcess(processParameters[1].trim(), childObject, serviceModel);
72 mapOfProcesses.put("CDS", new ToscaMetadataCdsProcess());
73 mapOfProcesses.put("CSAR_RESOURCES", new ToscaMetadataTargetProcess());