public class CustomModelClassFactory extends AbstractModelClassFactory
Also, a custom event map location is supported (by setting AbstractModelClassFactory.setEventMapDirectory(String)
in a way that only new or modified structures needs to be defined there. If no structure was
found, the event map of the delegate ModelClassFactory serves as fallback.
DEFAULT_EVENT_MAP_DIRECTORY
Constructor and Description |
---|
CustomModelClassFactory()
Constructor which just delegated to
DefaultModelClassFactory |
CustomModelClassFactory(Map<String,String[]> map)
Constructor
|
CustomModelClassFactory(ModelClassFactory defaultFactory,
Map<String,String[]> map)
Set an explicit
ModelClassFactory is underlying delegate |
CustomModelClassFactory(String packageName)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addModels(Map<String,String[]> addedModelClasses)
Add model class packages after the object has been instantiated
|
protected <T> Class<T> |
findClass(String subpackage,
String name,
String version)
Finds appropriate classes to be loaded for the given structure/type
|
Map<String,String[]> |
getCustomModelClasses()
Returns the configured custom model classes
|
Class<? extends Group> |
getGroupClass(String name,
String version) |
Class<? extends Message> |
getMessageClass(String name,
String version,
boolean isExplicit) |
Class<? extends Message> |
getMessageClassInASpecificPackage(String theName,
String theVersion,
boolean theIsExplicit,
String thePackageName)
|
String |
getMessageStructureForEvent(String eventName,
Version version)
Looks up its own event map.
|
Class<? extends Segment> |
getSegmentClass(String name,
String version) |
Class<? extends Type> |
getTypeClass(String name,
String version) |
getEventMapDirectory, getEventMapForVersion, loadMessageStructures, setEventMapDirectory
public CustomModelClassFactory()
DefaultModelClassFactory
public CustomModelClassFactory(String packageName)
packageName
- The base package name to use.
When searching, package specified here will be appended with .[version].[structure type].
So, for instance, when looking for a v2.5 segment object, if "com.foo
" is passed in, HAPI will look in "com.foo.v25.segment.*
"
public CustomModelClassFactory(Map<String,String[]> map)
map
- Map of packages to include.
Keys are versions of HL7, e.g. "2.5".
Values are an array of packages to search in for custom model classes.
When searching, the package name here will be appended with ".[structure type]".
So, for example, to specify a custom message type, you could create the class
foo.example.v23.message.ZRM_Z01
, and pass in the string "foo.example.v23
".
public CustomModelClassFactory(ModelClassFactory defaultFactory, Map<String,String[]> map)
ModelClassFactory
is underlying delegatedefaultFactory
- default factory to be delegated tomap
- custom model mappublic Class<? extends Message> getMessageClass(String name, String version, boolean isExplicit) throws HL7Exception
name
- name of messageversion
- HL7 versionisExplicit
- true if the structure was specified explicitly in MSH-9-3, false if it was
inferred from MSH-9-1 and MSH-9-2. If false, a lookup may be performed to find an
alternate structure corresponding to that message type and event.HL7Exception
- if the version if not recognized or an appropriate class can not be
foundpublic Class<? extends Group> getGroupClass(String name, String version) throws HL7Exception
name
- name of groupversion
- HL7 versionHL7Exception
- if the version if not recognized or an appropriate class can not be
foundpublic Class<? extends Segment> getSegmentClass(String name, String version) throws HL7Exception
name
- name of segmentversion
- HL7 versionHL7Exception
- if the version if not recognized or an appropriate class can not be
foundpublic Class<? extends Type> getTypeClass(String name, String version) throws HL7Exception
name
- name of typeversion
- HL7 versionHL7Exception
- if the version if not recognized or an appropriate class can not be
foundprotected <T> Class<T> findClass(String subpackage, String name, String version) throws HL7Exception
HL7Exception
public Class<? extends Message> getMessageClassInASpecificPackage(String theName, String theVersion, boolean theIsExplicit, String thePackageName) throws HL7Exception
DefaultModelClassFactory.getMessageClassInASpecificPackage(String, String, boolean, String)
theName
- The message structure type (e.g. "ADT_A01")theVersion
- The HL7 version (e.g. "2.3.1")theIsExplicit
- If false, the message structure is looked up using
Parser.getMessageStructureForEvent(String, String)
and converted to the
appropriate structure type. For example, "ADT_A04" would be converted to "ADT_A01"
because the A04 trigger uses the A01 message structure according to HL7.thePackageName
- The package name to use. Note that if the message type can't be found in
this package, HAPI will return the standard type returned by
ModelClassFactory.getMessageClass(String, String, boolean)
HL7Exception
public Map<String,String[]> getCustomModelClasses()
public void addModels(Map<String,String[]> addedModelClasses)
addedModelClasses
- map with version number as key and package names has valuepublic String getMessageStructureForEvent(String eventName, Version version) throws HL7Exception
getMessageStructureForEvent
in interface ModelClassFactory
getMessageStructureForEvent
in class AbstractModelClassFactory
eventName
- event nameversion
- HL7 versionnull
if none
could be foundHL7Exception
- if the version is unknown or the message structure list is inaccessibleAbstractModelClassFactory.getMessageStructureForEvent(java.lang.String, ca.uhn.hl7v2.Version)
Copyright © 2001–2017 University Health Network. All rights reserved.