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=========================================================
20 package org.openecomp.sdc.be.resources.data;
22 import java.util.HashMap;
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;
29 public class InterfaceData extends GraphNode {
31 private InterfaceDataDefinition interfaceDataDefinition;
33 public InterfaceData() {
34 super(NodeTypeEnum.Interface);
35 interfaceDataDefinition = new InterfaceDataDefinition();
38 public InterfaceData(InterfaceData p) {
39 super(NodeTypeEnum.Interface);
40 interfaceDataDefinition = p.getInterfaceDataDefinition();
43 public InterfaceData(InterfaceDataDefinition interfaceDataDefinition) {
44 super(NodeTypeEnum.Interface);
45 this.interfaceDataDefinition = interfaceDataDefinition;
48 public InterfaceData(Map<String, Object> properties) {
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()));
57 public InterfaceDataDefinition getInterfaceDataDefinition() {
58 return interfaceDataDefinition;
61 public void setInterfaceDataDefinition(InterfaceDataDefinition interfaceDataDefinition) {
62 this.interfaceDataDefinition = interfaceDataDefinition;
66 public String getUniqueId() {
67 return interfaceDataDefinition.getUniqueId();
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());