示例#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;
 }
示例#2
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()});
 }