bp-gen code clone from cli repo
[dcaegen2/platform.git] / mod / bpgenerator / src / main / java / org / onap / blueprintgenerator / models / onapbp / OnapNode.java
1 /**============LICENSE_START======================================================= 
2  org.onap.dcae 
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 
9
10       http://www.apache.org/licenses/LICENSE-2.0 
11
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========================================================= 
18
19  */
20
21 package org.onap.blueprintgenerator.models.onapbp;
22
23 import java.util.LinkedHashMap;
24 import java.util.TreeMap;
25
26 import org.onap.blueprintgenerator.models.blueprint.Interfaces;
27 import org.onap.blueprintgenerator.models.blueprint.Node;
28 import org.onap.blueprintgenerator.models.blueprint.Properties;
29 import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
30
31 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
32 import com.fasterxml.jackson.annotation.JsonInclude;
33 import com.fasterxml.jackson.annotation.JsonInclude.Include;
34
35 import lombok.AllArgsConstructor;
36 import lombok.Builder;
37 import lombok.Getter; import lombok.Setter;
38 import lombok.EqualsAndHashCode;
39 import lombok.NoArgsConstructor;
40
41 @JsonIgnoreProperties(ignoreUnknown = true)
42 @Getter @Setter
43 @EqualsAndHashCode(callSuper=false)
44 @NoArgsConstructor
45 @JsonInclude(value=Include.NON_NULL)
46
47 public class OnapNode extends Node{
48         private TreeMap<String, Interfaces> interfaces;
49         private Properties properties;
50         public TreeMap<String, LinkedHashMap<String, Object>> createOnapNode(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
51                 TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
52                 retInputs = inps;
53
54                 //create and set the interfaces
55                 Interfaces inter = new Interfaces();
56                 retInputs = inter.createInterface(retInputs, cs);
57                 TreeMap<String, Interfaces> interfaces = new TreeMap<String, Interfaces>();
58                 interfaces.put("cloudify.interfaces.lifecycle", inter);
59                 this.setInterfaces(interfaces);
60
61                 //set the type
62                 this.setType("dcae.nodes.ContainerizedPlatformComponent");
63
64                 //set the properties
65                 Properties props = new Properties();
66                 retInputs = props.createOnapProperties(retInputs, cs, override);
67                 this.setProperties(props);
68
69                 return retInputs;
70         }
71 }