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 java.util.HashMap;
25 import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
26 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
27 import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
28 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
30 public class InterfaceData extends GraphNode {
32 private InterfaceDataDefinition interfaceDataDefinition;
34 public InterfaceData() {
35 super(NodeTypeEnum.Interface);
36 interfaceDataDefinition = new InterfaceDataDefinition();
39 public InterfaceData(InterfaceData p) {
40 super(NodeTypeEnum.Interface);
41 interfaceDataDefinition = p.getInterfaceDataDefinition();
44 public InterfaceData(InterfaceDataDefinition interfaceDataDefinition) {
45 super(NodeTypeEnum.Interface);
46 this.interfaceDataDefinition = interfaceDataDefinition;
49 public InterfaceData(Map<String, Object> properties) {
51 interfaceDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
52 interfaceDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
53 interfaceDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
54 interfaceDataDefinition.setCreationDate((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
55 interfaceDataDefinition.setLastUpdateDate((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
56 final Object normativeProperty = properties.get(GraphPropertiesDictionary.NORMATIVE.getProperty());
57 interfaceDataDefinition.setUserCreated(!(normativeProperty instanceof Boolean && (Boolean) normativeProperty));
60 public InterfaceDataDefinition getInterfaceDataDefinition() {
61 return interfaceDataDefinition;
64 public void setInterfaceDataDefinition(InterfaceDataDefinition interfaceDataDefinition) {
65 this.interfaceDataDefinition = interfaceDataDefinition;
69 public String getUniqueId() {
70 return interfaceDataDefinition.getUniqueId();
74 public Map<String, Object> toGraphMap() {
75 Map<String, Object> map = new HashMap<>();
76 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, interfaceDataDefinition.getUniqueId());
77 addIfExists(map, GraphPropertiesDictionary.TYPE, interfaceDataDefinition.getType());
78 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, interfaceDataDefinition.getCreationDate());
79 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, interfaceDataDefinition.getLastUpdateDate());
80 addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, interfaceDataDefinition.getDescription());
81 addIfExists(map, GraphPropertiesDictionary.NORMATIVE, !interfaceDataDefinition.isUserCreated());