public List<Manager> getManagerList(Programmer programmer) { List<Manager> managerList = new ArrayList<Manager>(); List<Project> projectList = new ProjectDaoTEXT().getProjectListProgrammer(programmer); try { loop: for (Project project : projectList) { Scanner scanner = new Scanner(fileProjects); String idProject = ""; String buf = ""; while (scanner.hasNextLine()) { buf = scanner.nextLine(); if (buf.split(":")[0].equals("id")) idProject = buf.split(":")[1]; if (buf.split(":")[0].equals("IDmanager") && idProject.equals(String.valueOf(project.getIdProject()))) { managerList.add(getManager(Integer.parseInt(buf.split(":")[1]))); continue loop; } } } return managerList; } catch (FileNotFoundException e) { e.printStackTrace(); } return null; }
@Test public void testCreaSequenza() { try { client1 = new Client(TestSequence1.port, TestSequence1.nomeServer); client1.connettiUtente(TestSequence1.nomeTest, TestSequence1.passwordTest); ArrayList<Project> pList = client1.mostraProgetti(); ArrayList<User> uList = client1.mostraContatti(); Project test = pList.get(0); client1.addActivity(test, TestSequence1.nomeA, "", uList.get(0), 0); client1.addActivity(test, TestSequence1.nomeA + "1", "", uList.get(0), 1); client1.startProject(test); assertEquals( "L'attività deve essere in corso", StateActivity.IN_CORSO, test.getListActivities().get(0).getStatoActivity()); assertEquals( "La seconda attività deve essere IN_ATTESA", StateActivity.IN_ATTESA, test.getListActivities().get(1).getStatoActivity()); } catch (Exception e) { e.printStackTrace(); } }
/** * Gives Project object from given identifier * * @param projectId * @return * @throws DatabaseException * @throws SQLException * @throws DatabaseValueNotFoundException */ public Project getProject(int projectId) throws DatabaseException, SQLException, DatabaseValueNotFoundException { PreparedStatement statement = this.conApex.prepareStatement( "SELECT * FROM BRG_PROJECT WHERE ID=?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); statement.setInt(1, projectId); ResultSet result = statement.executeQuery(); ArrayList<Rule> rules = getRules(projectId); while (result.next()) { Project tmpProject = new Project( result.getInt("ID"), result.getString("NAME"), result.getString("TARGET_DATABASE_DESC"), new DbConfiguration( result.getString("TARGET_DATABASE_IP"), result.getString("TARGET_DATABASE_USERNAME"), result.getString("TARGET_DATABASE_PASSWORD"), result.getString("TARGET_DATABASE_DATABASE"), result.getString("TARGET_DATABASE_PORT"))); if (rules != null) { for (Rule rule : rules) { ArrayList<Column> collumns = getColumns(rule.getId()); if (collumns != null) { for (Column column : collumns) { rule.addColumns(column); } } ArrayList<Value> values = getValues(rule.getId()); if (values != null) { for (Value value : values) { rule.addValues(value); } } ArrayList<Table> tables = getTables(rule.getId()); if (tables != null) { for (Table table : tables) { rule.addTables(table); } } tmpProject.addRule(rule); } } statement.close(); return tmpProject; } statement.close(); throw new DatabaseValueNotFoundException("Project " + projectId + " not found"); }
public double getMinAttrib(Project.Attribute attr) { double min = Double.MAX_VALUE; double value; for (Project p : refProjects) { value = p.getAttribute(attr); if (value < min) { min = value; } } return min; }
public double getMaxAttrib(Project.Attribute attr) { double max = 0; double value; for (Project p : refProjects) { value = p.getAttribute(attr); if (value > max) { max = value; } } return max; }
public List<Result> similarProjects(Project inputProject) { // LinkedList<Project> projects = new LinkedList<Project>(); ArrayList<Result> projects = new ArrayList<Result>(); double tmpSim; for (Project p : refProjects) { if ((tmpSim = p.calculateSimilarity(inputProject, this)) >= threshold) { projects.add(new Result(tmpSim, p)); } } return projects; }
public Collection<Activity> getAllActivitiesFromProject(Project project) { Collection<Activity> allActivities = activityService.findAllActivities(); Collection<Activity> projectActivities = new ArrayList<Activity>(); for (Activity activity : allActivities) { if (activity.getProject().getIdproject().equals(project.getIdproject())) { projectActivities.add(activity); } } return projectActivities; }
public void setup() { // Populate database. // First delete all old records. this.entityManager.createQuery("Delete from PhoneNumber p").executeUpdate(); this.entityManager.createQuery("Delete from Employee e").executeUpdate(); this.entityManager.createQuery("Delete from Address a").executeUpdate(); for (int j = 0; j < 100; j++) { Employee empInsert = new Employee(); empInsert.setFirstName("Brendan"); empInsert.setMale(); empInsert.setLastName("" + j + ""); empInsert.setSalary(100000); EmploymentPeriod employmentPeriod = new EmploymentPeriod(); java.sql.Date startDate = new java.sql.Date(new java.util.Date().getTime()); employmentPeriod.setStartDate(startDate); empInsert.setPeriod(employmentPeriod); empInsert.setAddress(new Address()); empInsert.getAddress().setCity("Nepean"); empInsert.getAddress().setPostalCode("N5J2N5"); empInsert.getAddress().setProvince("ON"); empInsert.getAddress().setStreet("1111 Mountain Blvd. Floor 13, suite " + j); empInsert.getAddress().setCountry("Canada"); empInsert.addPhoneNumber(new PhoneNumber("Work Fax", "613", "2255943")); empInsert.addPhoneNumber(new PhoneNumber("Home", "613", "2224599")); this.entityManager.persist(empInsert); } for (int j = 0; j < 50; j++) { Project project = new SmallProject(); project.setName("Tracker"); this.entityManager.persist(project); project = new LargeProject(); project.setName("Tracker"); this.entityManager.persist(project); } }
public String findItemProjectName(Integer id) { Project p = activityService.findItem(id).getProject(); return p.getName(); }