Esempio n. 1
0
 public void readTags(Element tagsElement, Long parent) throws DaoTaskException {
   for (Iterator<Element> i = tagsElement.elementIterator(); i.hasNext(); ) {
     Element element = i.next();
     if (element.getName().equals("tag")) {
       String name = element.elementText("name");
       String title = element.elementText("title") != null ? element.elementText("title") : name;
       TagEntity tag = getDao().getTagDao().getByName(parent, name);
       if (tag == null) {
         tag = new TagEntity(parent, name, title);
       }
       tag.setName(name);
       getDaoTaskAdapter().tagSave(tag);
       readTags(element, tag.getId());
     }
   }
 }
Esempio n. 2
0
 private List<TreeItemDecorator<TagEntity>> getTagTreeRoots() {
   List<TagEntity> tags = getDao().getTagDao().select();
   Map<Long, TreeItemDecorator<TagEntity>> buf = new HashMap<Long, TreeItemDecorator<TagEntity>>();
   for (TagEntity tag : tags) {
     buf.put(tag.getId(), new TreeItemDecorator<TagEntity>(tag, null));
   }
   List<TreeItemDecorator<TagEntity>> roots = new ArrayList<TreeItemDecorator<TagEntity>>();
   for (Long id : buf.keySet()) {
     TreeItemDecorator<TagEntity> tag = buf.get(id);
     if (tag.getEntity().getParent() == null) {
       roots.add(tag);
     } else {
       TreeItemDecorator<TagEntity> parent = buf.get(tag.getEntity().getParent());
       if (parent != null) {
         parent.getChildren().add(tag);
         tag.setParent(parent);
       }
     }
   }
   return roots;
 }