re base code
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / GraphNodeLock.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.enums.NodeTypeEnum;
26
27 import java.util.HashMap;
28 import java.util.Map;
29
30 public class GraphNodeLock extends GraphNode {
31
32         private String uniqueId;
33         private Long time;
34
35         public GraphNodeLock() {
36                 super(NodeTypeEnum.LockNode);
37                 time = System.currentTimeMillis();
38         }
39
40         public GraphNodeLock(String uniqueId) {
41                 this();
42                 this.uniqueId = uniqueId;
43         }
44
45         public GraphNodeLock(Map<String, Object> properties) {
46                 super(NodeTypeEnum.LockNode);
47
48                 setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
49                 setTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
50         }
51
52         @Override
53         public String getUniqueId() {
54                 return uniqueId;
55         }
56
57         @Override
58         public Map<String, Object> toGraphMap() {
59
60                 Map<String, Object> map = new HashMap<>();
61
62                 addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
63                 addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, time);
64                 return map;
65         }
66
67         public void setUniqueId(String uniqueId) {
68                 this.uniqueId = uniqueId;
69         }
70
71         public Long getTime() {
72                 return time;
73         }
74
75         public void setTime(Long time) {
76                 this.time = time;
77         }
78
79 }