final HapiContext hapiContext = new DefaultHapiContext(); if (!inputVersion.equals("autodetect")) { hapiContext.setModelClassFactory(new CanonicalModelClassFactory(inputVersion)); hapiContext.setValidationContext((ValidationContext) ValidationContextFactory.noValidation()); final PipeParser parser = hapiContext.getPipeParser(); final String hl7Text = new String(buffer, charset); try {
/** * @param theHapiContext HapiContext */ public HL7Service(HapiContext theHapiContext) { this(theHapiContext.getGenericParser(), theHapiContext.getLowerLayerProtocol(), theHapiContext.getExecutorService()); }
public DefaultHapiContext(HapiContext context) { this(context.getParserConfiguration(), context.getValidationContext(), context .getModelClassFactory()); }
hapiContext.setValidationContext((ca.uhn.hl7v2.validation.ValidationContext) ValidationContextFactory.noValidation()); final PipeParser parser = hapiContext.getPipeParser(); final String hl7Text = new String(buffer, charset); final HL7Message message;
/** * @since 2.2 */ public Connection attachLazily(String host, int outboundPort, int inboundPort, boolean tls) throws HL7Exception { return attach(new ConnectionData(host, outboundPort, inboundPort, getHapiContext() .getGenericParser(), getHapiContext().getLowerLayerProtocol(), tls, getHapiContext().getSocketFactory(), true)); }
/** * {@inheritDoc} */ public Message next() { String nextString = myWrapped.next(); Message retVal; try { if (myMessageType != null) { retVal = ReflectionUtil.instantiateMessage(myMessageType, getHapiContext().getModelClassFactory()); retVal.parse(nextString); } else { retVal = getHapiContext().getPipeParser().parse(nextString); } } catch (EncodingNotSupportedException e) { throw new Hl7InputStreamMessageStringIterator.ParseFailureError("Failed to parse message", e); } catch (HL7Exception e) { throw new Hl7InputStreamMessageStringIterator.ParseFailureError("Failed to parse message", e); } return retVal; }
public ParserConfiguration getParserConfiguration() { return context.getParserConfiguration(); }
public PipeParser getPipeParser() { return context.getPipeParser(); }
public ApplicationRouterImpl(HapiContext theContext) { this(theContext, theContext.getGenericParser()); }
/** * @param context the set of validation rules to be applied to messages parsed or encoded by * this parser (defaults to ValidationContextFactory.DefaultValidation) * * @deprecated use a dedicated {@link HapiContext} and set its ValidationContext property */ public void setValidationContext(ValidationContext context) { HapiContext newContext = new DefaultHapiContext(getHapiContext()); newContext.setValidationContext(context); setHapiContext(newContext); }
/** * @param modelClassFactory transaction-specific model-class factory * @param validationRuleBuilder validation rule builder * @param profileStore profile store * @return HapiContext */ public static HapiContext createHapiContext(ModelClassFactory modelClassFactory, ValidationRuleBuilder validationRuleBuilder, ProfileStore profileStore) { HapiContext context = new DefaultHapiContext(modelClassFactory); context.setProfileStore(profileStore); context.setValidationRuleBuilder(validationRuleBuilder); context.getParserConfiguration().setValidating(false); context.getParserConfiguration().setIdGenerator(idGenerator); context.getParserConfiguration().setEscaping(DefaultEscaping.INSTANCE); context.setValidationExceptionHandlerFactory(new SimpleValidationExceptionHandler(context)); return context; } }
public ModelClassFactory getModelClassFactory() { return context.getModelClassFactory(); }
private ValidationException[] testAgainstProfile(Message message, String id) throws ProfileException, HL7Exception { HL7Exception[] exceptions; HapiContext context = message.getParser().getHapiContext(); Validator validator = context.getConformanceValidator(); try { ProfileStore profileStore = context.getProfileStore(); String profileString = profileStore.getProfile(id); if (profileString != null) { RuntimeProfile profile = getProfile(profileString); exceptions = validator.validate(message, profile.getMessage()); } else { throw new ProfileException("Unable to find the profile " + id); } } catch (IOException e) { throw new ProfileException("Error retreiving profile " + id, e); } ValidationException[] result = new ValidationException[exceptions.length]; for (int i = 0; i < exceptions.length; i++) { result[i] = ValidationException.fromHL7Exception(exceptions[i]); } return result; }
public ProfileStore getProfileStore() { return context.getProfileStore(); }
public <R> void setValidationExceptionHandlerFactory( ValidationExceptionHandlerFactory<R> factory) { context.setValidationExceptionHandlerFactory(factory); }
public CodeStoreRegistry getCodeStoreRegistry() { return context.getCodeStoreRegistry(); }
public void close() throws IOException { context.close(); } }
public ca.uhn.hl7v2.conf.check.Validator getConformanceValidator() { return context.getConformanceValidator(); }
/** * @since 2.2 */ public Connection attachLazily(String host, int outboundPort, int inboundPort, boolean tls) throws HL7Exception { return attach(new ConnectionData(host, outboundPort, inboundPort, getHapiContext() .getGenericParser(), getHapiContext().getLowerLayerProtocol(), tls, getHapiContext().getSocketFactory(), true)); }
/** * {@inheritDoc} */ public Message next() { String nextString = myWrapped.next(); Message retVal; try { if (myMessageType != null) { retVal = ReflectionUtil.instantiateMessage(myMessageType, getHapiContext().getModelClassFactory()); retVal.parse(nextString); } else { retVal = getHapiContext().getPipeParser().parse(nextString); } } catch (EncodingNotSupportedException e) { throw new Hl7InputStreamMessageStringIterator.ParseFailureError("Failed to parse message", e); } catch (HL7Exception e) { throw new Hl7InputStreamMessageStringIterator.ParseFailureError("Failed to parse message", e); } return retVal; }