4f3c4c0e6315d4a5b2c3c2a7f3ea37d31201447d
[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 package org.openecomp.sdc.be.resources.data;
21
22 import java.util.HashMap;
23 import java.util.Map;
24 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
25 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
26 import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
27 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
28
29 public class InterfaceData extends GraphNode {
30
31     private InterfaceDataDefinition interfaceDataDefinition;
32
33     public InterfaceData() {
34         super(NodeTypeEnum.Interface);
35         interfaceDataDefinition = new InterfaceDataDefinition();
36     }
37
38     public InterfaceData(InterfaceData p) {
39         super(NodeTypeEnum.Interface);
40         interfaceDataDefinition = p.getInterfaceDataDefinition();
41     }
42
43     public InterfaceData(InterfaceDataDefinition interfaceDataDefinition) {
44         super(NodeTypeEnum.Interface);
45         this.interfaceDataDefinition = interfaceDataDefinition;
46     }
47
48     public InterfaceData(Map<String, Object> properties) {
49         this();
50         interfaceDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
51         interfaceDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
52         interfaceDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
53         interfaceDataDefinition.setCreationDate((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
54         interfaceDataDefinition.setLastUpdateDate((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
55     }
56
57     public InterfaceDataDefinition getInterfaceDataDefinition() {
58         return interfaceDataDefinition;
59     }
60
61     public void setInterfaceDataDefinition(InterfaceDataDefinition interfaceDataDefinition) {
62         this.interfaceDataDefinition = interfaceDataDefinition;
63     }
64
65     @Override
66     public String getUniqueId() {
67         return interfaceDataDefinition.getUniqueId();
68     }
69
70     @Override
71     public Map<String, Object> toGraphMap() {
72         Map<String, Object> map = new HashMap<>();
73         addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, interfaceDataDefinition.getUniqueId());
74         addIfExists(map, GraphPropertiesDictionary.TYPE, interfaceDataDefinition.getType());
75         addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, interfaceDataDefinition.getCreationDate());
76         addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, interfaceDataDefinition.getLastUpdateDate());
77         addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, interfaceDataDefinition.getDescription());
78         return map;
79     }
80 }