2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.be.resources.data;
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;
28 import java.util.HashMap;
31 public class InterfaceData extends GraphNode {
33 private InterfaceDataDefinition interfaceDataDefinition;
35 public InterfaceData() {
36 super(NodeTypeEnum.Interface);
37 interfaceDataDefinition = new InterfaceDataDefinition();
41 public InterfaceData(InterfaceData p) {
42 super(NodeTypeEnum.Interface);
43 interfaceDataDefinition = p.getInterfaceDataDefinition();
47 public InterfaceData(InterfaceDataDefinition interfaceDataDefinition) {
48 super(NodeTypeEnum.Interface);
49 this.interfaceDataDefinition = interfaceDataDefinition;
53 public InterfaceData(Map<String, Object> properties) {
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()));
65 public InterfaceDataDefinition getInterfaceDataDefinition() {
66 return interfaceDataDefinition;
69 public void setInterfaceDataDefinition(InterfaceDataDefinition interfaceDataDefinition) {
70 this.interfaceDataDefinition = interfaceDataDefinition;
74 public String getUniqueId() {
75 return interfaceDataDefinition.getUniqueId();
79 public Map<String, Object> toGraphMap() {
80 Map<String, Object> map = new HashMap<>();
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());