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{
52 public TreeMap<String, LinkedHashMap<String, Object>> createOnapNode(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
53 TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
56 //create and set the interfaces
57 Interfaces inter = new Interfaces();
58 retInputs = inter.createInterface(retInputs, cs);
59 TreeMap<String, Interfaces> interfaces = new TreeMap<String, Interfaces>();
60 interfaces.put("cloudify.interfaces.lifecycle", inter);
61 this.setInterfaces(interfaces);
64 this.setType("dcae.nodes.ContainerizedServiceComponent");
66 //create and set the relationships
67 ArrayList<LinkedHashMap<String, String>> rets = new ArrayList();
69 //add relationship for policy if exist
70 if(cs.getPolicyInfo() != null){
71 ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder.getPolicyRelationships(cs);
72 rets.addAll(policyRelationshipsList);
75 //add relationships and env_variables for pgaas dbs if exist
76 if(cs.getAuxilary().getDatabases() != null){
77 ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder.getPgaasNodeRelationships(cs);
78 rets.addAll(pgaasRelationshipsList);
81 this.setRelationships(rets);
84 Properties props = new Properties();
85 retInputs = props.createOnapProperties(retInputs, cs, override);
86 this.setProperties(props);