コード例 #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
 /**
  * 批量保存字段
  *
  * @param dataTable
  */
 @Transactional(readOnly = false)
 public void saveTableColumns(DataTable dataTable) {
   List<Object> list = JsonParser.getFormTableDatas(TableColumn.class);
   for (Object obj : list) {
     TableColumn column = (TableColumn) obj;
     column.setCompanyId(ContextUtils.getCompanyId());
     column.setDataTableId(dataTable.getId());
     tableColumnDao.save(column);
   }
 }
コード例 #3
0
 /**
  * 字段保存
  *
  * @param tableColumn
  */
 @Transactional(readOnly = false)
 public void saveColumn(TableColumn tableColumn, boolean canChange) {
   tableColumn.setCompanyId(ContextUtils.getCompanyId());
   tableColumnDao.save(tableColumn);
   //		if(!canChange && !tableColumn.getDataTable().getExistedTable()){
   //			jdbcDao.addTableColumn(tableColumn.getDataTable().getTableName(), tableColumn);
   //		}
 }
コード例 #4
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;
  }