Esempio n. 1
0
 /**
  * 执行Insert 之前,检查数据必填项是否填写完毕。
  *
  * @param jbo
  * @return
  */
 public boolean checkValid(JboIFace jbo) throws JxException {
   if (jbo == null) {
     return false;
   }
   Map<String, JxAttribute> jxattr = jbo.getJxAttributes();
   String jboname = jbo.getJboName();
   String keyName = jbo.getUidName();
   Map<String, Object> data = jbo.getData();
   for (Map.Entry<String, JxAttribute> entry : jxattr.entrySet()) {
     String key = entry.getKey();
     if ((keyName != null && key.equalsIgnoreCase(keyName))) {
       continue;
     }
     JxAttribute attr = entry.getValue();
     if (attr == null) {
       continue;
     } else if (attr.getDefaultValue() != null) {
       if (data.get(key) == null) {
         data.put(key, attr.getDefaultValue());
       }
     } else if (attr.isRequired() && key.indexOf(".") == -1) {
       if (null == data.get(key)) {
         LOG.debug("表名.字段名(" + jboname + "." + key + ")为必填项。");
         throw new JxException(
             "必须填写:"
                 + attr.getObjectName()
                 + " : "
                 + attr.getTitle()
                 + " : "
                 + attr.getAttributeName());
       }
     }
   }
   return true;
 }
Esempio n. 2
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;
  }
Esempio n. 3
0
  private boolean hasNoneActiveDept(List<JboIFace> deptList) throws JxException {
    int size = deptList.size();
    for (int i = 0; i < size; i++) {
      JboIFace dept = deptList.get(i);
      if ("1".equals(dept.getString("STATE"))) {
        throw new JxException(JxLangResourcesUtil.getString("app.pubdepartment.HAS_ACTIVE_DEPT"));
      }
    }

    return true;
  }
Esempio n. 4
0
  private boolean hasNoneActiveUser(List<JboIFace> userList) throws JxException {
    int size = userList.size();
    for (int i = 0; i < size; i++) {
      JboIFace user = userList.get(i);
      if ("1".equals(user.getString("ACTIVE"))) {
        throw new JxException(JxLangResourcesUtil.getString("app.pubdepartment.HAS_ACTIVE_USER"));
      }
    }

    return true;
  }
Esempio n. 5
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();
  }
Esempio n. 6
0
 public int delete(Connection conn, JboIFace jbo) throws JxException {
   if (conn == null || jbo == null) {
     LOG.info("传入的参数为空。");
     return -1;
   }
   String tabname = jbo.getJboSet().getEntityname();
   String msql = "Delete from " + tabname + " where " + jbo.getUidName() + "=?";
   Object[] columns = new Object[] {jbo.getJxAttributes().get(jbo.getUidName())};
   JxLog jxlog = JxLogFactory.getJxLog(jbo.getJboSet().getAppname(), tabname);
   if (jxlog != null) {
     jxlog.info(jbo, "DELETE");
   }
   return execute(conn, msql, columns, new Object[] {jbo.getUidValue()});
 }
Esempio n. 7
0
 @Override
 protected void populateParams() {
   Tablecol col = (Tablecol) component;
   col.setId(id);
   col.setType(type);
   col.setMxevent_desc(mxevent_desc);
   col.setMxevent(mxevent);
   col.setMxevent_disabled(mxevent_disabled);
   col.setDataattribute(dataattribute);
   col.setLookup(lookup);
   col.setLookupWidth(lookupWidth);
   col.setLookupHeight(lookupHeight);
   col.setLookupWrite(lookupWrite);
   col.setLinkedcontrolid(linkedcontrolid);
   col.setMxevent_icon(mxevent_icon);
   col.setFilterable(filterable);
   col.setFiltername(filtername);
   col.setSortable(sortable);
   col.setSortname(sortname);
   col.setStartHtml(startHtml);
   col.setHtml(html);
   col.setRender(render);
   col.setVisibleHead(visibleHead);
   col.setFormat(format);
   col.setTable(table);
   col.setInputsize(inputsize);
   col.setMaxlength(maxlength);
   col.setWidth(width);
   col.setHeight(height);
   col.setNote(note);
   col.setReadonly(readonly);
   col.setSecondAttributes(secondAttributes);
   col.setDataname(dataname);
   JxParams jparam = BeanUtil.getJxParams();
   if (jparam != null) {
     if ("comtop".equalsIgnoreCase(urlType)) {
       col.setUrlType(jparam.getComtopUrl());
     } else if ("report".equalsIgnoreCase(urlType)) {
       col.setUrlType(jparam.getReportUrl());
     } else {
       col.setUrlType(urlType);
     }
   } else {
     col.setUrlType(urlType);
   }
   col.setUrlParamName(urlParamName);
   col.setUrlParamValue(urlParamValue);
   transformUrlParams(); // 转换所有参数的值
   col.setAllUrlParams(allUrlParams);
   col.setUrlTarget(urlTarget);
   col.setTitle(title);
   col.setAlign(align);
   col.setDataDisplay(dataDisplay);
   col.setVisible(visible);
   col.setDescdataattribute(descdataattribute);
   Tag tag = findAncestorWithClass(this, TableTag.class);
   if (tag != null && dataattribute != null) {
     TableTag ttag = (TableTag) tag;
     JboSetIFace jboset = ttag.getJboset();
     if (jboset != null) {
       try {
         Object jo = jboset.getJxAttribute(dataattribute.toUpperCase());
         if (jo != null) {
           jxattribute = (JxAttribute) jo;
           col.setJxattribute(jxattribute);
           for (JboIFace jbo : jboset.getJbolist()) {
             if (null != jbo) {
               if (!"TRUE".equalsIgnoreCase(required)) {
                 required = String.valueOf(jbo.isRequired(dataattribute));
               } else {
                 jbo.setRequired(dataattribute, true);
               }
             }
           }
         }
       } catch (Exception e) {
         LOG.error(e.getMessage(), e);
       }
     }
   }
   super.populateParams();
 }
Esempio n. 8
0
 /**
  * 保存数据
  *
  * @param conn
  * @param jbo
  * @return
  */
 public boolean save(Connection conn, JboIFace jbo) throws JxException {
   if (conn == null || jbo == null) {
     LOG.warn("保存数据失败,conn is null or jbo is null.");
     return false;
   }
   Map<String, Object> data = jbo.getData();
   if (data == null) {
     LOG.info("没有要保存的数据");
     return false;
   }
   int res;
   if (jbo.isToBeAdd() && jbo.isToBeDel()) {
     return true;
   }
   String tableName = jbo.getJboSet().getEntityname();
   if (jbo.isToBeDel() && !jbo.isToBeAdd()) {
     if (delete(conn, jbo) > 0) {
       removeCache(tableName);
       return true;
     } else {
       return false;
     }
   }
   if (!jbo.isModify() && !jbo.isToBeAdd()) {
     return true;
   }
   String keyName = jbo.getUidName();
   if (StrUtil.isNull(keyName)) {
     throw new JxException("表" + tableName + "没有指定关键字,请与管理员联系。");
   }
   Object keyValue = data.get(keyName);
   JboSetIFace js = jbo.getJboSet();
   DataQuery dq = DBFactory.getDataQuery(js.getDbtype(), js.getDataSourceName());
   // 设定记录信息
   java.sql.Timestamp ts = DateUtil.sqlDateTime();
   JxUserInfo user = JxSession.getJxUserInfo();
   if (user != null && jbo != null) {
     jbo.setString("MODIFIER_ID", user.getUserid());
     jbo.setString("MODIFIER", user.getDisplayname());
     jbo.setObject("MODIFY_TIME", ts);
     jbo.setObject("MODIFY_DATE", ts);
     jbo.setString("CHANGEBY", user.getUserid());
     jbo.setObject("CHANGEDATE", ts);
   }
   if (dq.exist(conn, tableName, keyName, keyValue)) {
     // 更改记录,修改人、修改时间要设置为现在
     res = update(conn, jbo);
   } else {
     res = insert(conn, jbo);
   }
   if (res > 0) {
     removeCache(tableName);
     return true;
   } else {
     LOG.info("没有保存到数据," + tableName + "." + keyName + "=" + keyValue);
     return false;
   }
 }