1 /*============LICENSE_START=======================================================
3 ================================================================================
4 Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
5 ================================================================================
6 Modifications Copyright (c) 2020 Nokia. All rights reserved.
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=========================================================
23 package org.onap.blueprintgenerator.models.onapbp;
25 import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CONTENERIZED_SERVICE_COMPONENT;
27 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
28 import com.fasterxml.jackson.annotation.JsonInclude;
29 import com.fasterxml.jackson.annotation.JsonInclude.Include;
30 import java.util.ArrayList;
31 import java.util.LinkedHashMap;
32 import java.util.TreeMap;
33 import lombok.EqualsAndHashCode;
35 import lombok.NoArgsConstructor;
37 import org.onap.blueprintgenerator.core.PgaasNodeBuilder;
38 import org.onap.blueprintgenerator.core.PolicyNodeBuilder;
39 import org.onap.blueprintgenerator.models.blueprint.Interfaces;
40 import org.onap.blueprintgenerator.models.blueprint.Node;
41 import org.onap.blueprintgenerator.models.blueprint.Properties;
42 import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
44 @JsonIgnoreProperties(ignoreUnknown = true)
47 @EqualsAndHashCode(callSuper = false)
49 @JsonInclude(value = Include.NON_NULL)
51 public class OnapNode extends Node {
53 public TreeMap<String, LinkedHashMap<String, Object>> createOnapNode(
54 TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
55 TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
58 //create and set the interfaces
59 Interfaces inter = new Interfaces();
60 retInputs = inter.createInterface(retInputs, cs);
61 TreeMap<String, Interfaces> interfaces = new TreeMap<String, Interfaces>();
62 interfaces.put("cloudify.interfaces.lifecycle", inter);
63 this.setInterfaces(interfaces);
66 this.setType(CONTENERIZED_SERVICE_COMPONENT);
68 //create and set the relationships
69 ArrayList<LinkedHashMap<String, String>> rets = new ArrayList();
71 //add relationship for policy if exist
72 if (cs.getPolicyInfo() != null) {
73 ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder
74 .getPolicyRelationships(cs);
75 rets.addAll(policyRelationshipsList);
78 //add relationships and env_variables for pgaas dbs if exist
79 if (cs.getAuxilary().getDatabases() != null) {
80 ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder
81 .getPgaasNodeRelationships(cs);
82 rets.addAll(pgaasRelationshipsList);
85 this.setRelationships(rets);
88 Properties props = new Properties();
89 retInputs = props.createOnapProperties(retInputs, cs, override);
90 this.setProperties(props);