StructureDefinition retVal = new StructureDefinition();
retVal.setName(theStructure.getName());
if (theStructure instanceof Group) {
retVal.setSegment(false);
Group group = (Group) theStructure;
int index = 0;
List<String> childNames = Arrays.asList(group.getNames());
/*
* For SuperStructures, which can hold more than one type of structure,
* we only actually bring in the child names that are actually a part
* of the structure we are trying to parse
*/
if (theStructure instanceof SuperStructure) {
String struct = theStructureName;
Map<String, String> evtMap = new DefaultModelClassFactory().getEventMapForVersion(Version.versionOf(theStructure.getMessage().getVersion()));
if (evtMap.containsKey(struct)) {
struct = evtMap.get(struct);
}
childNames = ((SuperStructure) theStructure).getChildNamesForStructure(struct);
}
for (String nextName : childNames) {
Structure nextChild = group.get(nextName);
StructureDefinition structureDefinition = createStructureDefinition(nextChild, thePreviousLeaf, theStructureName);
structureDefinition.setNameAsItAppearsInParent(nextName);
structureDefinition.setRepeating(group.isRepeating(nextName));
structureDefinition.setRequired(group.isRequired(nextName));
structureDefinition.setChoiceElement(group.isChoiceElement(nextName));
structureDefinition.setPosition(index++);
structureDefinition.setParent(retVal);
retVal.addChild(structureDefinition);
}
} else {