示例#1
0
 private BatchProto.Column buildColumn(EventColumn keyColumn) {
   BatchProto.Column.Builder columnBuilder = BatchProto.Column.newBuilder();
   columnBuilder.setName(keyColumn.getColumnName());
   columnBuilder.setType(keyColumn.getColumnType());
   columnBuilder.setIsNull(keyColumn.isNull());
   columnBuilder.setIsPrimaryKey(keyColumn.isKey());
   columnBuilder.setIndex(keyColumn.getIndex());
   if (keyColumn.getColumnValue() != null) {
     columnBuilder.setValue(keyColumn.getColumnValue());
   }
   columnBuilder.setIsUpdate(keyColumn.isUpdate()); // add by ljh 2012-08-30,标记变更字段
   return columnBuilder.build();
 }
示例#2
0
    /** 构建数据库主键字段的信息 */
    private TableData buildTableData(Table table, List<EventColumn> keys) {
      Column[] tableColumns = table.getColumns();

      TableData data = new TableData();
      data.indexs = new int[keys.size()];
      data.columnNames = new String[keys.size()];
      data.columnTypes = new int[keys.size()];
      data.columnValues = new Object[keys.size()];

      int i = 0;
      int index = 0;
      for (EventColumn keyColumn : keys) {
        for (Column tableColumn : tableColumns) {
          if (StringUtils.equalsIgnoreCase(keyColumn.getColumnName(), tableColumn.getName())) {
            data.indexs[i] = index;
            data.columnNames[i] = tableColumn.getName();
            data.columnTypes[i] = tableColumn.getTypeCode();
            data.columnValues[i] =
                SqlUtils.stringToSqlValue(
                    keyColumn.getColumnValue(),
                    tableColumn.getTypeCode(),
                    tableColumn.isRequired(),
                    false);

            i++;
            break;
          }
          index++;
        }
      }

      if (i != keys.size()) {
        throw new ExtractException(
            "keys is not found in table " + table.toString() + " keys : " + dumpEventColumn(keys));
      }
      return data;
    }