1 /*
2 * Copyright 2009 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.openehealth.ipf.commons.ihe.xds.core.transform.requests.query;
17
18
19 import static org.apache.commons.lang3.Validate.notNull;
20
21 import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetByIdQuery;
22 import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.QueryParameter;
23
24 /**
25 * Base class of transformers for {@link GetByIdQuery}.
26 * @param <T>
27 * the actual query type that is transformed by an extending subclass.
28 * @author Jens Riemschneider
29 */
30 public abstract class GetByIDQueryTransformer<T extends GetByIdQuery> extends GetByUUIDQueryTransformer<T> {
31 private final QueryParameter uniqueIdParam;
32
33 /**
34 * Constructs the transformer.
35 * @param uuidParam
36 * the parameter name of the UUID parameter.
37 * @param uniqueIdParam
38 * the parameter name of the unique ID parameter.
39 */
40 protected GetByIDQueryTransformer(QueryParameter uuidParam, QueryParameter uniqueIdParam) {
41 super(uuidParam);
42 notNull(uniqueIdParam, "uniqueIdParam cannot be null");
43 this.uniqueIdParam = uniqueIdParam;
44 }
45
46 @Override
47 protected void toEbXML(T query, QuerySlotHelper slots) {
48 super.toEbXML(query, slots);
49 slots.fromStringList(uniqueIdParam, query.getUniqueIds());
50 }
51
52 @Override
53 protected void fromEbXML(T query, QuerySlotHelper slots) {
54 super.fromEbXML(query, slots);
55 query.setUniqueIds(slots.toStringList(uniqueIdParam));
56 }
57 }