private void addStatuses() throws IOException { RandomAccessFile f = new RandomAccessFile("randomStatus.csv", "r"); String dataString = null; while ((dataString = f.readLine()) != null) { String[] data = dataString.split(";"); Status insert = new Status(); if (data[0].length() < 45) { insert.setStatusName(data[0]); } else { insert.setStatusName(data[0].substring(0, 44)); } System.out.println(insert); try { statusDAO.insertStatus(insert); } catch (StatusNameExistsException e) { e.printStackTrace(); } } f.close(); }
private void addProjects() throws IOException { RandomAccessFile f = new RandomAccessFile("randomProject.csv", "r"); String dataString = null; ArrayList<Status> stat = null; try { stat = statusDAO.getAllStatuses(); } catch (DAOException e1) { e1.printStackTrace(); } Random random = new Random(1l); while ((dataString = f.readLine()) != null) { String[] data = dataString.split(";"); Project insert = new Project(); if (data[0].length() < 45) { insert.setProjectName(data[0]); } else { insert.setProjectName(data[0].substring(0, 44)); } if (data[1].equals("1")) { insert.setOpenedStatus(true); } else { insert.setOpenedStatus(false); } insert.setStartWeek(Integer.parseInt(data[2])); insert.setDeadLine(Integer.parseInt(data[3])); insert.setNextRelease(data[4]); insert.setDescription(data[5]); insert.setCurrentStatusID(stat.get(random.nextInt(stat.size())).getStatusID()); System.out.println(insert); try { projectDAO.insertProject(insert); } catch (ProjectNameExistsException e) { e.printStackTrace(); } } f.close(); }