コード例 #1
0
ファイル: TeamViewModel.java プロジェクト: JJHarrison/seng302
 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());
   };
 }
コード例 #2
0
ファイル: TeamViewModel.java プロジェクト: JJHarrison/seng302
  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);
              }
            });
  }