Ejemplo n.º 1
0
  @Override
  public Role edit(Role role) {
    Trole t = roleDao.get(Trole.class, role.getId());
    if (t != null) {
      Map<String, Object> params = new HashMap<String, Object>();
      params.put("trole", t);
      roleResourceDao.executeHql("delete TroleTresource t where t.trole=:trole", params);

      BeanUtils.copyProperties(role, t);
      if (role.getResourceIds() != null) {
        String resourceNames = "";
        for (String id : role.getResourceIds().split(",")) {
          Tresource r = resourceDao.get(Tresource.class, id);
          if (r != null) {
            TroleTresource rr = new TroleTresource();
            rr.setId(UUID.randomUUID().toString());
            rr.setTresource(r);
            rr.setTrole(t);
            roleResourceDao.save(rr);

            if (resourceNames.length() > 0) {
              resourceNames += ",";
            }
            resourceNames += r.getText();
          }
        }
        role.setResourceNames(resourceNames);
      }
    }
    return role;
  }
Ejemplo n.º 2
0
 @Override
 public void remove(String ids) {
   // for (String id : ids.split(",")) {
   // Tuser u = userDao.get(Tuser.class, id);
   // if (u != null) {
   // userDao.delete(u);
   // }
   // }
   String[] nids = ids.split(",");
   String hql = "delete Tuser t where t.id in (";
   for (int i = 0; i < nids.length; i++) {
     if (i > 0) {
       hql += ",";
     }
     hql += "'" + nids[i] + "'";
   }
   hql += ")";
   userDao.executeHql(hql);
 }