1 /**============LICENSE_START=======================================================
3 ================================================================================
4 Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
5 ================================================================================
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ============LICENSE_END=========================================================
21 package org.onap.blueprintgenerator.models.onapbp;
23 import java.util.ArrayList;
24 import java.util.LinkedHashMap;
25 import java.util.TreeMap;
27 import org.onap.blueprintgenerator.core.PgaasNodeBuilder;
28 import org.onap.blueprintgenerator.core.PolicyNodeBuilder;
29 import org.onap.blueprintgenerator.models.blueprint.Interfaces;
30 import org.onap.blueprintgenerator.models.blueprint.Node;
31 import org.onap.blueprintgenerator.models.blueprint.Properties;
32 import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
34 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
35 import com.fasterxml.jackson.annotation.JsonInclude;
36 import com.fasterxml.jackson.annotation.JsonInclude.Include;
38 import lombok.AllArgsConstructor;
39 import lombok.Builder;
40 import lombok.Getter; import lombok.Setter;
41 import lombok.EqualsAndHashCode;
42 import lombok.NoArgsConstructor;
44 @JsonIgnoreProperties(ignoreUnknown = true)
46 @EqualsAndHashCode(callSuper=false)
48 @JsonInclude(value=Include.NON_NULL)
50 public class OnapNode extends Node{
51 private TreeMap<String, Interfaces> interfaces;
52 private Properties properties;
53 private ArrayList<LinkedHashMap<String, String>> relationships;
55 public TreeMap<String, LinkedHashMap<String, Object>> createOnapNode(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
56 TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
59 //create and set the interfaces
60 Interfaces inter = new Interfaces();
61 retInputs = inter.createInterface(retInputs, cs);
62 TreeMap<String, Interfaces> interfaces = new TreeMap<String, Interfaces>();
63 interfaces.put("cloudify.interfaces.lifecycle", inter);
64 this.setInterfaces(interfaces);
67 this.setType("dcae.nodes.ContainerizedServiceComponent");
69 //create and set the relationships
70 ArrayList<LinkedHashMap<String, String>> rets = new ArrayList();
72 //add relationship for policy if exist
73 if(cs.getPolicyInfo() != null){
74 ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder.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.getPgaasNodeRelationships(cs);
81 rets.addAll(pgaasRelationshipsList);
84 this.setRelationships(rets);
87 Properties props = new Properties();
88 retInputs = props.createOnapProperties(retInputs, cs, override);
89 this.setProperties(props);