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.Dictionary;
36 import org.onap.clamp.tosca.DictionaryElement;
37 import org.onap.clamp.tosca.DictionaryService;
38 import org.springframework.beans.factory.annotation.Autowired;
39 import org.springframework.stereotype.Component;
42 * This class is used to execute a code based on a key found in the metadata section.
45 public class ToscaMetadataExecutor {
47 private static final EELFLogger logger =
48 EELFManager.getInstance().getLogger(ToscaMetadataExecutor.class);
51 private DictionaryService dictionaryService;
53 private Map<String, ToscaMetadataProcess> mapOfProcesses = new HashMap<>();
56 * This method executes the required process specified in processInfo
58 * @param processInfo A String containing the process to execute, like "cds/param1:value1/param2:value2"
59 * @param childObject The jsonObject
60 * @param serviceModel The service model associated to do clamp enrichment
62 public void executeTheProcess(String processInfo, JsonObject childObject, Service serviceModel) {
63 String[] processParameters = (processInfo + "/ ").split("/");
64 logger.info("Executing the Tosca clamp process " + processParameters[0] + " with parameters "
65 + processParameters[1].trim());
66 mapOfProcesses.get(processParameters[0]).executeProcess(processParameters[1].trim(), childObject, serviceModel);
74 mapOfProcesses.put("CDS", new ToscaMetadataCdsProcess());
75 mapOfProcesses.put("CSAR_RESOURCES", new ToscaMetadataTargetProcess());
77 preProvisionDictionaryTable();
80 private void preProvisionDictionaryTable() {
81 // Set up dictionary elements
82 Dictionary actorDictionary = new Dictionary();
83 actorDictionary.setName("DefaultActor");
84 actorDictionary.setSecondLevelDictionary(0);
85 actorDictionary.setSubDictionaryType("");
87 DictionaryElement elementSo = new DictionaryElement();
88 elementSo.setName("SO");
89 elementSo.setShortName("SO");
90 elementSo.setType("string");
91 elementSo.setDescription("SO component");
92 actorDictionary.addDictionaryElements(elementSo);
94 DictionaryElement elementSdnc = new DictionaryElement();
95 elementSdnc.setName("SDNC");
96 elementSdnc.setShortName("SDNC");
97 elementSdnc.setType("string");
98 elementSdnc.setDescription("SDNC component");
99 actorDictionary.addDictionaryElements(elementSdnc);
101 DictionaryElement elementCds = new DictionaryElement();
102 elementCds.setName("CDS");
103 elementCds.setShortName("CDS");
104 elementCds.setType("string");
105 elementCds.setDescription("CDS component");
106 actorDictionary.addDictionaryElements(elementCds);
108 dictionaryService.saveOrUpdateDictionary(actorDictionary);