示例#1
0
 private void initDataSet() {
   dataSet.addColumn((Column) dm.getVrstenaloga().getColumn("CVRNAL").clone());
   dataSet.addColumn((Column) dm.getNalozi().getColumn("DATUMKNJ").clone());
   Column clDATUMDO = (Column) dm.getNalozi().getColumn("DATUMKNJ").clone();
   clDATUMDO.setColumnName("DATUMDO");
   dataSet.addColumn(clDATUMDO);
   Column clNK = new Column("NK", "Na\u010Din knjiženja", Variant.STRING);
   clNK.setDefault("K");
   dataSet.addColumn(clNK);
 }
  private void jbInit() throws Exception {
    dbAlias = com.limosys.dbaccess.Connection.getAddress(dbAlias);
    dbAlias.setTransactionIsolation(java.sql.Connection.TRANSACTION_READ_COMMITTED);
    dbAlias.setUseStatementCaching(false);

    pRowSelect.addColumn("ID", Variant.INT);

    colId.setColumnName("ID");
    colId.setServerColumnName("ID");
    colId.setTableName("T_6467063785");
    colId.setRowId(true);
    colId.setDataType(Variant.INT);
    colId.setSqlType(4);
    colName.setColumnName("NAME");
    colName.setServerColumnName("NAME");
    colName.setTableName("T_6467063785");
    colName.setDataType(Variant.STRING);
    colName.setPrecision(255);
    colName.setSqlType(12);
    colCompanyName.setColumnName("COMPANY_NAME");
    colCompanyName.setServerColumnName("COMPANY_NAME");
    colCompanyName.setTableName("T_6467063785");
    colCompanyName.setDataType(Variant.STRING);
    colCompanyName.setPrecision(255);
    colCompanyName.setSqlType(12);
    prT_6467063785.setDatabase(dbAlias);
    // prT_6467063785.setInsertProcedure(new ProcedureDescriptor(dbAlias, "exec
    // lsp_T_6467063785_INotNull_v2  :ID, :NAME, :COMPANY_NAME", pdsT_6467063785, true, Load.ALL));
    prT_6467063785.setDeleteProcedure(
        new ProcedureDescriptor(
            dbAlias, "exec lsp_T_6467063785_D_v2  :ID", pdsT_6467063785, true, Load.ALL));
    pdsT_6467063785.setMetaDataUpdate(MetaDataUpdate.NONE);
    pdsT_6467063785.setResolver(prT_6467063785);
    pdsT_6467063785.setSchemaName("");
    pdsT_6467063785.setProcedure(
        new ProcedureDescriptor(
            dbAlias, "exec lsp_T_6467063785_SRow_v2 :ID", pRowSelect, true, Load.ALL));
    pdsT_6467063785.setColumns(new Column[] {colId, colName, colCompanyName});
  }
示例#3
0
  public StorageDataSet getDataSetBySuperVos(SuperVO[] vos, int digit, Class cls)
      throws BusinessException {
    int iRowCount = (vos == null) ? 0 : vos.length;
    SuperVO vo = null;
    if (iRowCount == 0) { // 查询数据为空,必须构造column
      // System.out.println("DatasetUtil.getDatasetByCAVOs:行数为0");
      try {
        vo = (SuperVO) cls.newInstance();
      } catch (Exception e) {
        throw new BusinessException(e);
      }
    } else {
      vo = vos[0];
      cls = vo.getClass();
    }

    // 反射获得类属性信息
    QEDataSet sds = new QEDataSet();
    try {
      String names[] = vo.getAttributeNames();
      String realnames[] = null;
      if (vo instanceof IVarNameDefine) {
        realnames = ((IVarNameDefine) vo).getVaribleNames();
      }

      // 获得列数
      int iColCount = (names == null) ? 0 : names.length;

      Vector vecName = new Vector();
      Vector vecCol = new Vector();
      for (int i = 0; i < iColCount; i++) {
        try {
          // 创建列
          Column col = new Column();
          if (!CommonUtil.isNull(realnames) && !CommonUtil.isNull(realnames[i])) {
            col.setCaption(realnames[i]);

            col.setColumnName(names[i]);
            // 记录
            vecName.addElement(names[i]);
            vecCol.addElement(col);
            // 获得列类型
            Field fld = null;
            try {
              fld = cls.getField(names[i]);
            } catch (NoSuchFieldException e) {
              throw new BusinessException(e);
            }
            int iType = class2VariantType(fld.getType());
            /*
             * int iType = Variant.STRING; Object obj =
             * vos[0].getAttributeValue(names[i]); if (obj != null &&
             * obj.getClass().getSuperclass() == Number.class) iType =
             * Variant.DOUBLE;
             */
            col.setDataType(iType);
          }

        } catch (Exception e) {
          throw new BusinessException(e);
        }
      }
      // 获得有效列数
      iColCount = vecName.size();
      if (iColCount == 0) {
        // System.out.println("DatasetUtil.getDatasetByCAVOs:列数为0");
        return null;
      }
      // 重构列名数组和列数组
      names = new String[iColCount];
      vecName.copyInto(names);
      Column[] cols = new Column[iColCount];
      vecCol.copyInto(cols);

      // 转换
      sds = new QEDataSet();
      sds.setColumns(cols);
      sds.open();
      for (int i = 0; i < iRowCount; i++) {
        // 构造数据行
        DataRow row = new DataRow(sds);
        for (int j = 0; j < iColCount; j++) {
          Object obj = vos[i].getAttributeValue(names[j]);
          String str = (obj == null) ? null : obj.toString();
          int iColType = cols[j].getDataType();
          // 填充数据行
          DatasetUtil.makeDataRow(row, str, j, iColType);
          row = row;
        }
        // 加行
        sds.addRow(row);
      }
      sds.first();
    } catch (Exception e) {
      throw new BusinessException(e);
    }
    return sds;
  }