protected Supplier<List<Person>> scrumMasterSupplier() { return () -> { Skill smSkill = organisationProperty().get().getSmSkill(); Person currentProductOwner = productOwnerProperty().get(); List<Person> currentDevTeam = devTeamProperty().get(); // person has sm skill and does not currently have any other role in the team return teamMembersProperty() .get() .stream() .filter( person -> person.observableSkills().contains(smSkill) && !person.equals(currentProductOwner) && !currentDevTeam.contains(person)) .collect(Collectors.toList()); }; }
static void graphsToFile(List<Triplet<FooGraph, List<Integer>, FooGraph>> l, String name) { try { PrintWriter writer = new PrintWriter(name, "UTF-8"); writer.println("graph G {"); int offset = 0; for (Triplet<FooGraph, List<Integer>, FooGraph> t : l) { FooGraph g = t.getValue0(); List<Integer> markedNodes = t.getValue1(); FooGraph markedEdges = t.getValue2(); for (int i = 0; i < g.numVertices(); i++) { String vertex = "" + (offset + i); if (markedNodes != null && markedNodes.contains(i)) { vertex += " [fillcolor = red, style=filled]"; } writer.println(vertex); } for (int i = 0; i < g.numVertices(); i++) { for (int j = i + 1; j < g.numVertices(); j++) { if (g.adj[i][j]) { String edge = (offset + i) + " -- " + (offset + j); if (markedEdges != null && markedEdges.adj[i][j]) { edge += " [color = red, penwidth=6.0]"; } writer.println(edge); } } } writer.println(""); offset += g.numVertices(); } writer.println("}"); writer.close(); } catch (IOException e) { System.err.println("Caught IOException: " + e.getMessage()); } }
public TeamViewModel() { createValidators(); ListProperty<Person> peopleInOrganisation = new SimpleListProperty<>(); peopleInOrganisation.bind( Bindings.createObjectBinding( () -> { if (organisationProperty().get() != null) { return organisationProperty().get().getPeople(); } else { return FXCollections.observableArrayList(); } }, organisationProperty())); ListProperty<Team> teamsInOrganisation = new SimpleListProperty<>(); teamsInOrganisation.bind( Bindings.createObjectBinding( () -> { if (organisationProperty().get() != null) { return organisationProperty().get().getTeams(); } else { return FXCollections.observableArrayList(); } }, organisationProperty())); ListProperty<Person> peopleInTeams = new SimpleListProperty<>(); peopleInTeams.bind( Bindings.createObjectBinding( () -> { return teamsInOrganisation .stream() .flatMap(team -> team.observableTeamMembers().stream()) // TODO listen .collect(GoatCollectors.toObservableList()); }, teamsInOrganisation)); eligibleTeamMembers = new SimpleListProperty<>(); eligibleTeamMembers.bind( Bindings.createObjectBinding( () -> { return peopleInOrganisation .stream() .filter( person -> !peopleInTeams.contains(person) // no team in model || person.getTeam() == modelWrapper.get()) // this team in model .collect(GoatCollectors.toObservableList()); }, peopleInOrganisation, peopleInTeams)); eligibleDevs = new SimpleListProperty<>(); eligibleDevs.bind( Bindings.createObjectBinding( () -> { return teamMembersProperty() .get() .stream() // is in team .filter( person -> !person.equals(productOwnerProperty().get()) // not PO && !person.equals(scrumMasterProperty().get())) // not SM .collect(GoatCollectors.toObservableList()); }, teamMembersProperty(), productOwnerProperty(), scrumMasterProperty())); teamMembersProperty() .addListener( (ListChangeListener.Change<? extends Person> change) -> { change.next(); List<? extends Person> removed = change.getRemoved(); devTeamProperty().removeAll(removed); if (removed.contains(productOwnerProperty().get())) { productOwnerProperty().set(null); } if (removed.contains(scrumMasterProperty().get())) { scrumMasterProperty().set(null); } }); }