public Project createProject(String name, boolean k) {
   Project project = new Project();
   project.setStatus(name);
   project.setName(name);
   project.setCustomerCode(name);
   project.setCode(name);
   project.setParentCode("hkt");
   return project;
 }
Esempio n. 2
0
  // sheet Project
  private void MapTableProject(Sheet sheet) {
    System.out.println("Table : " + sheet.getSheetName());
    String tableName = sheet.getSheetName();
    if (tableName.equals("Du an")) {
      Iterator<Row> rowIterator = sheet.iterator();
      while (rowIterator.hasNext()) {
        // Get the row object

        Project project = new Project();

        Row row = rowIterator.next(); //
        // Every row has columns, get the column iterator and iterate over
        // them
        Iterator<Cell> cellIterator = row.cellIterator();
        if (row.getRowNum() > 0) {
          while (cellIterator.hasNext()) {
            Cell cell = cellIterator.next();
            if (cell.getRow().getRowNum() == 0) {
              System.out.println("---- Column name:" + cell.getNumericCellValue());
            } else {
              if (cell.getColumnIndex() == 2) {

                try {

                  if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
                    System.out.println("STT " + cell.getRowIndex());
                    System.out.println("---- Parent Project: " + cell.getNumericCellValue());
                    if (String.valueOf(cell.getNumericCellValue()) != null) {
                      project.setParentCode(String.valueOf(cell.getNumericCellValue()));
                    }
                  } else {
                    System.out.println("STT " + cell.getRowIndex());
                    System.out.println("---- Parent Project: " + cell.getStringCellValue());
                    if (cell.getStringCellValue() != null) {
                      project.setParentCode(cell.getStringCellValue());
                    }
                  }
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }

              if (cell.getColumnIndex() == 1) {
                System.out.println("---- Name Project: " + cell.getStringCellValue());
                project.setName(cell.getStringCellValue());
                if (project.getName().trim().length() == 0) {
                  continue;
                }
              }

              if (cell.getColumnIndex() == 0) {
                try {

                  if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {

                    project.setCode(String.valueOf(cell.getNumericCellValue()));

                  } else {
                    project.setCode(cell.getStringCellValue());
                  }
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }

              if (cell.getColumnIndex() == 3) {
                System.out.println("---- Description: " + cell.getStringCellValue());
                project.setDepartmentPart(cell.getStringCellValue());
              }

              if (cell.getColumnIndex() == 4) {
                System.out.println("---- Description: " + cell.getStringCellValue());
                project.setDescription(cell.getStringCellValue());
              }
            }
          }
          try {
            if (checkProject(project)) {
              project.setStatus("Đã hoàn thành");
              RestaurantModelManager.getInstance().saveProject(project);
            }
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      }
    }
  }