return constructSurvey(rootElement);
}
private Survey constructSurvey(Element element) {
Survey survey = new Survey();
survey.setName(element.elementText("name"));
for (Object levelElement : element.elements("level")) {
survey.getSurveyLevels().add(constructLevel((Element) levelElement));
}
for (Object sectionElement : element.elements("section")) {
survey.getSurveySections().add(constructSection((Element) sectionElement));
}
// Link Back
for (SurveyLevel l : survey.getSurveyLevels()) {
l.setSurvey(survey);
}
for (SurveySection s : survey.getSurveySections()) {
s.setSurvey(survey);
}
return survey;
}