Forgot to include the exception:
RDS_R06is called!!!!!!!
Exception in thread "main" java.lang.ClassCastException:
ca.uhn.hl7v2.model.GenericSegment cannot be cast to
com.mckn.mms.lds.hl7.zxx.custommodel.v25.group.PFG
at
com.mckn.mms.lds.hl7.zxx.custommodelv25.message.RDS_R06.getPFG(RDS_R06.java:67)
at
com.mpls.lds.hl7.zxx.custommodel.v25.message.TestMessageCreation.testParseCustomRDS_R06Message(TestMessageCreation.java:46)
at
com.mpls.lds.hl7.zxx.custommodel.v25.message.TestMessageCreation.main(TestMessageCreation.java:88)
From: Davies, Brian [mailto:[email protected]]
Sent: Tuesday, December 22, 2015 9:36 AM
To: [email protected]
Subject: [HAPI-devel] Custom Model Classes
Hi All,
It seems to me that the custom model classes simply do not recognize the
AbstractGroup types even when one tries to forcefully load the group from the
custom model. I think Christian is absolutely right that the eventmap is the
solution known to work for this issue. The problem for me however is that that
solution seems rather extreme. Unfortunately, the message type I am trying to
create is not a standard type.
Here is a case in point. The code snippet below is actually in a package
xxx.xxx.<version>.<type> but it seems only the eventmap is able to recognize
all types
package com.mckn.mms.lds.hl7.zxx.custommodel.v25.group
public class PFG extends AbstractGroup {
private static final long serialVersionUID = -5950843839679571210L;
public PFG(Group parent, ModelClassFactory factory) {
super(parent, factory);
try {
init();
} catch (HL7Exception e) {
log.error("Unexpected error creating PFG.", e);
}
}
......
package com.mckn.mms.lds.hl7.zxx.custommodel.v25.group
public PFG getPFG(){
//An attempt to load
ModelClassFactory cfm = new CustomModelClassFactory(
"com.mckn.mms.lds.hl7.zxx.custommodel");
Class c=null;
try {
c = cfm.getTypeClass("PFG", "2.5");
} catch (HL7Exception e) {
return null;
}
return (PFG)super.getTyped("PFG", c);
}
I have tried all the recommendations so far, except for the eventmap solution,
but with no success. Unfortunately, there is not enough information showing an
instance of creating a completely new message type implementation from scratch.
Has anyone got a working solution to this problem?
------------------------------------------------------------------------------
_______________________________________________
Hl7api-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel