public void add(Auth auth) { Tauth t = new Tauth(); BeanUtils.copyProperties(auth, t); t.setCid(UUID.randomUUID().toString()); if (auth.getPid() != null && !auth.getPid().equals(auth.getCid())) { t.setTauth(authDao.get(Tauth.class, auth.getPid())); } authDao.save(t); }
public List<Auth> treegrid(Auth auth) { List<Tauth> l; if (auth != null && auth.getId() != null) { l = authDao.find( "from Tauth t where t.tauth.cid = ? order by t.cseq", new Object[] {auth.getId()}); } else { l = authDao.find("from Tauth t where t.tauth is null order by t.cseq"); } return changeModel(l); }
public List<TreeNode> tree(Auth auth, boolean b) { List<Object> param = new ArrayList<Object>(); String hql = "from Tauth t where t.tauth is null order by t.cseq"; if (auth != null && auth.getId() != null && !auth.getId().trim().equals("")) { hql = "from Tauth t where t.tauth.cid = ? order by t.cseq"; param.add(auth.getId()); } List<Tauth> l = authDao.find(hql, param); List<TreeNode> tree = new ArrayList<TreeNode>(); for (Tauth t : l) { tree.add(this.tree(t, b)); } return tree; }
private List<Auth> changeModel(List<Tauth> tauths) { List<Auth> l = new ArrayList<Auth>(); if (tauths != null && tauths.size() > 0) { for (Tauth t : tauths) { Auth a = new Auth(); BeanUtils.copyProperties(t, a); if (t.getTauth() != null) { a.setPid(t.getTauth().getCid()); a.setPname(t.getTauth().getCname()); } if (countChildren(t.getCid()) > 0) { a.setState("closed"); } l.add(a); } } return l; }
public void edit(Auth auth) { Tauth t = authDao.get(Tauth.class, auth.getCid()); // authority to be edit BeanUtils.copyProperties(auth, t); if (auth.getPid() != null && !auth.getPid().equals(auth.getCid())) { Tauth pAuth = authDao.get(Tauth.class, auth.getPid()); // parent authority if (pAuth != null) { if (isDown(t, pAuth)) { Set<Tauth> tauths = t.getTauths(); // all child auth of current auth if (tauths != null && tauths.size() > 0) { for (Tauth tauth : tauths) { if (tauth != null) { tauth.setTauth(null); } } } } t.setTauth(pAuth); } } }
public void delete(Auth auth) { del(auth.getCid()); }