1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.xds.core.responses;
17
18 import org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationMessage;
19 import org.openehealth.ipf.commons.ihe.xds.core.validate.XDSMetaDataException;
20
21 import javax.xml.bind.annotation.XmlEnum;
22 import javax.xml.bind.annotation.XmlEnumValue;
23 import javax.xml.bind.annotation.XmlType;
24
25
26
27
28 @XmlType(name = "Status")
29 @XmlEnum(String.class)
30 public enum Status {
31
32 @XmlEnumValue("Failure") FAILURE("Failure", "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure"),
33
34 @XmlEnumValue("Success") SUCCESS("Success", "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success"),
35
36 @XmlEnumValue("PartialSuccess") PARTIAL_SUCCESS("PartialSuccess", "urn:ihe:iti:2007:ResponseStatusType:PartialSuccess");
37
38 private final String opcode21;
39 private final String opcode30;
40
41 Status(String opcode21, String opcode30) {
42 this.opcode21 = opcode21;
43 this.opcode30 = opcode30;
44 }
45
46
47
48
49 public String getOpcode21() {
50 return opcode21;
51 }
52
53
54
55
56 public String getOpcode30() {
57 return opcode30;
58 }
59
60
61
62
63
64
65
66 public static String getOpcode21(Status status) {
67 return status != null ? status.getOpcode21() : null;
68 }
69
70
71
72
73
74
75
76 public static String getOpcode30(Status status) {
77 return status != null ? status.getOpcode30() : null;
78 }
79
80
81
82
83
84
85
86
87
88 public static Status valueOfOpcode(String opcode) {
89 if (opcode == null) {
90 return null;
91 }
92
93 for (Status status : values()) {
94 if (opcode.equals(status.getOpcode21()) || opcode.equals(status.getOpcode30())) {
95 return status;
96 }
97 }
98
99 throw new XDSMetaDataException(ValidationMessage.INVALID_STATUS_IN_RESPONSE);
100 }
101 }
102