Exemplo n.º 1
0
 private void loadQuestion(Element node, Tutorial tutorial) {
   String question_id = getId(node);
   Question question = tutorial.findOrCreateQuestion(question_id);
   for (Iterator<?> iter = node.elementIterator(); iter.hasNext(); ) {
     Element child = (Element) iter.next();
     String name = child.getName();
     String text = CDom4jHelper.getTrimmedText(child);
     if (name.equals("text")) question.setText(CDom4jHelper.getChildrenAsXml(child));
     else if (name.equals("choice")) loadChoice(child, question);
     else setProperty(question, name, text);
   }
   this.writer.message("updating question: [" + question.getId() + "]");
 }
Exemplo n.º 2
0
 private void loadPage(Element node, Tutorial tutorial) {
   String page_id = getId(node);
   Page page = tutorial.findOrCreatePage(page_id);
   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")) page.setTitle(CDom4jHelper.getChildrenAsXml(child));
     else if (name.equals("text")) page.setText(CDom4jHelper.getChildrenAsXml(child));
     else setProperty(tutorial, name, text);
   }
   this.writer.message("updating page: [" + page.getId() + "]");
 }
Exemplo n.º 3
0
 private void loadLink(Element node, Tutorial tutorial) {
   String link_id = getId(node);
   Link link = tutorial.findOrCreateLink(link_id);
   link.setHref(CDom4jHelper.getAttribute(node, "href"));
   for (Iterator<?> iter = node.elementIterator(); iter.hasNext(); ) {
     Element child = (Element) iter.next();
     String name = child.getName();
     String text = CDom4jHelper.getTrimmedText(child);
     if (name.equals("text")) link.setText(CDom4jHelper.getChildrenAsXml(child));
     else if (name.equals("description")) doNothing();
     else setProperty(link, name, text);
   }
   this.writer.message("updating link: [" + link.getId() + "]");
 }
Exemplo n.º 4
0
 private void loadFlash(Element node, Tutorial tutorial) {
   String flash_id = getId(node);
   Flash flash = tutorial.findOrCreateFlash(flash_id);
   flash.setBase(CDom4jHelper.getAttribute(node, "base"));
   flash.setSrc(CDom4jHelper.getAttribute(node, "src"));
   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")) flash.setTitle(CDom4jHelper.getChildrenAsXml(child));
     else if (name.equals("caption")) flash.setCaption(CDom4jHelper.getChildrenAsXml(child));
     else if (name.equals("alt")) doNothing();
     else if (name.equals("description")) doNothing();
     else setProperty(flash, name, text);
   }
   this.writer.message("updating flash: [" + flash.getId() + "]");
 }
Exemplo n.º 5
0
 private void loadImage(Element node, Tutorial tutorial) {
   String image_id = getId(node);
   Image image = tutorial.findOrCreateImage(image_id);
   image.setSrc(CDom4jHelper.getAttribute(node, "src"));
   image.setWidth(CDom4jHelper.getIntAttribute(node, "width"));
   image.setHeight(CDom4jHelper.getIntAttribute(node, "height"));
   // image.setThumbnail(CDom4jHelper.getAttribute(node,"thumbnail"));
   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")) image.setTitle(CDom4jHelper.getChildrenAsXml(child));
     else if (name.equals("caption")) image.setCaption(CDom4jHelper.getChildrenAsXml(child));
     else if (name.equals("alt"))
       doNothing(); // image.setAlt(CDom4jHelper.getChildrenAsXml(child));
     else if (name.equals("description"))
       doNothing(); // image.setDescription(CDom4jHelper.getChildrenAsXml(child));
     else setProperty(image, name, text);
   }
   this.writer.message("updating image: [" + image.getId() + "]");
 }
Exemplo n.º 6
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;
 }