private boolean checkProject(Project project) { if (project == null) return false; if (project.getName() == null) return false; if (project.getCode() == null) return false; if (project.getName().trim().length() == 0) return false; if (project.getCode().trim().length() == 0) return false; return true; }
@Before public void setup() { instance = createProject("hkt"); List<ProjectMember> projectMembers = new ArrayList<ProjectMember>(); projectMembers.add(creatProjectMember(1234)); instance.setProjectMembers(projectMembers); instance = repo.save(instance); assertEquals(1, instance.getProjectMembers().size()); }
@Test public void testProjectMember() { Project project = repo.findOne(instance.getId()); project.add(creatProjectMember(33333)); repo.save(project); for (ProjectMember p : repo.findInvoiceDetailByEmployeeCode(33333).get(0).getProjectMembers()) { JOptionPane.showConfirmDialog(null, p); } }
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; }
// 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(); } } } } }