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