Example #1
0
 /** 保存新增对象 */
 public String save() {
   // 先判断分区名称是否重复
   if (!partitionManager.isUniqueByDf(partition, "name")) {
     Flash.current().success(Partition.ALIAS_NAME + "已存在!");
     return CREATE_JSP;
   }
   partition.setDf("0");
   partition.setTs(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
   partitionManager.save(partition);
   Flash.current().success(CREATED_SUCCESS); // 存放在Flash中的数据,在下一次http请求中仍然可以读取数据,error()用于显示错误消息
   return LIST_ACTION;
 }
Example #2
0
 /** 删除对象 */
 public String delete() {
   for (int i = 0; i < items.length; i++) {
     Hashtable params = HttpUtils.parseQueryString(items[i]);
     java.lang.String id = new java.lang.String((String) params.get("id"));
     partition = (Partition) partitionManager.getById(id);
     partition.setDf("1");
     // 删除分区时,把分区与管理员的关系 分区与角色的关系删除
     //			partition.setApplications(new HashSet<Application>(0));
     //			partition.setUsers(new HashSet<User>(0));
     partition.setOrganizations(new HashSet<Organization>(0));
     List roles = roleManager.findAllByDf("partitionId", partition.getId());
     if (!roles.isEmpty() && roles.size() > 0) {
       Flash.current().error("分区" + partition.getName() + "下已经有角色等数据,不能删除!");
       return LIST_ACTION;
     }
     partitionManager.update(this.partition);
   }
   Flash.current().success(DELETE_SUCCESS);
   return LIST_ACTION;
 }