public boolean moveDown(String id) { Ida ida = idaDAOImpl.findUnique(" from Ida where id=?", id); String hql = " from Ida where _parentId = ? order by seq asc"; List<Ida> list = idaDAOImpl.find(hql, ida.getParentId()); // 查询兄弟节点 int position = list.indexOf(ida); if (position == (list.size() - 1)) { return false; } for (int i = list.size() - 1; i >= 0; i--) { Ida node = list.get(i); if (i == position) { // 于之前的节点seq互换 Ida before = list.get(i + 1); int seq = node.getSeq(); ida.setSeq(before.getSeq()); before.setSeq(seq); idaDAOImpl.save(ida); return true; } else if (i > position) { node.setSeq(node.getSeq() + 1); // 所有当前节点之前的节点,seq-1; } } return false; }
public IdaMappingBean(Ida ida) { setId(ida.getId()); setStructName(ida.getStructName()); setStructAlias(ida.getStructAlias()); setMetadataId(ida.getMetadataId()); setSeq(ida.getSeq()); setXpath(ida.getXpath()); if (ida.getType() != null) { if (ida.getLength() != null) { setType(ida.getType() + "(" + ida.getLength() + ")"); } else { setType(ida.getType()); } } setScale(ida.getScale()); setLength(ida.getLength()); setRequired(ida.getRequired()); set_parentId(ida.getParentId()); setInterfaceId(ida.getInterfaceId()); setPotUser(ida.getPotUser()); setPotDate(ida.getPotDate()); setHeadId(ida.getHeadId()); setVersion(ida.getVersion()); setRemark(ida.getRemark()); }