Project

General

Profile

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