Esempio n. 1
0
  @Override
  protected String getJSONString(RunData rundata, Context context) throws Exception {
    String result = new JSONArray().toString();
    String mode = this.getMode();
    try {

      if (ALEipConstants.MODE_INSERT.equals(mode)) {
        //
        ToDoFormData formData = new ToDoFormData();
        formData.initField();
        formData.loadCategoryList(rundata);
        if (formData.doInsert(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }

      } else if (ALEipConstants.MODE_UPDATE.equals(mode)) {

        ToDoFormData formData = new ToDoFormData();
        formData.initField();
        formData.loadCategoryList(rundata);
        if (formData.doUpdate(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      } else if (ALEipConstants.MODE_DELETE.equals(mode)) {

        ToDoFormData formData = new ToDoFormData();
        formData.initField();
        formData.loadCategoryList(rundata);
        if (formData.doDelete(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      } else if ("multi_delete".equals(mode)) {

        ToDoMultiDelete delete = new ToDoMultiDelete();
        if (delete.doMultiAction(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      } else if ("multi_complete".equals(mode)) {

        ToDoMultiStateUpdate delete = new ToDoMultiStateUpdate();
        if (delete.doMultiAction(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      }
    } catch (Exception e) {
      logger.error("[ToDoFormJSONScreen]", e);
    }

    return result;
  }
Esempio n. 2
0
  /**
   * @param rundata
   * @param context
   * @param msgList
   * @return
   * @throws ALPageNotFoundException
   * @throws ALDBErrorException
   */
  @Override
  protected boolean setFormData(RunData rundata, Context context, List<String> msgList)
      throws ALPageNotFoundException, ALDBErrorException {

    boolean res = super.setFormData(rundata, context, msgList);

    if (accountId <= 0 || userId <= 0) {
      return res;
    }
    try {
      fileuploadList = FileuploadUtils.getFileuploadList(rundata);
      // Body
      // オブジェクトモデルを取得
      EipMMailAccount account = ALMailUtils.getMailAccount(userId, accountId);
      // 署名を本文に追加
      if (!ALEipConstants.MODE_INSERT.equals(rundata.getParameters().get(ALEipConstants.MODE))
          && account.getSignature() != null
          && !"".equals(account.getSignature())) {
        StringBuffer bodybuf = new StringBuffer();
        if (body.getValue() != null) {
          bodybuf.append(body.getValue());
        }
        bodybuf.append("\r\n\r\n\r\n");
        bodybuf.append(account.getSignature());
        body.setValue(bodybuf.toString());
      }
    } catch (Exception ex) {
      logger.error("webmail", ex);
    }

    return res;
  }
  /**
   * フォームに入力されたデータの妥当性検証を行います。 <br>
   *
   * @param msgList
   * @return
   */
  @Override
  protected boolean validate(List<String> msgList) {
    position_name.validate(msgList);

    try {
      SelectQuery<EipMPosition> query = Database.query(EipMPosition.class);

      if (ALEipConstants.MODE_INSERT.equals(getMode())) {
        Expression exp =
            ExpressionFactory.matchExp(
                EipMPosition.POSITION_NAME_PROPERTY, position_name.getValue());
        query.setQualifier(exp);
      } else if (ALEipConstants.MODE_UPDATE.equals(getMode())) {
        Expression exp1 =
            ExpressionFactory.matchExp(
                EipMPosition.POSITION_NAME_PROPERTY, position_name.getValue());
        query.setQualifier(exp1);
        Expression exp2 =
            ExpressionFactory.noMatchDbExp(
                EipMPosition.POSITION_ID_PK_COLUMN, Integer.valueOf(position_id));
        query.andQualifier(exp2);
      }

      if (query.fetchList().size() != 0) {
        msgList.add(ALLocalizationUtils.getl10nFormat("ACCOUNT_VALIDATE_POSITION", position_name));
      }
    } catch (Exception ex) {
      logger.error("AccountPositionFormData.validate", ex);
      return false;
    }

    return (msgList.size() == 0);
  }
Esempio n. 4
0
  /**
   * フォームに入力されたデータの妥当性検証を行います。 <br>
   *
   * @param msgList
   * @return TRUE 成功 FALSE 失敗
   */
  @Override
  protected boolean validate(List<String> msgList) {
    String tmp_acl_role_name = acl_role_name.getValue();
    if (tmp_acl_role_name != null && !"".equals(tmp_acl_role_name)) {
      // ロール名の重複をチェックする
      try {
        SelectQuery<EipTAclRole> query = Database.query(EipTAclRole.class);
        if (ALEipConstants.MODE_INSERT.equals(getMode())) {
          Expression exp =
              ExpressionFactory.matchExp(EipTAclRole.ROLE_NAME_PROPERTY, tmp_acl_role_name);
          query.setQualifier(exp);
        } else if (ALEipConstants.MODE_UPDATE.equals(getMode())) {
          Expression exp1 =
              ExpressionFactory.matchExp(EipTAclRole.ROLE_NAME_PROPERTY, tmp_acl_role_name);
          query.setQualifier(exp1);
          Expression exp2 =
              ExpressionFactory.noMatchDbExp(
                  EipTAclRole.ROLE_ID_PK_COLUMN, Integer.valueOf(acl_role_id));
          query.andQualifier(exp2);
        }

        if (query.fetchList().size() != 0) {
          msgList.add(
              ALLocalizationUtils.getl10nFormat(
                  "ACCESSCTL_ALERT_ALREADY_CREATED", acl_role_name.toString()));
        }
      } catch (Exception ex) {
        logger.error("AccessControlFormData.validate", ex);
        return false;
      }
    }

    // ロール名
    acl_role_name.validate(msgList);
    // メモ
    note.validate(msgList);

    acllist.validate(msgList);
    acldetail.validate(msgList);
    aclinsert.validate(msgList);
    aclupdate.validate(msgList);
    acldelete.validate(msgList);
    aclexport.validate(msgList);

    // アクセス権限
    if (acllist.getValue() == 0
        && acldetail.getValue() == 0
        && aclinsert.getValue() == 0
        && aclupdate.getValue() == 0
        && acldelete.getValue() == 0
        && aclexport.getValue() == 0) {
      msgList.add(ALLocalizationUtils.getl10n("ACCESSCTL_ALERT_NO_FEATURE_SELECTED"));
    }

    // 所属メンバー
    if (memberList.size() == 0) {
      msgList.add(ALLocalizationUtils.getl10n("ACCESSCTL_ALERT_NO_MEMBER_SELECTED"));
    } else {
      try {
        // 同一機能の他ロールには所属できないようにする

        List<Integer> uids = new ArrayList<Integer>();
        int msize = memberList.size();
        for (int i = 0; i < msize; i++) {
          ALEipUser user = memberList.get(i);
          uids.add(Integer.valueOf((int) user.getUserId().getValue()));
        }

        SelectQuery<EipTAclRole> rolequery = Database.query(EipTAclRole.class);
        Expression exp11 =
            ExpressionFactory.matchDbExp(
                EipTAclRole.EIP_TACL_PORTLET_FEATURE_PROPERTY
                    + "."
                    + EipTAclPortletFeature.FEATURE_ID_PK_COLUMN,
                Integer.valueOf((int) feature_id.getValue()));
        Expression exp12 =
            ExpressionFactory.inDbExp(
                EipTAclRole.EIP_TACL_USER_ROLE_MAPS_PROPERTY
                    + "."
                    + EipTAclUserRoleMap.TURBINE_USER_PROPERTY
                    + "."
                    + TurbineUser.USER_ID_PK_COLUMN,
                uids);
        rolequery.setQualifier(exp11.andExp(exp12));

        if (ALEipConstants.MODE_UPDATE.equals(getMode())) {
          Expression exp13 =
              ExpressionFactory.noMatchDbExp(
                  EipTAclRole.ROLE_ID_PK_COLUMN, Integer.valueOf(acl_role_id));
          rolequery.andQualifier(exp13);
        }

        List<EipTAclRole> roleList = rolequery.fetchList();
        if (roleList != null && roleList.size() != 0) {
          msgList.add(ALLocalizationUtils.getl10n("ACCESSCTL_ALERT_OTHER_ROLE"));
        }
      } catch (Exception ex) {
        logger.error("AccessControlFormData.validate", ex);
        return false;
      }
    }

    return (msgList.size() == 0);
  }