Revision 47676
Added by Claudio Atzori almost 7 years ago
Api.java | ||
---|---|---|
5 | 5 |
import java.util.Set; |
6 | 6 |
import javax.persistence.*; |
7 | 7 |
|
8 |
import com.fasterxml.jackson.annotation.JsonAutoDetect; |
|
9 |
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
8 |
import com.google.common.collect.ComparisonChain; |
|
10 | 9 |
import com.google.gson.Gson; |
11 | 10 |
import io.swagger.annotations.ApiModel; |
12 | 11 |
|
... | ... | |
15 | 14 |
*/ |
16 | 15 |
@Entity |
17 | 16 |
@Table(name = "dsm_api") |
18 |
@JsonAutoDetect |
|
19 | 17 |
@ApiModel(value = "Datasource Api model", description = "describes the datasource api") |
20 |
public class Api { |
|
18 |
public class Api implements Comparable<Api> {
|
|
21 | 19 |
|
22 | 20 |
@Id |
23 | 21 |
private String id = null; |
24 | 22 |
|
25 | 23 |
private String protocol = null; |
26 |
@JsonIgnore |
|
27 |
@ManyToOne |
|
28 |
@JoinColumn(name = "datasource") |
|
29 |
private Datasource datasource = null; |
|
24 |
|
|
25 |
private String datasource = null; |
|
30 | 26 |
private String contentdescription = null; |
31 | 27 |
private Boolean active = false; |
32 | 28 |
private Boolean removable = false; |
... | ... | |
63 | 59 |
|
64 | 60 |
private String baseurl = null; |
65 | 61 |
|
66 |
@OneToMany(mappedBy="api", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
|
62 |
@OneToMany(mappedBy = "id.api", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
|
67 | 63 |
private Set<Apiparam> apiparam; |
68 | 64 |
|
65 |
public Api() {} |
|
66 |
|
|
69 | 67 |
public String getId() { |
70 | 68 |
return id; |
71 | 69 |
} |
... | ... | |
74 | 72 |
return protocol; |
75 | 73 |
} |
76 | 74 |
|
77 |
public Datasource getDatasource() {
|
|
75 |
public String getDatasource() {
|
|
78 | 76 |
return datasource; |
79 | 77 |
} |
80 | 78 |
|
... | ... | |
160 | 158 |
return this; |
161 | 159 |
} |
162 | 160 |
|
163 |
public Api setDatasource(final Datasource datasource) {
|
|
161 |
public Api setDatasource(final String datasource) {
|
|
164 | 162 |
this.datasource = datasource; |
165 | 163 |
return this; |
166 | 164 |
} |
... | ... | |
277 | 275 |
return new Gson().toJson(this); |
278 | 276 |
} |
279 | 277 |
|
278 |
@Override |
|
279 |
public int compareTo(final Api a) { |
|
280 |
return ComparisonChain.start() |
|
281 |
.compare(getId(), a.getId()) |
|
282 |
.result(); |
|
283 |
} |
|
284 |
|
|
280 | 285 |
} |
281 | 286 |
|
Also available in: Unified diff
fine grained operations