예제 #1
0
  /**
   * @param tableMetadata TableMetadata
   * @param DOMeta DOMetaData
   */
  protected static void getColMetadata(
      JConnection conn, JParamObject PO, DictMetadata dictMetadata, DOMetaData DOMeta)
      throws Exception {
    if (DOMeta == null) return;
    TableMetadata tableMetadata = dictMetadata.getTableMetadata();
    if (tableMetadata.colList == null) tableMetadata.colList = new ArrayList();
    EFDataSet efds = DOMeta.getDOColumns();
    //        //获取自列表列与掩码Map
    //        java.util.Map map = getSelfEnumColViewMap(conn, PO, dictMetadata);
    //        //
    for (int i = 0; i < efds.getRowCount(); i++) {
      EFRowSet edrs = efds.getRowSet(i);
      ColumnMetaData colMetadata = ColumnMetaData.getInstance();
      colMetadata.setStubTable(new Hashtable());
      colMetadata.getStubTable().putAll(edrs.getDataMap());
      //			String colid = colMetadata.getString("COL_ID", "");
      String coledit = colMetadata.getString("COL_EDIT", "");
      //            if(map != null && coledit.equals("15")){
      //                String view = (String)map.get(colid);
      //                colMetadata.setString("COL_VIEW", view);
      //            }
      // 从DOMetaData中获取 gengeng 2011-11-21
      if (coledit.equals(ColumnMetaData.EL_SELFENUM))
        colMetadata.setString("COL_VIEW", edrs.getString("SYS_SELFENUM", ""));

      tableMetadata.colList.add(colMetadata);
      //            getColRefDictMetadata(conn, PO, dictMetadata, colMetadata);
    }
  }
예제 #2
0
 /**
  * @param conn JConnection
  * @param PO JParamObject
  * @param dictMetadata DictMetadata
  * @param colMetadata ColMetaData
  * @throws Exception
  */
 protected static void getColRefDictMetadata(
     JConnection conn, JParamObject PO, DictMetadata dictMetadata, ColumnMetaData colMetadata)
     throws Exception {
   // 如果列没有启用,直接返回
   TableMetadata tableMetadata = dictMetadata.getTableMetadata();
   if (!"1".equals(colMetadata.getString("COL_USE", "1"))) return;
   String COL_FOBJ = colMetadata.getString("COL_FOBJ", null);
   if (COL_FOBJ == null || "".equals(COL_FOBJ.trim())) return;
   // 如果外键是他自己,可能造成死循环,不再获取元数据
   if (COL_FOBJ.equals(tableMetadata.getString("OBJ_ID", ""))) return;
   DictMetadata fkeyDictMetadata = getMetaDataNew(conn, PO, COL_FOBJ);
   attachColmetadataRefDict(colMetadata, fkeyDictMetadata);
 }
예제 #3
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;
  }
예제 #4
0
 protected static void getSYS_DCT_CST(
     JConnection conn, JParamObject PO, DictMetadata dictMetadata, DCTMetaData DCTMeta)
     throws Exception {
   if (DCTMeta == null) return;
   TableMetadata tableMetadata = dictMetadata.getTableMetadata();
   String DCT_ID = tableMetadata.getString("OBJ_ID", "");
   java.util.List list = new ArrayList();
   java.util.Map SYS_DCT_CST = DCTMeta.getSYS_DCT_CST();
   if (SYS_DCT_CST == null) return;
   ;
   for (Iterator it = SYS_DCT_CST.keySet().iterator(); it.hasNext(); ) {
     Object key = it.next();
     Object val = SYS_DCT_CST.get(key);
     StubObject so = new StubObject();
     so.setString("UNIT_ID", "");
     so.setString("DCT_ID", DCT_ID);
     so.setString("DCT_KEY", (String) key);
     so.setString("DCT_VALUE", (String) val);
     list.add(so);
   }
   dictMetadata.setObject("SYS_DCT_CST", list);
 }
예제 #5
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;
 }