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