Project

General

Profile

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
import javax.persistence.Transient;
14

    
15
import com.google.common.collect.ComparisonChain;
16
import com.google.gson.Gson;
17

    
18
/**
19
 * Api
20
 */
21
@MappedSuperclass
22
public class Api<AP extends ApiParam> implements Comparable<Api<AP>> {
23

    
24
	@Id
25
	protected String id = null;
26
	protected String protocol = null;
27
	protected String datasource = null;
28
	protected String contentdescription = null;
29
	protected Boolean active = false;
30
	protected Boolean removable = false;
31
	protected String typology = null;
32
	protected String compatibility;
33

    
34
	@Transient
35
	protected boolean compatibilityOverrided = false;
36

    
37
	@Column(name = "metadata_identifier_path")
38
	protected String metadataIdentifierPath;
39

    
40
	@Column(name = "last_collection_total")
41
	protected Integer lastCollectionTotal;
42

    
43
	@Column(name = "last_collection_date")
44
	protected Date lastCollectionDate;
45

    
46
	@Column(name = "last_collection_mdid")
47
	protected String lastCollectionMdid;
48

    
49
	@Column(name = "last_aggregation_total")
50
	protected Integer lastAggregationTotal;
51

    
52
	@Column(name = "last_aggregation_date")
53
	protected Date lastAggregationDate;
54

    
55
	@Column(name = "last_aggregation_mdid")
56
	protected String lastAggregationMdid;
57

    
58
	@Column(name = "last_download_total")
59
	protected Integer lastDownloadTotal;
60

    
61
	@Column(name = "last_download_date")
62
	protected Date lastDownloadDate;
63

    
64
	@Column(name = "last_download_objid")
65
	protected String lastDownloadObjid;
66

    
67
	@Column(name = "last_validation_job")
68
	protected String lastValidationJob;
69
	protected String baseurl = null;
70

    
71
	@OneToMany(mappedBy = "id.api", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
72
	protected Set<AP> apiParams;
73

    
74
	public Api() {}
75

    
76
	public String getId() {
77
		return id;
78
	}
79

    
80
	public String getProtocol() {
81
		return protocol;
82
	}
83

    
84
	public String getDatasource() {
85
		return datasource;
86
	}
87

    
88
	public String getContentdescription() {
89
		return contentdescription;
90
	}
91

    
92
	public Boolean getActive() {
93
		return active;
94
	}
95

    
96
	public Boolean getRemovable() {
97
		return removable;
98
	}
99

    
100
	public String getTypology() {
101
		return typology;
102
	}
103

    
104
	public String getCompatibility() {
105
		return compatibility;
106
	}
107

    
108
	public boolean isCompatibilityOverrided() {
109
		return compatibilityOverrided;
110
	}
111

    
112
	public String getMetadataIdentifierPath() {
113
		return metadataIdentifierPath;
114
	}
115

    
116
	public Integer getLastCollectionTotal() {
117
		return lastCollectionTotal;
118
	}
119

    
120
	public Date getLastCollectionDate() {
121
		return lastCollectionDate;
122
	}
123

    
124
	public String getLastCollectionMdid() {
125
		return lastCollectionMdid;
126
	}
127

    
128
	public Integer getLastAggregationTotal() {
129
		return lastAggregationTotal;
130
	}
131

    
132
	public Date getLastAggregationDate() {
133
		return lastAggregationDate;
134
	}
135

    
136
	public String getLastAggregationMdid() {
137
		return lastAggregationMdid;
138
	}
139

    
140
	public Integer getLastDownloadTotal() {
141
		return lastDownloadTotal;
142
	}
143

    
144
	public Date getLastDownloadDate() {
145
		return lastDownloadDate;
146
	}
147

    
148
	public String getLastDownloadObjid() {
149
		return lastDownloadObjid;
150
	}
151

    
152
	public String getLastValidationJob() {
153
		return lastValidationJob;
154
	}
155

    
156
	public String getBaseurl() {
157
		return baseurl;
158
	}
159

    
160
	public Set<AP> getApiParams() {
161
		return apiParams;
162
	}
163

    
164
	public Api<AP> setId(final String id) {
165
		this.id = id;
166
		return this;
167
	}
168

    
169
	public Api<AP> setProtocol(final String protocol) {
170
		this.protocol = protocol;
171
		return this;
172
	}
173

    
174
	public Api<AP> setDatasource(final String datasource) {
175
		this.datasource = datasource;
176
		return this;
177
	}
178

    
179
	public Api<AP> setContentdescription(final String contentdescription) {
180
		this.contentdescription = contentdescription;
181
		return this;
182
	}
183

    
184
	public Api<AP> setActive(final Boolean active) {
185
		this.active = active;
186
		return this;
187
	}
188

    
189
	public Api<AP> setRemovable(final Boolean removable) {
190
		this.removable = removable;
191
		return this;
192
	}
193

    
194
	public Api<AP> setTypology(final String typology) {
195
		this.typology = typology;
196
		return this;
197
	}
198

    
199
	public Api<AP> setCompatibility(final String compatibility) {
200
		this.compatibility = compatibility;
201
		return this;
202
	}
203

    
204
	public Api<AP> setCompatibilityOverrided(final boolean compatibilityOverrided) {
205
		this.compatibilityOverrided = compatibilityOverrided;
206
		return this;
207
	}
208

    
209
	public Api<AP> setMetadataIdentifierPath(final String metadataIdentifierPath) {
210
		this.metadataIdentifierPath = metadataIdentifierPath;
211
		return this;
212
	}
213

    
214
	public Api<AP> setLastCollectionTotal(final Integer lastCollectionTotal) {
215
		this.lastCollectionTotal = lastCollectionTotal;
216
		return this;
217
	}
218

    
219
	public Api<AP> setLastCollectionDate(final Date lastCollectionDate) {
220
		this.lastCollectionDate = lastCollectionDate;
221
		return this;
222
	}
223

    
224
	public Api<AP> setLastCollectionMdid(final String lastCollectionMdid) {
225
		this.lastCollectionMdid = lastCollectionMdid;
226
		return this;
227
	}
228

    
229
	public Api<AP> setLastAggregationTotal(final Integer lastAggregationTotal) {
230
		this.lastAggregationTotal = lastAggregationTotal;
231
		return this;
232
	}
233

    
234
	public Api<AP> setLastAggregationDate(final Date lastAggregationDate) {
235
		this.lastAggregationDate = lastAggregationDate;
236
		return this;
237
	}
238

    
239
	public Api<AP> setLastAggregationMdid(final String lastAggregationMdid) {
240
		this.lastAggregationMdid = lastAggregationMdid;
241
		return this;
242
	}
243

    
244
	public Api<AP> setLastDownloadTotal(final Integer lastDownloadTotal) {
245
		this.lastDownloadTotal = lastDownloadTotal;
246
		return this;
247
	}
248

    
249
	public Api<AP> setLastDownloadDate(final Date lastDownloadDate) {
250
		this.lastDownloadDate = lastDownloadDate;
251
		return this;
252
	}
253

    
254
	public Api<AP> setLastDownloadObjid(final String lastDownloadObjid) {
255
		this.lastDownloadObjid = lastDownloadObjid;
256
		return this;
257
	}
258

    
259
	public Api<AP> setLastValidationJob(final String lastValidationJob) {
260
		this.lastValidationJob = lastValidationJob;
261
		return this;
262
	}
263

    
264
	public Api<AP> setBaseurl(final String baseurl) {
265
		this.baseurl = baseurl;
266
		return this;
267
	}
268

    
269
	public Api<AP> setApiParams(final Set<AP> apiParams) {
270
		this.apiParams = apiParams;
271
		return this;
272
	}
273

    
274
	@Override
275
	public boolean equals(final Object o) {
276
		if (this == o) { return true; }
277
		if (o == null || getClass() != o.getClass()) { return false; }
278
		final Api<?> api = (Api<?>) o;
279
		return Objects.equals(this.id, api.id);
280
	}
281

    
282
	/*
283
	 * (non-Javadoc)
284
	 *
285
	 * @see eu.dnetlib.openaire.exporter.model.datasource.db.ApiInterface#hashCode()
286
	 */
287

    
288
	@Override
289
	public int hashCode() {
290
		return Objects.hash(id);
291
	}
292

    
293
	@Override
294
	public String toString() {
295
		return new Gson().toJson(this);
296
	}
297

    
298
	@Override
299
	public int compareTo(final Api<AP> a) {
300
		return ComparisonChain.start()
301
				.compare(getId(), a.getId())
302
				.result();
303
	}
304

    
305
}
(3-3/20)