1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.xds.core.metadata;
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
29 @XmlType(name = "AssociationType")
30 @XmlEnum(String.class)
31 public enum AssociationType {
32
33 @XmlEnumValue("APND") APPEND("APND", "urn:ihe:iti:2007:AssociationType:APND"),
34
35 @XmlEnumValue("RPLC") REPLACE("RPLC", "urn:ihe:iti:2007:AssociationType:RPLC"),
36
37 @XmlEnumValue("XFRM") TRANSFORM("XFRM", "urn:ihe:iti:2007:AssociationType:XFRM"),
38
39 @XmlEnumValue("XFRM_RPLC") TRANSFORM_AND_REPLACE("XFRM_RPLC", "urn:ihe:iti:2007:AssociationType:XFRM_RPLC"),
40
41 @XmlEnumValue("HasMember") HAS_MEMBER("HasMember", "urn:oasis:names:tc:ebxml-regrep:AssociationType:HasMember"),
42
43 @XmlEnumValue("signs") SIGNS("signs", "urn:ihe:iti:2007:AssociationType:signs"),
44
45 @XmlEnumValue("IsSnapshotOf") IS_SNAPSHOT_OF("IsSnapshotOf", "urn:ihe:iti:2010:AssociationType:IsSnapshotOf"),
46
47 @XmlEnumValue("UpdateAvailabilityStatus") UPDATE_AVAILABILITY_STATUS("UpdateAvailabilityStatus", "urn:ihe:iti:2010:AssociationType:UpdateAvailabilityStatus"),
48
49 @XmlEnumValue("SubmitAssociation") SUBMIT_ASSOCIATION("SubmitAssociation", "urn:ihe:iti:2010:AssociationType:SubmitAssociation");
50
51 private final String opcode21;
52 private final String opcode30;
53
54 AssociationType(String opcode21, String opcode30) {
55 this.opcode21 = opcode21;
56 this.opcode30 = opcode30;
57 }
58
59
60
61
62 public String getOpcode21() {
63 return opcode21;
64 }
65
66
67
68
69 public String getOpcode30() {
70 return opcode30;
71 }
72
73
74
75
76
77
78
79 public static String getOpcode21(AssociationType type) {
80 return type != null ? type.getOpcode21() : null;
81 }
82
83
84
85
86
87
88
89 public static String getOpcode30(AssociationType type) {
90 return type != null ? type.getOpcode30() : null;
91 }
92
93
94
95
96
97
98
99
100
101 public static AssociationType valueOfOpcode21(String opcode) {
102 if (opcode == null) {
103 return null;
104 }
105
106 for (AssociationType type : AssociationType.values()) {
107 if (opcode.equals(type.getOpcode21())) {
108 return type;
109 }
110 }
111
112 throw new XDSMetaDataException(ValidationMessage.INVALID_ASSOCIATION_TYPE);
113 }
114
115
116
117
118
119
120
121
122
123 public static AssociationType valueOfOpcode30(String opcode) {
124 if (opcode == null) {
125 return null;
126 }
127
128 for (AssociationType type : AssociationType.values()) {
129 if (opcode.equals(type.getOpcode30())) {
130 return type;
131 }
132 }
133
134 throw new XDSMetaDataException(ValidationMessage.INVALID_ASSOCIATION_TYPE);
135 }
136
137
138
139
140 public boolean isReplace() {
141 return this == REPLACE || this == TRANSFORM_AND_REPLACE;
142 }
143 }