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.RequirementDataDefinition;
26 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
28 import java.util.HashMap;
31 public class RequirementData extends GraphNode {
33 private String uniqueId;
37 private Long creationTime;
39 private Long modificationTime;
41 private String relationshipType;
42 private String minOccurrences = RequirementDataDefinition.MIN_OCCURRENCES;
43 private String maxOccurrences = RequirementDataDefinition.MAX_DEFAULT_OCCURRENCES;
45 public RequirementData() {
46 super(NodeTypeEnum.Requirement);
50 public RequirementData(Map<String, Object> properties) {
54 this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
56 this.setNode((String) properties.get(GraphPropertiesDictionary.NODE.getProperty()));
58 this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
60 this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
62 this.setRelationshipType((String) properties.get(GraphPropertiesDictionary.RELATIONSHIP_TYPE.getProperty()));
63 this.setMinOccurrences((String) properties.get(GraphPropertiesDictionary.MIN_OCCURRENCES.getProperty()));
64 this.setMaxOccurrences((String) properties.get(GraphPropertiesDictionary.MAX_OCCURRENCES.getProperty()));
69 public Map<String, Object> toGraphMap() {
71 Map<String, Object> map = new HashMap<>();
73 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
75 addIfExists(map, GraphPropertiesDictionary.NODE, node);
77 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
79 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
81 addIfExists(map, GraphPropertiesDictionary.RELATIONSHIP_TYPE, relationshipType);
82 addIfExists(map, GraphPropertiesDictionary.MIN_OCCURRENCES, minOccurrences);
83 addIfExists(map, GraphPropertiesDictionary.MAX_OCCURRENCES, maxOccurrences);
88 public String getNode() {
92 public void setNode(String node) {
96 public Long getCreationTime() {
100 public void setCreationTime(Long creationTime) {
101 this.creationTime = creationTime;
104 public Long getModificationTime() {
105 return modificationTime;
108 public void setModificationTime(Long modificationTime) {
109 this.modificationTime = modificationTime;
112 public void setUniqueId(String uniqueId) {
113 this.uniqueId = uniqueId;
116 public String getRelationshipType() {
117 return relationshipType;
120 public void setRelationshipType(String relationshipType) {
121 this.relationshipType = relationshipType;
124 public String getMinOccurrences() {
125 return minOccurrences;
128 public void setMinOccurrences(String minOccurrences) {
129 if (minOccurrences != null) {
130 this.minOccurrences = minOccurrences;
134 public String getMaxOccurrences() {
135 return maxOccurrences;
138 public void setMaxOccurrences(String maxOccurrences) {
139 if (maxOccurrences != null) {
140 this.maxOccurrences = maxOccurrences;
145 public String getUniqueId() {
150 public String toString() {
151 return "RequirementData [uniqueId=" + uniqueId + ", node=" + node + ", creationTime=" + creationTime
152 + ", modificationTime=" + modificationTime + ", relationshipType=" + relationshipType
153 + ", minOccurrences=" + minOccurrences + ", maxOccurrences=" + maxOccurrences + "]";