aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/GlobalSubstitutionServiceTemplate.java
blob: 2d33748e265f0fcfa8b1e6b0b670f3192fcdec0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package org.openecomp.core.impl;

import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.model.Import;
import org.openecomp.sdc.tosca.datatypes.model.NodeType;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GlobalSubstitutionServiceTemplate extends ServiceTemplate {
    private static final Logger logger = LoggerFactory.getLogger(ServiceTemplate.class);

    public static final String GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME = "GlobalSubstitutionServiceTemplate.yaml";
    public static final String TEMPLATE_NAME_PROPERTY = "template_name";
    public static final String DEFININTION_VERSION = "tosca_simple_yaml_1_0_0";
    public static final String HEAT_INDEX = "openecomp_heat_index";

    public GlobalSubstitutionServiceTemplate() {
        super();
        init();
    }


    public void appendNodes(Map<String, NodeType> nodes) {
        getNode_types().putAll(nodes);
    }

    public void init()   {
        writeDefinitionSection();
        writeMetadataSection();
        writeImportsSection();
        setNode_types(new HashMap<>());
    }

    private void writeImportsSection() {
        List<Map<String, Import>> imports = new ArrayList<>();
        Map<String, Import> stringImportMap = new HashMap<>();
        imports.add(stringImportMap);
        setImports(imports);
        Import imprtObj = new Import();
        imprtObj.setFile("openecomp-heat/_index.yml");
        stringImportMap.put("openecomp_heat_index", imprtObj);
    }


    private void writeMetadataSection() {
        Map<String, String> metadata = new HashMap<>();
        metadata.put(TEMPLATE_NAME_PROPERTY, "GlobalSubstitutionTypes");
        setMetadata(metadata);
    }

    private void writeDefinitionSection() {
        setTosca_definitions_version(DEFININTION_VERSION);
    }
}