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.*;
8

    
9
import com.google.common.collect.ComparisonChain;
10
import com.google.gson.Gson;
11

    
12
/**
13
 * Api
14
 */
15
@MappedSuperclass
16
public class Api<AP extends ApiParam<?>> implements Comparable<Api<AP>> {
17

    
18
	@Id
19
	protected String id = null;
20
	protected String protocol = null;
21
	protected String datasource = null;
22
	protected String contentdescription = null;
23
	protected Boolean active = false;
24
	protected Boolean removable = false;
25
	protected String typology = null;
26
	protected String compatibility;
27

    
28
	@Column(name = "metadata_identifier_path")
29
	protected String metadataIdentifierPath;
30

    
31
	@Column(name = "last_collection_total")
32
	protected Integer lastCollectionTotal;
33

    
34
	@Column(name = "last_collection_date")
35
	protected Date lastCollectionDate;
36

    
37
	@Column(name = "last_collection_mdid")
38
	protected String lastCollectionMdid;
39

    
40
	@Column(name = "last_aggregation_total")
41
	protected Integer lastAggregationTotal;
42

    
43
	@Column(name = "last_aggregation_date")
44
	protected Date lastAggregationDate;
45

    
46
	@Column(name = "last_aggregation_mdid")
47
	protected String lastAggregationMdid;
48

    
49
	@Column(name = "last_download_total")
50
	protected Integer lastDownloadTotal;
51

    
52
	@Column(name = "last_download_date")
53
	protected Date lastDownloadDate;
54

    
55
	@Column(name = "last_download_objid")
56
	protected String lastDownloadMdid;
57

    
58
	@Column(name = "last_validation_job")
59
	protected String lastValidationJob;
60
	protected String baseurl = null;
61

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

    
65
	public Api() {}
66

    
67
	public String getId() {
68
		return id;
69
	}
70

    
71
	public String getProtocol() {
72
		return protocol;
73
	}
74

    
75
	public String getDatasource() {
76
		return datasource;
77
	}
78

    
79
	public String getContentdescription() {
80
		return contentdescription;
81
	}
82

    
83
	public Boolean getActive() {
84
		return active;
85
	}
86

    
87
	public Boolean getRemovable() {
88
		return removable;
89
	}
90

    
91
	public String getTypology() {
92
		return typology;
93
	}
94

    
95
	public String getCompatibility() {
96
		return compatibility;
97
	}
98

    
99
	public String getMetadataIdentifierPath() {
100
		return metadataIdentifierPath;
101
	}
102

    
103
	public Integer getLastCollectionTotal() {
104
		return lastCollectionTotal;
105
	}
106

    
107
	public Date getLastCollectionDate() {
108
		return lastCollectionDate;
109
	}
110

    
111
	public String getLastCollectionMdid() {
112
		return lastCollectionMdid;
113
	}
114

    
115
	public Integer getLastAggregationTotal() {
116
		return lastAggregationTotal;
117
	}
118

    
119
	public Date getLastAggregationDate() {
120
		return lastAggregationDate;
121
	}
122

    
123
	public String getLastAggregationMdid() {
124
		return lastAggregationMdid;
125
	}
126

    
127
	public Integer getLastDownloadTotal() {
128
		return lastDownloadTotal;
129
	}
130

    
131
	public Date getLastDownloadDate() {
132
		return lastDownloadDate;
133
	}
134

    
135
	public String getLastDownloadMdid() {
136
		return lastDownloadMdid;
137
	}
138

    
139
	public String getLastValidationJob() {
140
		return lastValidationJob;
141
	}
142

    
143
	public String getBaseurl() {
144
		return baseurl;
145
	}
146

    
147
	public Set<AP> getApiParams() {
148
		return apiParams;
149
	}
150

    
151
	public Api setId(final String id) {
152
		this.id = id;
153
		return this;
154
	}
155

    
156
	public Api setProtocol(final String protocol) {
157
		this.protocol = protocol;
158
		return this;
159
	}
160

    
161
	public Api setDatasource(final String datasource) {
162
		this.datasource = datasource;
163
		return this;
164
	}
165

    
166
	public Api setContentdescription(final String contentdescription) {
167
		this.contentdescription = contentdescription;
168
		return this;
169
	}
170

    
171
	public Api setActive(final Boolean active) {
172
		this.active = active;
173
		return this;
174
	}
175

    
176
	public Api setRemovable(final Boolean removable) {
177
		this.removable = removable;
178
		return this;
179
	}
180

    
181
	public Api setTypology(final String typology) {
182
		this.typology = typology;
183
		return this;
184
	}
185

    
186
	public Api setCompatibility(final String compatibility) {
187
		this.compatibility = compatibility;
188
		return this;
189
	}
190

    
191
	public Api setMetadataIdentifierPath(final String metadataIdentifierPath) {
192
		this.metadataIdentifierPath = metadataIdentifierPath;
193
		return this;
194
	}
195

    
196
	public Api setLastCollectionTotal(final Integer lastCollectionTotal) {
197
		this.lastCollectionTotal = lastCollectionTotal;
198
		return this;
199
	}
200

    
201
	public Api setLastCollectionDate(final Date lastCollectionDate) {
202
		this.lastCollectionDate = lastCollectionDate;
203
		return this;
204
	}
205

    
206
	public Api setLastCollectionMdid(final String lastCollectionMdid) {
207
		this.lastCollectionMdid = lastCollectionMdid;
208
		return this;
209
	}
210

    
211
	public Api setLastAggregationTotal(final Integer lastAggregationTotal) {
212
		this.lastAggregationTotal = lastAggregationTotal;
213
		return this;
214
	}
215

    
216
	public Api setLastAggregationDate(final Date lastAggregationDate) {
217
		this.lastAggregationDate = lastAggregationDate;
218
		return this;
219
	}
220

    
221
	public Api setLastAggregationMdid(final String lastAggregationMdid) {
222
		this.lastAggregationMdid = lastAggregationMdid;
223
		return this;
224
	}
225

    
226
	public Api setLastDownloadTotal(final Integer lastDownloadTotal) {
227
		this.lastDownloadTotal = lastDownloadTotal;
228
		return this;
229
	}
230

    
231
	public Api setLastDownloadDate(final Date lastDownloadDate) {
232
		this.lastDownloadDate = lastDownloadDate;
233
		return this;
234
	}
235

    
236
	public Api setLastDownloadMdid(final String lastDownloadMdid) {
237
		this.lastDownloadMdid = lastDownloadMdid;
238
		return this;
239
	}
240

    
241
	public Api setLastValidationJob(final String lastValidationJob) {
242
		this.lastValidationJob = lastValidationJob;
243
		return this;
244
	}
245

    
246
	public Api setBaseurl(final String baseurl) {
247
		this.baseurl = baseurl;
248
		return this;
249
	}
250

    
251
	public Api setApiParams(final Set<AP> apiParams) {
252
		this.apiParams = apiParams;
253
		return this;
254
	}
255

    
256
	public boolean equals(Object o) {
257
		if (this == o) { return true; }
258
		if (o == null || getClass() != o.getClass()) { return false; }
259
		Api api = (Api) o;
260
		return Objects.equals(this.id, api.id);
261
	}
262

    
263
	/*
264
	 * (non-Javadoc)
265
	 * 
266
	 * @see eu.dnetlib.openaire.exporter.model.datasource.db.ApiInterface#hashCode()
267
	 */
268

    
269
	public int hashCode() {
270
		return Objects.hash(id);
271
	}
272

    
273
	public String toString() {
274
		return new Gson().toJson(this);
275
	}
276

    
277
	public int compareTo(final Api a) {
278
		return ComparisonChain.start()
279
				.compare(getId(), a.getId())
280
				.result();
281
	}
282

    
283
}
(3-3/16)