Project

General

Profile

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