Пример #1
0
  /**
   * 获取自列表的列与掩码的Map
   *
   * @param conn
   * @param PO
   * @param dictMetadata
   * @param DOMeta
   * @throws Exception
   */
  protected static java.util.Map getSelfEnumColViewMap(
      JConnection conn, JParamObject PO, DictMetadata dictMetadata) throws Exception {
    if (dictMetadata == null) {
      return null;
    }
    TableMetadata tableMetadata = dictMetadata.getTableMetadata();
    if (tableMetadata == null) {
      return null;
    }
    java.util.List colList = tableMetadata.getColList();
    if (colList == null) return null;

    // 获取各列的掩码
    java.util.Map map = new java.util.HashMap();
    String objid = tableMetadata.getString("OBJ_ID", "");
    Statement st = null;
    ResultSet rs = null;
    String sql = " select * from SYS_SELFENUM" + " where OBJ_ID='" + objid + "' order by COL_DISP";
    try {
      st = conn.createStatement();
      rs = st.executeQuery(sql);
      while (rs.next()) {
        String colid = rs.getString("COL_ID");
        String colval = rs.getString("COL_VAL");
        String colnote = rs.getString("F_NOTE");
        if (colval == null || colval.length() == 0) {
          colval = " ";
        }
        if (colnote == null || colnote.length() == 0) {
          colnote = colval;
        }
        String view = (String) map.get(colid);
        if (view == null) {
          map.put(colid, colval + ":" + colnote);
        } else {
          if (view.endsWith(";")) {
            view = view.substring(0, view.length() - 1);
          }
          map.put(colid, view + ";" + colval + ":" + colnote);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      conn.BackStatement(st, rs);
    }
    return map;
  }
Пример #2
0
 /** 使用新式的元数据兼容旧的元数据 */
 protected static DictMetadata getMetaDataNew(JConnection conn, JParamObject PO, String dctid)
     throws Exception {
   DictMetadata dictMetadata = DictMetadata.getInstance();
   dictMetadata.setID(dctid);
   Statement st = null;
   DCTMetaData DICTMeta = null;
   DOMetaData DOMeta = null;
   try {
     st = JConnection.getInstance(conn).createStatement();
     //
     ESPServerContext ctx = ESPServerContext.getInstance(PO, JConnection.getInstance(conn));
     ctx.setStatement(st);
     DICTMeta =
         (DCTMetaData)
             MetaDataManager.getInstance(MetaDataManager._DCTObject_ + "_DAL")
                 .getMetaData(ctx, dctid);
     if (DICTMeta != null) {
       DOMeta = DICTMeta.getDoMetaData();
       dictMetadata.setStubTable(new Hashtable());
       dictMetadata.getStubTable().putAll(DICTMeta.getDataMap());
       //                DICTMeta.getSYS_DCT_CST();
     } else {
       DOMeta =
           (DOMetaData)
               MetaDataManager.getInstance(MetaDataManager._DataObject_ + "_DAL")
                   .getMetaData(ctx, dctid);
     }
     // 对象信息
     TableMetadata tableMetadata = TableMetadata.getInstance();
     tableMetadata.setID(dctid);
     tableMetadata.setStubTable(new Hashtable());
     if (tableMetadata.colList == null) tableMetadata.colList = new ArrayList();
     dictMetadata.tableMetadata = tableMetadata;
     // 复制对象信息
     if (DOMeta != null) tableMetadata.getStubTable().putAll(DOMeta.getDataMap());
     // 复制列信息
     getColMetadata(conn, PO, dictMetadata, DOMeta);
     // 复制数据字典的扩展属性
     getSYS_DCT_CST(conn, PO, dictMetadata, DICTMeta);
   } catch (Exception ex) {
     ex.printStackTrace();
   } finally {
     conn.BackStatement(st, null);
   }
   return dictMetadata;
 }
Пример #3
0
 public static DefaultCellEditor getColumnBlobEditor(BlobDataSet bds, ColumnMetaData colinfo) {
   DefaultCellEditor dce = (DefaultCellEditor) colinfo.getEditor();
   if (dce != null) return dce;
   IHelpCallBack callback = null;
   if (colinfo.getHelpClass().trim().length() > 0) {
     try {
       callback = (IHelpCallBack) Class.forName(colinfo.getHelpClass().trim()).newInstance();
       callback.setColumnMetaData(colinfo);
       colinfo.setLostValue("IHelpCallback", callback);
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   } else callback = new ImageHelpCallback(); // 默认的
   dce = new BlobCellEditor(callback, bds, colinfo);
   colinfo.setEditor(dce);
   return dce;
 }
Пример #4
0
 /** 取数据字典的自定义属性列表STUBOBJECT */
 private static List getDictCST(JConnection conn, JParamObject PO, String dctid) {
   java.util.List maps = new ArrayList();
   Statement stmt = null;
   try {
     stmt = conn.createStatement();
     HashMap map = new HashMap();
     map.put("TABLE", "SYS_DCT_CST");
     map.put("WHERE", "DCT_ID = '" + dctid + "'");
     map.put("ORDER", "UNIT_ID,DCT_KEY");
     maps.add(map);
     return DBUtils.SimpleQuery(conn, PO, maps, stmt);
   } catch (Exception ex) {
     ex.printStackTrace();
   } finally {
     conn.BackStatement(stmt, null);
   }
   return null;
 }
Пример #5
0
  public static DefaultCellEditor getColumnEditor(ColumnMetaData colinfo) {
    DefaultCellEditor dce = (DefaultCellEditor) colinfo.getEditor();
    if (dce != null) return dce;
    if (colinfo.getHelpFObj().trim().length() > 0) {
      dce = new FKeyCellEditor(colinfo);
    } else if (colinfo.getHelpClass().trim().length() > 0) {
      IHelpCallBack callback = null;
      try {
        callback = (IHelpCallBack) Class.forName(colinfo.getHelpClass().trim()).newInstance();
        callback.setColumnMetaData(colinfo);
        colinfo.setLostValue("IHelpCallback", callback);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
      dce = new SelfHelpCellEditor(callback, colinfo);
    } else if (colinfo.isFKEY()) {
      dce = new FKeyCellEditor(colinfo);
    } else {
      switch (colinfo.getColEditType()) {
        case ColumnMetaData.EL_STRING:
          dce = new StringCellEditor(colinfo);
          break;
        case ColumnMetaData.EL_TEXT:
          dce = new TextCellEditor(colinfo);
          break;
        case ColumnMetaData.EL_BOOL:
          dce = new BoolCellEditor();
          break;
        case ColumnMetaData.EL_DATE:
          dce = new DateCellEditor();
          ((DateCellEditor) dce).setColumnMetaData(colinfo);
          break;
        case ColumnMetaData.EL_TIME:
          dce = new TimeCellEditor(colinfo, 0);
          ((TimeCellEditor) dce).setColumnMetaData(colinfo);
          break;
        case ColumnMetaData.EL_FLOAT:
          dce = new NumberCellEditor();
          break;
        case ColumnMetaData.EL_POPUP:
          {
            Map hash = new Hashtable();
            String view = colinfo.getString("COL_EDITVIEW", null);
            if (view == null) view = colinfo.getColView();
            // 如果是变量(脚本对象),则获取真正的掩码
            if (view != null && view.equals("@POUP@")) {
              try {
                //                            BIZPoupScript poupScript = new BIZPoupScript(
                //                                    colinfo.getString("OBJ_ID", null),
                //                                    colinfo.getString("COL_ID", null),
                //                                    colinfo.getString("ServerName", ""));
                //                            Object obj = poupScript.getReturnObject();
                //                            if (obj != null && obj instanceof String) {
                //                                view = (String) obj;
                //                            } else {
                //                                view = "";
                //                            }
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            }
            String[] item = view.split(";");
            List keyList = new ArrayList();
            for (int i = 0; i < item.length; i++) {
              if (item[i] == null || item[i].indexOf(":") < 0) continue;
              String s1 = item[i].substring(0, item[i].indexOf(":"));
              String s2 = item[i].substring(item[i].indexOf(":") + 1);
              hash.put(s1, s2);
              keyList.add(s1);
            }
            String editorEditable = colinfo.getString("EnumCellEditor_EDITABLE", "0");
            if (editorEditable.equals("1")) {
              dce = new EnumCellEditor(hash, keyList, colinfo);
            } else {
              dce = new EnumCellEditor(hash, keyList);
            }

            break;
          }
          // 增加密码列
        case ColumnMetaData.EL_WINDOW:
          {
            dce = new PassWordCellEditor();
            break;
          }
          // 增加弹出窗口
        case ColumnMetaData.EL_DIALOG:
          {
            dce = new WindowCellEditor(colinfo);
            break;
          }
          // 自列表
        case ColumnMetaData.EL_SELFENUM:
          {
            Map hash = new Hashtable();
            List keyList = new ArrayList();
            String view = colinfo.getString("COL_EDITVIEW", null);
            if (view == null) view = colinfo.getColView();
            String[] item = view.split(";");
            for (int i = 0; i < item.length; i++) {
              if (item[i] == null || item[i].indexOf(":") < 0) continue;
              String s1 = item[i].substring(0, item[i].indexOf(":"));
              String s2 = item[i].substring(item[i].indexOf(":") + 1);
              hash.put(s1, s2);
              keyList.add(s1);
            }
            dce = new SelfEnumCellEditor(hash, keyList, colinfo);

            break;
          }
        default:
          break;
      }
    }
    colinfo.setEditor(dce);
    return dce;
  }