Adding interfaces in documentation
[aai/sparky-be.git] / src / main / java / org / onap / aai / sparky / sync / entity / IndexableEntity.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.aai.sparky.sync.entity;
22
23 import java.sql.Timestamp;
24 import java.text.SimpleDateFormat;
25
26 import com.fasterxml.jackson.annotation.JsonIgnore;
27 import com.fasterxml.jackson.annotation.JsonProperty;
28
29 /**
30  * The Class IndexableEntity.
31  */
32 public abstract class IndexableEntity {
33   protected String id; // generated, SHA-256 digest
34   protected String entityType;
35   protected String entityPrimaryKeyValue;
36   protected String lastmodTimestamp;
37   protected String link;
38
39   private static final String TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
40
41   /**
42    * Instantiates a new indexable entity.
43    */
44   public IndexableEntity() {
45     SimpleDateFormat dateFormat = new SimpleDateFormat(TIMESTAMP_FORMAT);
46     Timestamp timestamp = new Timestamp(System.currentTimeMillis());
47     String currentFormattedTimeStamp = dateFormat.format(timestamp);
48     this.setEntityTimeStamp(currentFormattedTimeStamp);
49   }
50
51   @JsonIgnore
52   public String getId() {
53     return id;
54   }
55
56   @JsonProperty("entityType")
57   public String getEntityType() {
58     return entityType;
59   }
60
61   @JsonProperty("entityPrimaryKeyValue")
62   public String getEntityPrimaryKeyValue() {
63     return entityPrimaryKeyValue;
64   }
65
66   @JsonProperty("lastmodTimestamp")
67   public String getEntityTimeStamp() {
68     return lastmodTimestamp;
69   }
70
71   public void setId(String id) {
72     this.id = id;
73   }
74
75   public void setEntityType(String entityType) {
76     this.entityType = entityType;
77   }
78
79   public void setEntityPrimaryKeyValue(String fieldValue) {
80     this.entityPrimaryKeyValue = fieldValue;
81   }
82
83   public void setEntityTimeStamp(String lastmodTimestamp) {
84     this.lastmodTimestamp = lastmodTimestamp;
85   }
86
87   @JsonProperty("link")
88   public String getLink() {
89     return link;
90   }
91
92   public void setLink(String link) {
93     this.link = link;
94   }
95
96 }