Project

General

Profile

1
package eu.dnetlib.datasource.publisher.model.db;
2

    
3
import java.sql.Date;
4
import java.util.Objects;
5
import java.util.Set;
6
import javax.persistence.*;
7

    
8
import com.google.common.collect.ComparisonChain;
9
import com.google.gson.Gson;
10
import io.swagger.annotations.ApiModel;
11

    
12
/**
13
 * Api
14
 */
15
@Entity
16
@Table(name = "dsm_api")
17
@ApiModel(value = "Datasource Api model", description = "describes the datasource api")
18
public class Api implements Comparable<Api> {
19

    
20
	@Id
21
	private String id = null;
22

    
23
	private String protocol = null;
24

    
25
	private String datasource = null;
26
	private String contentdescription = null;
27
	private Boolean active = false;
28
	private Boolean removable = false;
29
	private String typology = null;
30

    
31
	private String compatibility;
32

    
33
	@Column(name = "metadata_identifier_path")
34
	private String metadataIdentifierPath;
35

    
36
	@Column(name = "last_collection_total")
37
	private Integer lastCollectionTotal;
38
	@Column(name = "last_collection_date")
39
	private Date lastCollectionDate;
40
	@Column(name = "last_collection_mdid")
41
	private String lastCollectionMdid;
42

    
43
	@Column(name = "last_aggregation_total")
44
	private Integer lastAggregationTotal;
45
	@Column(name = "last_aggregation_date")
46
	private Date lastAggregationDate;
47
	@Column(name = "last_aggregation_mdid")
48
	private String lastAggregationMdid;
49

    
50
	@Column(name = "last_download_total")
51
	private Integer lastDownloadTotal;
52
	@Column(name = "last_download_date")
53
	private Date lastDownloadDate;
54
	@Column(name = "last_download_objid")
55
	private String lastDownloadMdid;
56

    
57
	@Column(name = "last_validation_job")
58
	private String lastValidationJob;
59

    
60
	private String baseurl = null;
61

    
62
	@OneToMany(mappedBy = "id.api", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
63
	private Set<Apiparam> apiparam;
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<Apiparam> getApiparam() {
148
		return apiparam;
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 setApiparam(final Set<Apiparam> apiparam) {
252
		this.apiparam = apiparam;
253
		return this;
254
	}
255

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

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

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

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

    
285
}
286

    
(2-2/12)