1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.hl7v2.definitions;
17
18 import java.util.Collections;
19 import java.util.Map;
20
21 import ca.uhn.hl7v2.Version;
22 import ca.uhn.hl7v2.parser.Parser;
23 import ca.uhn.hl7v2.parser.PipeParser;
24 import org.openehealth.ipf.modules.hl7.parser.CustomModelClassFactory;
25
26
27
28
29
30
31 public final class CustomModelClassUtils {
32
33 private static final String CUSTOM_EVENT_MAP_DIRECTORY = "org/openehealth/ipf/commons/ihe/hl7v2/";
34
35 private CustomModelClassUtils() {
36 throw new IllegalStateException("Utility class, cannot instantiate");
37 }
38
39
40
41
42 public static CustomModelClassFactory createFactory(String transaction, String version) {
43 String packageName = String.format("%s.%s.%s",
44 CustomModelClassUtils.class.getPackage().getName(),
45 transaction,
46 Version.versionOf(version).getPackageVersion());
47 Map<String, String[]> map = Collections.singletonMap(version, new String[]{packageName});
48 CustomModelClassFactory cmcf = new CustomModelClassFactory(map);
49 cmcf.setEventMapDirectory(CUSTOM_EVENT_MAP_DIRECTORY);
50 return cmcf;
51 }
52
53
54
55
56
57
58
59 public static Parser createParser(String transaction, String version) {
60 return new PipeParser(createFactory(transaction, version));
61 }
62
63 }