1
|
package eu.dnetlib.enabling.datasources.common;
|
2
|
|
3
|
import java.util.Date;
|
4
|
import java.util.Objects;
|
5
|
import java.util.Set;
|
6
|
import javax.persistence.*;
|
7
|
|
8
|
import com.google.common.collect.ComparisonChain;
|
9
|
import com.google.gson.Gson;
|
10
|
|
11
|
/**
|
12
|
* Api
|
13
|
*/
|
14
|
@MappedSuperclass
|
15
|
public class Api<AP extends ApiParam> implements Comparable<Api<AP>> {
|
16
|
|
17
|
@Id
|
18
|
protected String id = null;
|
19
|
protected String protocol = null;
|
20
|
protected String datasource = null;
|
21
|
protected String contentdescription = null;
|
22
|
protected Boolean active = false;
|
23
|
protected Boolean removable = false;
|
24
|
protected String typology = null;
|
25
|
protected String compatibility;
|
26
|
|
27
|
@Transient
|
28
|
protected boolean compatibilityOverrided = false;
|
29
|
|
30
|
@Column(name = "metadata_identifier_path")
|
31
|
protected String metadataIdentifierPath;
|
32
|
|
33
|
@Column(name = "last_collection_total")
|
34
|
protected Integer lastCollectionTotal;
|
35
|
|
36
|
@Column(name = "last_collection_date")
|
37
|
@Temporal(TemporalType.TIMESTAMP)
|
38
|
protected Date lastCollectionDate;
|
39
|
|
40
|
@Column(name = "last_collection_mdid")
|
41
|
protected String lastCollectionMdid;
|
42
|
|
43
|
@Column(name = "last_aggregation_total")
|
44
|
protected Integer lastAggregationTotal;
|
45
|
|
46
|
@Column(name = "last_aggregation_date")
|
47
|
@Temporal(TemporalType.TIMESTAMP)
|
48
|
protected Date lastAggregationDate;
|
49
|
|
50
|
@Column(name = "last_aggregation_mdid")
|
51
|
protected String lastAggregationMdid;
|
52
|
|
53
|
@Column(name = "last_download_total")
|
54
|
protected Integer lastDownloadTotal;
|
55
|
|
56
|
@Column(name = "last_download_date")
|
57
|
@Temporal(TemporalType.TIMESTAMP)
|
58
|
protected Date lastDownloadDate;
|
59
|
|
60
|
@Column(name = "last_download_objid")
|
61
|
protected String lastDownloadObjid;
|
62
|
|
63
|
@Column(name = "last_validation_job")
|
64
|
protected String lastValidationJob;
|
65
|
protected String baseurl = null;
|
66
|
|
67
|
@OneToMany(mappedBy = "id.api", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
68
|
protected Set<AP> apiParams;
|
69
|
|
70
|
public Api() {}
|
71
|
|
72
|
public String getId() {
|
73
|
return id;
|
74
|
}
|
75
|
|
76
|
public String getProtocol() {
|
77
|
return protocol;
|
78
|
}
|
79
|
|
80
|
public String getDatasource() {
|
81
|
return datasource;
|
82
|
}
|
83
|
|
84
|
public String getContentdescription() {
|
85
|
return contentdescription;
|
86
|
}
|
87
|
|
88
|
public Boolean getActive() {
|
89
|
return active;
|
90
|
}
|
91
|
|
92
|
public Boolean getRemovable() {
|
93
|
return removable;
|
94
|
}
|
95
|
|
96
|
public String getTypology() {
|
97
|
return typology;
|
98
|
}
|
99
|
|
100
|
public String getCompatibility() {
|
101
|
return compatibility;
|
102
|
}
|
103
|
|
104
|
public boolean isCompatibilityOverrided() {
|
105
|
return compatibilityOverrided;
|
106
|
}
|
107
|
|
108
|
public String getMetadataIdentifierPath() {
|
109
|
return metadataIdentifierPath;
|
110
|
}
|
111
|
|
112
|
public Integer getLastCollectionTotal() {
|
113
|
return lastCollectionTotal;
|
114
|
}
|
115
|
|
116
|
public Date getLastCollectionDate() {
|
117
|
return lastCollectionDate;
|
118
|
}
|
119
|
|
120
|
public String getLastCollectionMdid() {
|
121
|
return lastCollectionMdid;
|
122
|
}
|
123
|
|
124
|
public Integer getLastAggregationTotal() {
|
125
|
return lastAggregationTotal;
|
126
|
}
|
127
|
|
128
|
public Date getLastAggregationDate() {
|
129
|
return lastAggregationDate;
|
130
|
}
|
131
|
|
132
|
public String getLastAggregationMdid() {
|
133
|
return lastAggregationMdid;
|
134
|
}
|
135
|
|
136
|
public Integer getLastDownloadTotal() {
|
137
|
return lastDownloadTotal;
|
138
|
}
|
139
|
|
140
|
public Date getLastDownloadDate() {
|
141
|
return lastDownloadDate;
|
142
|
}
|
143
|
|
144
|
public String getLastDownloadObjid() {
|
145
|
return lastDownloadObjid;
|
146
|
}
|
147
|
|
148
|
public String getLastValidationJob() {
|
149
|
return lastValidationJob;
|
150
|
}
|
151
|
|
152
|
public String getBaseurl() {
|
153
|
return baseurl;
|
154
|
}
|
155
|
|
156
|
public Set<AP> getApiParams() {
|
157
|
return apiParams;
|
158
|
}
|
159
|
|
160
|
public Api<AP> setId(final String id) {
|
161
|
this.id = id;
|
162
|
return this;
|
163
|
}
|
164
|
|
165
|
public Api<AP> setProtocol(final String protocol) {
|
166
|
this.protocol = protocol;
|
167
|
return this;
|
168
|
}
|
169
|
|
170
|
public Api<AP> setDatasource(final String datasource) {
|
171
|
this.datasource = datasource;
|
172
|
return this;
|
173
|
}
|
174
|
|
175
|
public Api<AP> setContentdescription(final String contentdescription) {
|
176
|
this.contentdescription = contentdescription;
|
177
|
return this;
|
178
|
}
|
179
|
|
180
|
public Api<AP> setActive(final Boolean active) {
|
181
|
this.active = active;
|
182
|
return this;
|
183
|
}
|
184
|
|
185
|
public Api<AP> setRemovable(final Boolean removable) {
|
186
|
this.removable = removable;
|
187
|
return this;
|
188
|
}
|
189
|
|
190
|
public Api<AP> setTypology(final String typology) {
|
191
|
this.typology = typology;
|
192
|
return this;
|
193
|
}
|
194
|
|
195
|
public Api<AP> setCompatibility(final String compatibility) {
|
196
|
this.compatibility = compatibility;
|
197
|
return this;
|
198
|
}
|
199
|
|
200
|
public Api<AP> setCompatibilityOverrided(final boolean compatibilityOverrided) {
|
201
|
this.compatibilityOverrided = compatibilityOverrided;
|
202
|
return this;
|
203
|
}
|
204
|
|
205
|
public Api<AP> setMetadataIdentifierPath(final String metadataIdentifierPath) {
|
206
|
this.metadataIdentifierPath = metadataIdentifierPath;
|
207
|
return this;
|
208
|
}
|
209
|
|
210
|
public Api<AP> setLastCollectionTotal(final Integer lastCollectionTotal) {
|
211
|
this.lastCollectionTotal = lastCollectionTotal;
|
212
|
return this;
|
213
|
}
|
214
|
|
215
|
public Api<AP> setLastCollectionDate(final Date lastCollectionDate) {
|
216
|
this.lastCollectionDate = lastCollectionDate;
|
217
|
return this;
|
218
|
}
|
219
|
|
220
|
public Api<AP> setLastCollectionMdid(final String lastCollectionMdid) {
|
221
|
this.lastCollectionMdid = lastCollectionMdid;
|
222
|
return this;
|
223
|
}
|
224
|
|
225
|
public Api<AP> setLastAggregationTotal(final Integer lastAggregationTotal) {
|
226
|
this.lastAggregationTotal = lastAggregationTotal;
|
227
|
return this;
|
228
|
}
|
229
|
|
230
|
public Api<AP> setLastAggregationDate(final Date lastAggregationDate) {
|
231
|
this.lastAggregationDate = lastAggregationDate;
|
232
|
return this;
|
233
|
}
|
234
|
|
235
|
public Api<AP> setLastAggregationMdid(final String lastAggregationMdid) {
|
236
|
this.lastAggregationMdid = lastAggregationMdid;
|
237
|
return this;
|
238
|
}
|
239
|
|
240
|
public Api<AP> setLastDownloadTotal(final Integer lastDownloadTotal) {
|
241
|
this.lastDownloadTotal = lastDownloadTotal;
|
242
|
return this;
|
243
|
}
|
244
|
|
245
|
public Api<AP> setLastDownloadDate(final Date lastDownloadDate) {
|
246
|
this.lastDownloadDate = lastDownloadDate;
|
247
|
return this;
|
248
|
}
|
249
|
|
250
|
public Api<AP> setLastDownloadObjid(final String lastDownloadObjid) {
|
251
|
this.lastDownloadObjid = lastDownloadObjid;
|
252
|
return this;
|
253
|
}
|
254
|
|
255
|
public Api<AP> setLastValidationJob(final String lastValidationJob) {
|
256
|
this.lastValidationJob = lastValidationJob;
|
257
|
return this;
|
258
|
}
|
259
|
|
260
|
public Api<AP> setBaseurl(final String baseurl) {
|
261
|
this.baseurl = baseurl;
|
262
|
return this;
|
263
|
}
|
264
|
|
265
|
public Api<AP> setApiParams(final Set<AP> apiParams) {
|
266
|
this.apiParams = apiParams;
|
267
|
return this;
|
268
|
}
|
269
|
|
270
|
@Override
|
271
|
public boolean equals(final Object o) {
|
272
|
if (this == o) { return true; }
|
273
|
if (o == null || getClass() != o.getClass()) { return false; }
|
274
|
final Api<?> api = (Api<?>) o;
|
275
|
return Objects.equals(this.id, api.id);
|
276
|
}
|
277
|
|
278
|
/*
|
279
|
* (non-Javadoc)
|
280
|
*
|
281
|
* @see eu.dnetlib.openaire.exporter.model.datasource.db.ApiInterface#hashCode()
|
282
|
*/
|
283
|
|
284
|
@Override
|
285
|
public int hashCode() {
|
286
|
return Objects.hash(id);
|
287
|
}
|
288
|
|
289
|
@Override
|
290
|
public String toString() {
|
291
|
return new Gson().toJson(this);
|
292
|
}
|
293
|
|
294
|
@Override
|
295
|
public int compareTo(final Api<AP> a) {
|
296
|
return ComparisonChain.start()
|
297
|
.compare(getId(), a.getId())
|
298
|
.result();
|
299
|
}
|
300
|
|
301
|
}
|