コード例 #1
0
 private Tutorial loadTutorial(Element node) {
   String tutorial_id = getId(node);
   Tutorial tutorial = this.tutorialService.findOrCreateTutorial(tutorial_id);
   tutorial.setName(CDom4jHelper.getAttribute(node, "name"));
   tutorial.setNumber(getNumber(tutorial.getName()));
   for (Iterator<?> iter = node.elementIterator(); iter.hasNext(); ) {
     Element child = (Element) iter.next();
     String name = child.getName();
     String text = CDom4jHelper.getTrimmedText(child);
     if (name.equals("title")) tutorial.setTitle(CDom4jHelper.getChildrenAsXml(child));
     else if (name.equals("pages")) loadPages(child, tutorial);
     else if (name.equals("questions")) loadQuestions(child, tutorial);
     else if (name.equals("images")) loadImages(child, tutorial);
     else if (name.equals("links")) loadLinks(child, tutorial);
     else if (name.equals("flashs")) loadFlashs(child, tutorial);
     else setProperty(tutorial, name, text);
   }
   this.writer.message("updating tutorial: [" + tutorial.getId() + "]");
   this.tutorialService.updateTutorial(tutorial);
   return tutorial;
 }