示例#1
0
 /**
  * 删除数据表字段
  *
  * @param columnId
  */
 @Transactional(readOnly = false)
 public void deleteTableColumn(Long columnId) {
   TableColumn column = tableColumnDao.get(columnId);
   column.setDeleted(true);
   tableColumnDao.save(column);
   //		tableColumnDao.delete(columnId);
 }
示例#2
0
  @Transactional(readOnly = false)
  public List<TableColumn> importIntoData(File file, DataTable dataTable) throws IOException {
    List<TableColumn> columns = new ArrayList<TableColumn>();
    FileInputStream fileIn = null;

    try {
      List<TableColumn> exsitColumns =
          tableColumnManager.getTableColumnByDataTableId(dataTable.getId());
      for (TableColumn col : exsitColumns) {
        col.setDeleted(true);
        tableColumnManager.saveColumn(col, false);
      }
      fileIn = new FileInputStream(file);
      POIFSFileSystem fs = new POIFSFileSystem(fileIn);
      HSSFWorkbook wb = new HSSFWorkbook(fs);
      HSSFSheet sheet = wb.getSheetAt(0);
      HSSFRow row = null;
      TableColumn tableColumn = null;
      String val = null;
      for (int i = 1; i < sheet.getLastRowNum() + 1; i++) {
        row = sheet.getRow(i);
        tableColumn = new TableColumn();
        tableColumn.setName(row.getCell(0).getStringCellValue());
        tableColumn.setDbColumnName(row.getCell(1).getStringCellValue());
        tableColumn.setAlias(row.getCell(2).getStringCellValue());
        tableColumn.setDataType(DataType.valueOf(row.getCell(3).getStringCellValue()));
        tableColumn.setDefaultValue(row.getCell(4).getStringCellValue());
        val = row.getCell(5).getStringCellValue();
        tableColumn.setMaxLength(StringUtils.isEmpty(val) ? null : Integer.parseInt(val));
        tableColumn.setDisplayOrder(Integer.parseInt(getCellValue(row.getCell(6))));
        tableColumn.setDataTableId(dataTable.getId());
        tableColumnManager.saveColumn(tableColumn, false);
        columns.add(tableColumn);
      }
    } finally {
      if (fileIn != null) fileIn.close();
    }
    return columns;
  }