Exemple #1
0
  @Override
  public boolean canDelete() throws JxException {
    boolean b = super.canDelete();
    if (b) {

      JboSetIFace childDeptSet = getRelationJboSet("PUB_DEPARTMENTSUPER_DEPARTMENT_IDP");
      List<JboIFace> childs = childDeptSet.getJbolist();
      if (childs.isEmpty()) {
        JboSetIFace deptUserJboSet = getRelationJboSet("PUB_USERDEPARTMENT_IDP");
        if (!deptUserJboSet.getJbolist().isEmpty()) {
          throw new JxException(JxLangResourcesUtil.getString("app.pubdepartment.DEL.HASUSER"));
        }
      } else {
        for (int i = 0; i < childs.size(); i++) {
          JboIFace jbo = childs.get(i);
          JboSetIFace deptUserJboSet = jbo.getRelationJboSet("PUB_USERDEPARTMENT_IDP");
          if (!deptUserJboSet.getJbolist().isEmpty()) {
            getJboSet().rollback();
            throw new JxException(JxLangResourcesUtil.getString("app.pubdepartment.DEL.HASUSER"));
          } else {
            jbo.delete();
          }
        }
      }
    }
    return b;
  }
Exemple #2
0
  @Override
  public List<JboIFace> query() throws JxException {
    App app = JxSession.getMainApp();
    if (app.getAppNameType().equalsIgnoreCase("PUBDEPARTMENT.LIST")) {
      DataQueryInfo queryInfo = getQueryInfo();

      App userApp = JxSession.getApp("pubdepartment.user");
      if (null != userApp) {
        JboIFace userJbo = userApp.getJbo();
        if (null != userJbo) {
          JboSetIFace userRoleJboSet = userJbo.getRelationJboSet("PUB_ROLE_USERUSER_IDP");
          if (null != userRoleJboSet) {
            List<JboIFace> userRoleList = userRoleJboSet.getJbolist();
            if (!userRoleList.isEmpty()) {
              StringBuffer sb = new StringBuffer();

              sb.append("ROLE_ID NOT IN (");
              int size = userRoleList.size();
              for (int i = 0; i < size; i++) {
                JboIFace tempJbo = userRoleList.get(i);
                sb.append("'").append(tempJbo.getString("ROLE_ID")).append("'");
                if (i < size - 1) {
                  sb.append(",");
                }
              }
              sb.append(")");

              queryInfo.setWhereCause(sb.toString());
            }
          }
        }
      }
    }

    getQueryInfo().setPageNum(0);
    getQueryInfo().setPageSize(40);
    return super.query();
  }