Пример #1
0
 @Transactional
 public void update(Node node, Integer[] viewOrgIds) {
   if (viewOrgIds == null) {
     viewOrgIds = new Integer[0];
   }
   SortedSet<NodeOrg> nodeOrgs = node.getNodeOrgs();
   if (nodeOrgs == null) {
     nodeOrgs = new TreeSet<NodeOrg>(new NodeOrgComparator());
     node.setNodeOrgs(nodeOrgs);
   }
   // 先更新
   for (NodeOrg nodeOrg : nodeOrgs) {
     if (ArrayUtils.contains(viewOrgIds, nodeOrg.getOrg().getId())) {
       nodeOrg.setViewPerm(true);
     } else {
       nodeOrg.setViewPerm(false);
     }
   }
   // 再新增
   for (Integer viewOrgId : viewOrgIds) {
     boolean contains = false;
     for (NodeOrg nodeOrg : nodeOrgs) {
       if (nodeOrg.getOrg().getId().equals(viewOrgId)) {
         contains = true;
         break;
       }
     }
     if (!contains) {
       nodeOrgs.add(save(node, viewOrgId, true));
     }
   }
 }
Пример #2
0
 public RowSide<Node> findSide(
     Integer parentId,
     Boolean showDescendants,
     Integer userId,
     boolean allNode,
     Map<String, String[]> params,
     Node bean,
     Integer position,
     Sort sort) {
   if (position == null) {
     return new RowSide<Node>();
   }
   Limitable limit = RowSide.limitable(position, sort);
   List<Node> list;
   if (showDescendants != null && showDescendants) {
     String treeNumber = null;
     if (parentId != null) {
       Node parent = get(parentId);
       treeNumber = parent.getTreeNumber();
     }
     list = dao.findAll(spec(null, treeNumber, userId, allNode, params), limit);
   } else {
     if (parentId != null) {
       list = dao.findAll(spec(parentId, null, userId, allNode, params), limit);
     } else {
       list = Collections.emptyList();
     }
   }
   return RowSide.create(list, bean);
 }
Пример #3
0
 @Transient
 public List<Node> getHierarchy() {
   List<Node> hierarchy = new LinkedList<Node>();
   Node node = this;
   while (node != null) {
     hierarchy.add(0, node);
     node = node.getParent();
   }
   return hierarchy;
 }
Пример #4
0
 @Transient
 public String getDisplayName() {
   StringBuilder sb = new StringBuilder();
   Node node = this;
   sb.append(node.getName());
   node = node.getParent();
   while (node != null) {
     sb.insert(0, " - ");
     sb.insert(0, node.getName());
     node = node.getParent();
   }
   return sb.toString();
 }
Пример #5
0
 public List<Node> findList(
     Integer siteId, Integer parentId, Boolean isRealNode, Boolean isHidden) {
   String treeNumber = null;
   if (parentId != null) {
     Node node = get(parentId);
     if (node != null) {
       treeNumber = node.getTreeNumber();
     }
   }
   Sort sort = new Sort("treeNumber");
   Limitable limitable = new LimitRequest(null, null, sort);
   return dao.findList(new Integer[] {siteId}, null, treeNumber, isRealNode, isHidden, limitable);
 }
Пример #6
0
 public List<Node> findList(
     Integer parentId,
     Boolean showDescendants,
     Integer userId,
     boolean allNode,
     Map<String, String[]> params,
     Sort sort) {
   List<Node> list;
   if (showDescendants != null && showDescendants) {
     Node parent = get(parentId);
     String treeNumber = parent.getTreeNumber();
     list = dao.findAll(spec(null, treeNumber, userId, allNode, params), sort);
   } else {
     list = dao.findAll(spec(parentId, null, userId, allNode, params), sort);
   }
   return list;
 }
Пример #7
0
 @Transient
 public void updateHtmlStatus() {
   Node node = this;
   while (node != null) {
     if (node.getGenerate()) {
       if (StringUtils.isNotBlank(node.getHtml())) {
         node.setHtmlStatus(HTML_TOBE_UPDATE);
       } else {
         node.setHtmlStatus(HTML_TOBE_GENERATE);
       }
     } else {
       if (StringUtils.isNotBlank(node.getHtml())) {
         node.setHtmlStatus(HTML_TOBE_DELETE);
       } else {
         node.setHtmlStatus(HTML_DISABLED);
       }
     }
     node = node.getParent();
   }
 }
 public void addDocument(final Integer siteId, final Node node, Integer userId) {
   String name = "ALL";
   if (node != null) {
     name = node.getName();
   }
   Task task = taskService.save("Node: " + name, null, Task.FULLTEXT, userId, siteId);
   final Integer taskId = task.getId();
   new Thread() {
     @Override
     public void run() {
       try {
         infoFulltextService.addDocument(siteId, node, taskService, taskId);
         taskService.finish(taskId);
       } catch (Exception e) {
         taskService.abort(taskId);
         logger.error("create fulltext index error!", e);
       }
     }
   }.start();
 }