/** * Returns the event map for a given HL7 version. In this map, the key is a message * type and trigger event in the form <code>[type]_[trigger]</code>, for example: * <code>ADT_A04</code>, and the values are the corresponding structure for this trigger, * for example: <code>ADT_A01</code>. * * @param version the HL7 version * @return Returns <code>null</code> if no event map is found for the given version * @throws HL7Exception if the HL7 version is unknown */ public Map<String, String> getEventMapForVersion(Version version) throws HL7Exception { return getEventMap().get(version); }
/** * Returns the event structure. If nothing could be found, the event name is returned * * @see ca.uhn.hl7v2.parser.AbstractModelClassFactory#getMessageStructureForEvent(java.lang.String, ca.uhn.hl7v2.Version) */ @Override public String getMessageStructureForEvent(String name, Version version) throws HL7Exception { String structure = super.getMessageStructureForEvent(name, version); return structure != null ? structure : name; }
/** * Load event map from a external resource * * @return the event map * @throws IOException */ protected Map<Version, Map<String, String>> loadMessageStructures() throws IOException { Map<Version, Map<String, String>> map = new HashMap<Version, Map<String, String>>(); for (Version v : Version.values()) { String resource = getEventMapDirectory() + v.getVersion() + ".properties"; InputStream in = getResource(resource); if (in != null) { try { Properties structures = new Properties(); structures.load(in); Map<String, String> structureMap = new HashMap<String, String>(); for(Map.Entry<Object, Object> next : structures.entrySet()) { structureMap.put((String)next.getKey(), (String)next.getValue()); } map.put(v, Collections.unmodifiableMap(structureMap)); } finally { in.close(); } } } return map; }
/** * Initializes the event map once and returns it. * <p> * This method is package private for testing reasons. * * @return the event map * @throws HL7Exception */ synchronized Map<Version, Map<String, String>> getEventMap() throws HL7Exception { if (eventMap == null) { try { eventMap = loadMessageStructures(); } catch (IOException e) { throw new HL7Exception("Could not load event map", e); } } return eventMap; }
/** * @see ca.uhn.hl7v2.parser.ModelClassFactory#getMessageStructureForEvent(java.lang.String, * ca.uhn.hl7v2.Version) */ public String getMessageStructureForEvent(String name, Version version) throws HL7Exception { Map<String, String> p = getEventMapForVersion(version); if (p == null) { // Instead of throwing an Exception, Allow to parse as generic message if the structure library // (and the contained event map) are not on the classpath. LOG.debug("No event map found for version " + version); return name; // before: // throw new HL7Exception("No map found for version " + version // + ". Only the following are available: " + getEventMap().keySet()); } else { return p.get(name); } }
/** * Load event map from a external resource * * @return the event map * @throws IOException */ protected Map<Version, Map<String, String>> loadMessageStructures() throws IOException { Map<Version, Map<String, String>> map = new HashMap<Version, Map<String, String>>(); for (Version v : Version.values()) { String resource = getEventMapDirectory() + v.getVersion() + ".properties"; InputStream in = getResource(resource); if (in != null) { try { Properties structures = new Properties(); structures.load(in); Map<String, String> structureMap = new HashMap<String, String>(); for(Map.Entry<Object, Object> next : structures.entrySet()) { structureMap.put((String)next.getKey(), (String)next.getValue()); } map.put(v, Collections.unmodifiableMap(structureMap)); } finally { in.close(); } } } return map; }
/** * Initializes the event map once and returns it. * <p> * This method is package private for testing reasons. * * @return the event map * @throws HL7Exception */ synchronized Map<Version, Map<String, String>> getEventMap() throws HL7Exception { if (eventMap == null) { try { eventMap = loadMessageStructures(); } catch (IOException e) { throw new HL7Exception("Could not load event map", e); } } return eventMap; }
/** * @see ca.uhn.hl7v2.parser.ModelClassFactory#getMessageStructureForEvent(java.lang.String, * ca.uhn.hl7v2.Version) */ public String getMessageStructureForEvent(String name, Version version) throws HL7Exception { Map<String, String> p = getEventMapForVersion(version); if (p == null) { // Instead of throwing an Exception, Allow to parse as generic message if the structure library // (and the contained event map) are not on the classpath. LOG.debug("No event map found for version " + version); return name; // before: // throw new HL7Exception("No map found for version " + version // + ". Only the following are available: " + getEventMap().keySet()); } else { return p.get(name); } }
/** * Returns the event structure. If nothing could be found, the event name is returned * * @see ca.uhn.hl7v2.parser.AbstractModelClassFactory#getMessageStructureForEvent(java.lang.String, ca.uhn.hl7v2.Version) */ @Override public String getMessageStructureForEvent(String name, Version version) throws HL7Exception { String structure = super.getMessageStructureForEvent(name, version); return structure != null ? structure : name; }
/** * Returns the event map for a given HL7 version. In this map, the key is a message * type and trigger event in the form <code>[type]_[trigger]</code>, for example: * <code>ADT_A04</code>, and the values are the corresponding structure for this trigger, * for example: <code>ADT_A01</code>. * * @param version the HL7 version * @return Returns <code>null</code> if no event map is found for the given version * @throws HL7Exception if the HL7 version is unknown */ public Map<String, String> getEventMapForVersion(Version version) throws HL7Exception { return getEventMap().get(version); }
/** * Looks up its own event map. If no structure was found, the call is delegated to * the default ModelClassFactory. If nothing can be found, the eventName is returned * as structure. * * @see ca.uhn.hl7v2.parser.AbstractModelClassFactory#getMessageStructureForEvent(java.lang.String, ca.uhn.hl7v2.Version) */ @Override public String getMessageStructureForEvent(String eventName, Version version) throws HL7Exception { String structure = super.getMessageStructureForEvent(eventName, version); if (structure != null) return structure; structure = delegate.getMessageStructureForEvent(eventName, version); return structure != null ? structure : eventName; }
/** * Looks up its own event map. If no structure was found, the call is delegated to * the default ModelClassFactory. If nothing can be found, the eventName is returned * as structure. * * @see ca.uhn.hl7v2.parser.AbstractModelClassFactory#getMessageStructureForEvent(java.lang.String, ca.uhn.hl7v2.Version) */ @Override public String getMessageStructureForEvent(String eventName, Version version) throws HL7Exception { String structure = super.getMessageStructureForEvent(eventName, version); if (structure != null) return structure; structure = delegate.getMessageStructureForEvent(eventName, version); return structure != null ? structure : eventName; }