Ejemplo n.º 1
0
  /**
   * 削除処理を行います.<br>
   * 削除完了時および何かしら問題があった場合に、画面にメッセージを表示します.<br>
   * 処理実行後、{@link Mapping#INPUT}で定義されたURIに遷移します.
   *
   * @return 画面遷移先のURI文字列
   * @throws Exception
   */
  @Execute(validator = false)
  public String delete() throws Exception {
    try {
      List<Dept> deptList = this.deptService.findByParentId(this.editDeptForm.deptId);
      if (deptList.size() > 0) {
        super.messages.add(
            ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.dept.childexists"));
        ActionMessagesUtil.addErrors(super.httpRequest, super.messages);
        return EditDeptAction.Mapping.INPUT;
      }

      this.deptService.deleteRecord(
          Beans.createAndCopy(DeptDto.class, this.editDeptForm).execute());
      this.init(null);

      super.messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("infos.delete"));
      ActionMessagesUtil.addMessages(super.httpRequest, super.messages);
    } catch (UnabledLockException e) {
      super.errorLog(e);

      super.messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(e.getKey()));
      ActionMessagesUtil.addErrors(super.httpRequest, super.messages);
    } catch (ServiceException e) {
      super.errorLog(e);
      throw e;
    }
    return EditDeptAction.Mapping.INPUT;
  }
Ejemplo n.º 2
0
  /**
   * 登録処理を行います.<br>
   * 登録完了時および何かしらの問題があった場合に、画面にメッセージを表示します.<br>
   * 処理実行後、{@link Mapping#INPUT}で定義されたURIに遷移します.
   *
   * @return 画面遷移先のURI文字列
   * @throws Exception
   */
  @Execute(validator = true, validate = "validateForInsert", input = EditDeptAction.Mapping.INPUT)
  public String insert() throws Exception {
    try {
      Dept dept = this.deptService.findById(this.editDeptForm.deptId);
      if (dept != null) {
        super.messages.add(
            ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.dept.already.exists"));
        ActionMessagesUtil.addErrors(super.httpRequest, super.messages);
        return EditDeptAction.Mapping.INPUT;
      }

      DeptDto dto = Beans.createAndCopy(DeptDto.class, this.editDeptForm).execute();

      this.deptService.insertRecord(dto);

      this.init(this.editDeptForm.deptId);

      super.messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("infos.insert"));
      ActionMessagesUtil.addMessages(super.httpRequest, super.messages);
    } catch (ServiceException e) {
      super.errorLog(e);
      throw e;
    }
    return EditDeptAction.Mapping.INPUT;
  }
Ejemplo n.º 3
0
  /**
   * 更新処理を行います.<br>
   * 更新完了時に、画面にメッセージを表示します. 処理実行後、{@link Mapping#INPUT}で定義されたURIに遷移します.
   *
   * @return 画面遷移先のURI文字列
   * @throws Exception
   */
  @Execute(validator = true, validate = "validateForUpdate", input = EditDeptAction.Mapping.INPUT)
  public String update() throws Exception {
    try {
      DeptDto dto = Beans.createAndCopy(DeptDto.class, this.editDeptForm).execute();

      this.deptService.updateRecord(dto);

      this.init(this.editDeptForm.deptId);

      super.messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("infos.update"));
      ActionMessagesUtil.addMessages(super.httpRequest, super.messages);
    } catch (UnabledLockException e) {
      super.errorLog(e);

      super.messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(e.getKey()));
      ActionMessagesUtil.addErrors(super.httpRequest, super.messages);
    } catch (ServiceException e) {
      super.errorLog(e);
      throw e;
    }
    return EditDeptAction.Mapping.INPUT;
  }