/* (非 Javadoc)
   * <p>Title: persistenceFunction</p>
   * <p>Description: 持久化程式弹窗模式</p>
   * @param permission
   * @return
   */
  public boolean persistenceFunction(Permission permission) {
    Integer userId = Constants.getCurrendUser().getUserId();
    if (null == permission.getPermissionId() || "".equals(permission.getPermissionId())) {
      permission.setCreated(new Date());
      permission.setLastmod(new Date());
      permission.setCreater(userId);
      permission.setModifyer(userId);
      permission.setStatus(Constants.PERSISTENCE_STATUS);
      if (Constants.IS_FUNCTION.equals(permission.getType())) {
        permission.setState(Constants.TREE_STATUS_CLOSED);
      } else {
        permission.setState(Constants.TREE_STATUS_OPEN);
      }
      permissionPublicDao.save(permission);
    } else {
      if (Constants.IS_FUNCTION.equals(permission.getType())) {
        permission.setState(Constants.TREE_STATUS_CLOSED);
      } else {
        permission.setState(Constants.TREE_STATUS_OPEN);
      }

      permission.setLastmod(new Date());
      permission.setModifyer(userId);
      permissionPublicDao.update(permission);
    }
    return true;
  }
 public List<TreeModel> findAllFunctionList() {
   String hql = "from Permission t where t.status='A' and t.type='F' ";
   List<Permission> list = permissionPublicDao.find(hql);
   List<TreeModel> tempList = new ArrayList<TreeModel>();
   for (Permission function : list) {
     TreeModel treeModel = new TreeModel();
     treeModel.setId(function.getPermissionId().toString());
     treeModel.setPid(function.getPid() == null ? "" : function.getPid().toString());
     treeModel.setName(function.getName());
     treeModel.setIconCls(function.getIconCls());
     treeModel.setState(Constants.TREE_STATUS_OPEN);
     tempList.add(treeModel);
   }
   return tempList;
 }