use of ca.uhn.hl7v2.validation.impl.NoValidation in project camel by apache.
the class HL7ValidateTest method createRouteBuilder.
protected RouteBuilder createRouteBuilder() throws Exception {
HapiContext hapiContext = new DefaultHapiContext();
hapiContext.setValidationContext(new NoValidation());
Parser p = new GenericParser(hapiContext);
hl7 = new HL7DataFormat();
hl7.setParser(p);
/*
* Let's start by adding a validation rule to the default validation
* that disallows PID-2 to be empty.
*/
ValidationRuleBuilder builder = new ValidationRuleBuilder() {
private static final long serialVersionUID = 1L;
@Override
protected void configure() {
forVersion(Version.V24).message("ADT", "*").terser("PID-2", not(empty()));
}
};
ValidationContext customValidationContext = ValidationContextFactory.fromBuilder(builder);
HapiContext customContext = new DefaultHapiContext(customValidationContext);
final Parser customParser = new GenericParser(customContext);
return new RouteBuilder() {
public void configure() throws Exception {
from("direct:unmarshalFailed").unmarshal().hl7().to("mock:unmarshal");
from("direct:unmarshalOk").unmarshal().hl7(false).to("mock:unmarshal");
from("direct:unmarshalOkCustom").unmarshal(hl7).to("mock:unmarshal");
from("direct:start1").marshal().hl7(customParser).to("mock:end");
from("direct:start2").marshal().hl7(true).to("mock:end");
}
};
}
use of ca.uhn.hl7v2.validation.impl.NoValidation in project tdi-studio-se by Talend.
the class HL7Parse method getHL7MessageInput.
/**
* DOC gcui Comment method "getHL7MessageInput".
*
* @param messageText
* @return
*/
public Message getHL7MessageInput(String messageText) {
GenericParser p = new GenericParser();
// force use novalidation
p.setValidationContext(new NoValidation());
Message message = null;
try {
if (messageText != null) {
messageText = messageText.replace('\n', '\r');
message = p.parse(messageText);
}
} catch (Exception e) {
ExceptionHandler.process(e);
MessageBox errorBox = new MessageBox(new Shell(), SWT.APPLICATION_MODAL | SWT.OK);
//$NON-NLS-1$
errorBox.setText("Parse error");
//$NON-NLS-1$
errorBox.setMessage("The content can't be parsed correctly,please check the file");
if (errorBox.open() == SWT.OK) {
errorBox.getParent().getShell().close();
}
}
return message;
}
use of ca.uhn.hl7v2.validation.impl.NoValidation in project camel by apache.
the class HL7XmlDataFormatTest method createRouteBuilder.
protected RouteBuilder createRouteBuilder() throws Exception {
HapiContext hapiContext = new DefaultHapiContext();
hapiContext.setValidationContext(new NoValidation());
Parser p = new GenericParser(hapiContext);
hl7 = new HL7DataFormat();
hl7.setParser(p);
return new RouteBuilder() {
public void configure() throws Exception {
from("direct:unmarshalOk").unmarshal().hl7(false).to("mock:unmarshal");
from("direct:unmarshalOkXml").unmarshal(hl7).to("mock:unmarshal");
}
};
}
Aggregations