re base code
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / RequirementData.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
21 package org.openecomp.sdc.be.resources.data;
22
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;
27
28 import java.util.HashMap;
29 import java.util.Map;
30
31 public class RequirementData extends GraphNode {
32
33         private String uniqueId;
34
35         private String node;
36
37         private Long creationTime;
38
39         private Long modificationTime;
40
41         private String relationshipType;
42         private String minOccurrences = RequirementDataDefinition.MIN_OCCURRENCES;
43         private String maxOccurrences = RequirementDataDefinition.MAX_DEFAULT_OCCURRENCES;
44
45         public RequirementData() {
46                 super(NodeTypeEnum.Requirement);
47
48         }
49
50         public RequirementData(Map<String, Object> properties) {
51
52                 this();
53
54                 this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
55
56                 this.setNode((String) properties.get(GraphPropertiesDictionary.NODE.getProperty()));
57
58                 this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
59
60                 this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
61
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()));
65
66         }
67
68         @Override
69         public Map<String, Object> toGraphMap() {
70
71                 Map<String, Object> map = new HashMap<>();
72
73                 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
74
75                 addIfExists(map, GraphPropertiesDictionary.NODE, node);
76
77                 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
78
79                 addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
80
81                 addIfExists(map, GraphPropertiesDictionary.RELATIONSHIP_TYPE, relationshipType);
82                 addIfExists(map, GraphPropertiesDictionary.MIN_OCCURRENCES, minOccurrences);
83                 addIfExists(map, GraphPropertiesDictionary.MAX_OCCURRENCES, maxOccurrences);
84
85                 return map;
86         }
87
88         public String getNode() {
89                 return node;
90         }
91
92         public void setNode(String node) {
93                 this.node = node;
94         }
95
96         public Long getCreationTime() {
97                 return creationTime;
98         }
99
100         public void setCreationTime(Long creationTime) {
101                 this.creationTime = creationTime;
102         }
103
104         public Long getModificationTime() {
105                 return modificationTime;
106         }
107
108         public void setModificationTime(Long modificationTime) {
109                 this.modificationTime = modificationTime;
110         }
111
112         public void setUniqueId(String uniqueId) {
113                 this.uniqueId = uniqueId;
114         }
115
116         public String getRelationshipType() {
117                 return relationshipType;
118         }
119
120         public void setRelationshipType(String relationshipType) {
121                 this.relationshipType = relationshipType;
122         }
123
124         public String getMinOccurrences() {
125                 return minOccurrences;
126         }
127
128         public void setMinOccurrences(String minOccurrences) {
129                 if (minOccurrences != null) {
130                         this.minOccurrences = minOccurrences;
131                 }
132         }
133
134         public String getMaxOccurrences() {
135                 return maxOccurrences;
136         }
137
138         public void setMaxOccurrences(String maxOccurrences) {
139                 if (maxOccurrences != null) {
140                         this.maxOccurrences = maxOccurrences;
141                 }
142         }
143
144         @Override
145         public String getUniqueId() {
146                 return uniqueId;
147         }
148
149         @Override
150         public String toString() {
151                 return "RequirementData [uniqueId=" + uniqueId + ", node=" + node + ", creationTime=" + creationTime
152                                 + ", modificationTime=" + modificationTime + ", relationshipType=" + relationshipType
153                                 + ", minOccurrences=" + minOccurrences + ", maxOccurrences=" + maxOccurrences + "]";
154         }
155
156 }