Update the dependencies to use project version
[aai/sparky-be.git] / src / main / java / org / onap / aai / sparky / synchronizer / entity / IndexableEntity.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017 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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23 package org.onap.aai.sparky.synchronizer.entity;
24
25 import java.sql.Timestamp;
26 import java.text.SimpleDateFormat;
27
28 import org.onap.aai.sparky.config.oxm.OxmModelLoader;
29
30 /**
31  * The Class IndexableEntity.
32  */
33 public abstract class IndexableEntity {
34   protected String id; // generated, SHA-256 digest
35   protected String entityType;
36   protected String entityPrimaryKeyValue;
37   protected String lastmodTimestamp;
38
39   /**
40    * @return the lastmodTimestamp
41    */
42   public String getLastmodTimestamp() {
43     return lastmodTimestamp;
44   }
45
46   /**
47    * @param lastmodTimestamp the lastmodTimestamp to set
48    */
49   public void setLastmodTimestamp(String lastmodTimestamp) {
50     this.lastmodTimestamp = lastmodTimestamp;
51   }
52
53   /**
54    * @return the loader
55    */
56   public OxmModelLoader getLoader() {
57     return loader;
58   }
59
60   /**
61    * @param loader the loader to set
62    */
63   public void setLoader(OxmModelLoader loader) {
64     this.loader = loader;
65   }
66
67   /**
68    * @return the timestampFormat
69    */
70   public static String getTimestampFormat() {
71     return TIMESTAMP_FORMAT;
72   }
73
74   protected String link;
75   protected OxmModelLoader loader;
76
77   private static final String TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
78
79   /**
80    * Instantiates a new indexable entity.
81    */
82   public IndexableEntity() {
83     SimpleDateFormat dateFormat = new SimpleDateFormat(TIMESTAMP_FORMAT);
84     Timestamp timestamp = new Timestamp(System.currentTimeMillis());
85     String currentFormattedTimeStamp = dateFormat.format(timestamp);
86     this.setEntityTimeStamp(currentFormattedTimeStamp);
87   }
88
89   /**
90    * Instantiates a new indexable entity.
91    *
92    * @param loader the loader
93    */
94   public IndexableEntity(OxmModelLoader loader) {
95     this();
96     this.loader = loader;
97   }
98
99   public String getId() {
100     return id;
101   }
102
103   public String getEntityType() {
104     return entityType;
105   }
106
107   public String getEntityPrimaryKeyValue() {
108     return entityPrimaryKeyValue;
109   }
110
111   public String getEntityTimeStamp() {
112     return lastmodTimestamp;
113   }
114
115   public void setId(String id) {
116     this.id = id;
117   }
118
119   public void setEntityType(String entityType) {
120     this.entityType = entityType;
121   }
122
123   public void setEntityPrimaryKeyValue(String fieldValue) {
124     this.entityPrimaryKeyValue = fieldValue;
125   }
126
127   public void setEntityTimeStamp(String lastmodTimestamp) {
128     this.lastmodTimestamp = lastmodTimestamp;
129   }
130
131   public String getLink() {
132     return link;
133   }
134
135   public void setLink(String link) {
136     this.link = link;
137   }
138
139 }