/** * {@inheritDoc} */ public boolean isEmpty() throws HL7Exception { for (String name : getNames()) { if (!get(name).isEmpty()) return false; } return true; }
/** * {@inheritDoc} */ public boolean isEmpty() throws HL7Exception { for (String name : getNames()) { if (!get(name).isEmpty()) return false; } return true; }
/** * Checks a group's children against a list of allowed structures for the group (ie those * mentioned in the profile with usage other than X). Returns a list of exceptions representing * structures that appear in the message but are not supposed to. */ protected void checkForExtraStructures(Group group, List<String> allowedStructures, List<HL7Exception> exList) throws ProfileException { for (String childName : group.getNames()) { if (!allowedStructures.contains(childName)) { try { for (Structure rep : group.getAll(childName)) { if (!rep.isEmpty()) { HL7Exception e = new XElementPresentException("The structure " + childName + " appears in the message but not in the profile"); exList.add(e); } } } catch (HL7Exception he) { throw new ProfileException("Problem checking profile", he); } } } }
private void apply(Group theStructure, List<ValidationException> theExceptions) { Set<String> choicesWithContent = null; for (String nextName : theStructure.getNames()) { try { boolean nextIsChoiceElement = theStructure.isChoiceElement(nextName); for (Structure nextStruct : theStructure.getAll(nextName)) { if (nextIsChoiceElement && !nextStruct.isEmpty()) { if (choicesWithContent == null) { choicesWithContent = new HashSet<String>(); } choicesWithContent.add(nextName); } if (nextStruct instanceof Group) { apply((Group) nextStruct, theExceptions); } } } catch (HL7Exception e) { throw new Error("Failed to find " + nextName + " in structure. This is probably a HAPI bug."); } } if (choicesWithContent != null && choicesWithContent.size() > 1) { theExceptions.add(new ValidationException("Structure '" + theStructure.getName() + "' must have content only in one of the following choices: " + choicesWithContent.toString())); } }
private void apply(Group theStructure, List<ValidationException> theExceptions) { Set<String> choicesWithContent = null; for (String nextName : theStructure.getNames()) { try { boolean nextIsChoiceElement = theStructure.isChoiceElement(nextName); for (Structure nextStruct : theStructure.getAll(nextName)) { if (nextIsChoiceElement && !nextStruct.isEmpty()) { if (choicesWithContent == null) { choicesWithContent = new HashSet<String>(); } choicesWithContent.add(nextName); } if (nextStruct instanceof Group) { apply((Group) nextStruct, theExceptions); } } } catch (HL7Exception e) { throw new Error("Failed to find " + nextName + " in structure. This is probably a HAPI bug."); } } if (choicesWithContent != null && choicesWithContent.size() > 1) { theExceptions.add(new ValidationException("Structure '" + theStructure.getName() + "' must have content only in one of the following choices: " + choicesWithContent.toString())); } }
/** * Checks a group's children against a list of allowed structures for the group (ie those * mentioned in the profile with usage other than X). Returns a list of exceptions representing * structures that appear in the message but are not supposed to. */ protected void checkForExtraStructures(Group group, List<String> allowedStructures, List<HL7Exception> exList) throws ProfileException { for (String childName : group.getNames()) { if (!allowedStructures.contains(childName)) { try { for (Structure rep : group.getAll(childName)) { if (!rep.isEmpty()) { HL7Exception e = new XElementPresentException("The structure " + childName + " appears in the message but not in the profile"); exList.add(e); } } } catch (HL7Exception he) { throw new ProfileException("Problem checking profile", he); } } } }
private void checkStructure(SuperStructure theMsg, List<ValidationException> theExceptions) { String messageStructure = theMsg.getMessage().getName(); Set<String> nonStandardNames = theMsg.getNonStandardNames(); FORNAME: for (String name : theMsg.getNames()) { if (nonStandardNames != null && nonStandardNames.contains(name)) { continue; } try { for (Structure rep : theMsg.getAll(name)) { if (!rep.isEmpty()) { Set<String> structuresWhichChildAppliesTo = theMsg.getStructuresWhichChildAppliesTo(name); if (!structuresWhichChildAppliesTo.contains(messageStructure)) { String msgSimpleName = theMsg.getMessage().getClass().getSimpleName(); theExceptions.add(new ValidationException("Message (superstructure " + msgSimpleName + ") of type " + messageStructure + " must not have content in " + name)); } continue FORNAME; } } } catch (HL7Exception e) { // should not happen throw new Error("Can't get rep of structure " + name + ". This is probably a HAPI bug"); } } }
private void checkStructure(SuperStructure theMsg, List<ValidationException> theExceptions) { String messageStructure = theMsg.getMessage().getName(); Set<String> nonStandardNames = theMsg.getNonStandardNames(); FORNAME: for (String name : theMsg.getNames()) { if (nonStandardNames != null && nonStandardNames.contains(name)) { continue; } try { for (Structure rep : theMsg.getAll(name)) { if (!rep.isEmpty()) { Set<String> structuresWhichChildAppliesTo = theMsg.getStructuresWhichChildAppliesTo(name); if (!structuresWhichChildAppliesTo.contains(messageStructure)) { String msgSimpleName = theMsg.getMessage().getClass().getSimpleName(); theExceptions.add(new ValidationException("Message (superstructure " + msgSimpleName + ") of type " + messageStructure + " must not have content in " + name)); } continue FORNAME; } } } catch (HL7Exception e) { // should not happen throw new Error("Can't get rep of structure " + name + ". This is probably a HAPI bug"); } } }
Structure[] allReps = getAll(nextName); for (Structure structure : allReps) { if (!structure.isEmpty()) { hasContent = true; break;
List<Structure> instancesWithContent = new ArrayList<Structure>(); for (Structure instance : group.getAll(struct.getName())) { if (!instance.isEmpty()) instancesWithContent.add(instance);
List<Structure> instancesWithContent = new ArrayList<Structure>(); for (Structure instance : group.getAll(struct.getName())) { if (!instance.isEmpty()) instancesWithContent.add(instance);
Structure[] allReps = getAll(nextName); for (Structure structure : allReps) { if (!structure.isEmpty()) { hasContent = true; break;