1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.xds.core.transform.requests.query;
17
18 import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLAdhocQueryRequest;
19 import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetByIdAndCodesQuery;
20 import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.QueryParameter;
21
22 import static org.apache.commons.lang3.Validate.notNull;
23
24
25
26
27
28
29
30 public abstract class GetByIDAndCodesQueryTransformer<T extends GetByIdAndCodesQuery> extends AbstractStoredQueryTransformer<T> {
31 private final QueryParameter formatCodeParam;
32 private final QueryParameter confCodeParam;
33 private final QueryParameter confCodeSchemeParam;
34 private final QueryParameter uniqueIdParam;
35 private final QueryParameter uuidParam;
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 public GetByIDAndCodesQueryTransformer(QueryParameter uuidParam, QueryParameter uniqueIdParam, QueryParameter formatCodeParam, QueryParameter formatCodeSchemeParam, QueryParameter confCodeParam, QueryParameter confCodeSchemeParam) {
53 notNull(uniqueIdParam, "uniqueIdParam cannot be null");
54 notNull(uuidParam, "uuidParam cannot be null");
55 notNull(formatCodeParam, "formatCodeParam cannot be null");
56 notNull(formatCodeSchemeParam, "formatCodeSchemeParam cannot be null");
57 notNull(confCodeParam, "confCodeParam cannot be null");
58 notNull(confCodeSchemeParam, "confCodeSchemeParam cannot be null");
59
60 this.formatCodeParam = formatCodeParam;
61 this.confCodeParam = confCodeParam;
62 this.confCodeSchemeParam = confCodeSchemeParam;
63 this.uniqueIdParam = uniqueIdParam;
64 this.uuidParam = uuidParam;
65 }
66
67
68
69
70
71
72
73
74
75
76 public void toEbXML(T query, EbXMLAdhocQueryRequest ebXML) {
77 if (query == null || ebXML == null) {
78 return;
79 }
80
81 super.toEbXML(query, ebXML);
82
83 QuerySlotHelper slots = new QuerySlotHelper(ebXML);
84
85 slots.fromCode(formatCodeParam, query.getFormatCodes());
86 slots.fromCode(confCodeParam, query.getConfidentialityCodes());
87 slots.fromString(uuidParam, query.getUuid());
88 slots.fromString(uniqueIdParam, query.getUniqueId());
89 }
90
91
92
93
94
95
96
97
98
99
100 public void fromEbXML(T query, EbXMLAdhocQueryRequest ebXML) {
101 if (query == null || ebXML == null) {
102 return;
103 }
104
105 super.fromEbXML(query, ebXML);
106
107 QuerySlotHelper slots = new QuerySlotHelper(ebXML);
108
109 query.setFormatCodes(slots.toCodeList(formatCodeParam));
110 query.setConfidentialityCodes(slots.toCodeQueryList(confCodeParam, confCodeSchemeParam));
111 query.setUniqueId(slots.toString(uniqueIdParam));
112 query.setUuid(slots.toString(uuidParam));
113 }
114
115 }