1
|
|
|
package com.hltech.judged.server.infrastructure.persistence.contracts; |
2
|
|
|
|
3
|
|
|
import com.hltech.judged.server.domain.ServiceVersion; |
4
|
|
|
import lombok.AccessLevel; |
5
|
|
|
import lombok.AllArgsConstructor; |
6
|
|
|
import lombok.EqualsAndHashCode; |
7
|
|
|
import lombok.Getter; |
8
|
|
|
import lombok.NoArgsConstructor; |
9
|
|
|
|
10
|
|
|
import javax.persistence.Access; |
11
|
|
|
import javax.persistence.AccessType; |
12
|
|
|
import javax.persistence.ElementCollection; |
13
|
|
|
import javax.persistence.Embeddable; |
14
|
|
|
import javax.persistence.EmbeddedId; |
15
|
|
|
import javax.persistence.Entity; |
16
|
|
|
import javax.persistence.FetchType; |
17
|
|
|
import javax.persistence.JoinColumn; |
18
|
|
|
import javax.persistence.JoinTable; |
19
|
|
|
import javax.persistence.MapKeyColumn; |
20
|
|
|
import javax.persistence.Table; |
21
|
|
|
import java.io.Serializable; |
22
|
|
|
import java.util.Map; |
23
|
|
|
|
24
|
|
|
@Entity |
25
|
|
|
@Table(name = "SERVICE_CONTRACTS") |
26
|
|
|
@Getter |
27
|
|
|
@AllArgsConstructor |
28
|
|
|
@NoArgsConstructor(access = AccessLevel.PROTECTED) |
29
|
|
|
public class ServiceContractsTuple { |
30
|
|
|
|
31
|
|
|
@EmbeddedId |
32
|
|
|
private ServiceVersion id; |
33
|
|
|
|
34
|
|
|
@ElementCollection(fetch = FetchType.EAGER) |
35
|
|
|
@MapKeyColumn(name = "protocol") |
36
|
|
|
@JoinTable(name = "capabilities", joinColumns = { |
37
|
|
|
@JoinColumn(name = "service_name", referencedColumnName = "name"), |
38
|
|
|
@JoinColumn(name = "service_version", referencedColumnName = "version") |
39
|
|
|
}) |
40
|
|
|
private Map<String, ContractTuple> capabilitiesPerProtocol; |
41
|
|
|
|
42
|
|
|
@ElementCollection(fetch = FetchType.EAGER) |
43
|
|
|
@JoinTable(name = "expectations", joinColumns = { |
44
|
|
|
@JoinColumn(name = "service_name", referencedColumnName = "name"), |
45
|
|
|
@JoinColumn(name = "service_version", referencedColumnName = "version") |
46
|
|
|
}) |
47
|
|
|
private Map<ProviderProtocolTuple, ContractTuple> expectations; |
48
|
|
|
|
49
|
|
|
public String getName() { |
50
|
|
|
return this.id.getName(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public String getVersion() { |
54
|
|
|
return this.id.getVersion(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
@Getter |
58
|
|
|
@Embeddable |
59
|
|
|
@AllArgsConstructor |
60
|
|
|
@NoArgsConstructor |
61
|
|
|
@Access(AccessType.FIELD) |
62
|
|
|
@EqualsAndHashCode |
63
|
|
|
public static class ProviderProtocolTuple { |
64
|
|
|
private String provider; |
65
|
|
|
private String protocol; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
@Getter |
69
|
|
|
@Embeddable |
70
|
|
|
@AllArgsConstructor |
71
|
|
|
@NoArgsConstructor |
72
|
|
|
@Access(AccessType.FIELD) |
73
|
|
|
@EqualsAndHashCode |
74
|
|
|
public static class ContractTuple implements Serializable { |
75
|
|
|
private String value; |
76
|
|
|
private String mimeType; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
} |
80
|
|
|
|