re base code
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / InterfaceData.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.resources.data;
22
23 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
24 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
25 import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
26 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
27
28 import java.util.HashMap;
29 import java.util.Map;
30
31 public class InterfaceData extends GraphNode {
32
33         private InterfaceDataDefinition interfaceDataDefinition;
34
35         public InterfaceData() {
36                 super(NodeTypeEnum.Interface);
37                 interfaceDataDefinition = new InterfaceDataDefinition();
38
39         }
40
41         public InterfaceData(InterfaceData p) {
42                 super(NodeTypeEnum.Interface);
43                 interfaceDataDefinition = p.getInterfaceDataDefinition();
44
45         }
46
47         public InterfaceData(InterfaceDataDefinition interfaceDataDefinition) {
48                 super(NodeTypeEnum.Interface);
49                 this.interfaceDataDefinition = interfaceDataDefinition;
50
51         }
52
53         public InterfaceData(Map<String, Object> properties) {
54                 this();
55                 interfaceDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
56                 interfaceDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
57                 interfaceDataDefinition
58                                 .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
59                 interfaceDataDefinition
60                                 .setCreationDate((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
61                 interfaceDataDefinition
62                                 .setLastUpdateDate((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
63         }
64
65         public InterfaceDataDefinition getInterfaceDataDefinition() {
66                 return interfaceDataDefinition;
67         }
68
69         public void setInterfaceDataDefinition(InterfaceDataDefinition interfaceDataDefinition) {
70                 this.interfaceDataDefinition = interfaceDataDefinition;
71         }
72
73         @Override
74         public String getUniqueId() {
75                 return interfaceDataDefinition.getUniqueId();
76         }
77
78         @Override
79         public Map<String, Object> toGraphMap() {
80                 Map<String, Object> map = new HashMap<>();
81
82                 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, interfaceDataDefinition.getUniqueId());
83                 addIfExists(map, GraphPropertiesDictionary.TYPE, interfaceDataDefinition.getType());
84                 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, interfaceDataDefinition.getCreationDate());
85                 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, interfaceDataDefinition.getLastUpdateDate());
86                 addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, interfaceDataDefinition.getDescription());
87
88                 return map;
89         }
90
91 }