Esempio n. 1
1
  @Override
  public Command getCommand() {
    // edit command
    final ArrayList<Command> changes = new ArrayList<>();
    super.addEditCommands.accept(changes);

    if (productOwnerProperty().get() != modelWrapper.get().getProductOwner()) {
      changes.add(
          new EditCommand<>(modelWrapper.get(), "productOwner", productOwnerProperty().get()));
    }

    if (scrumMasterProperty().get() != modelWrapper.get().getScrumMaster()) {
      changes.add(
          new EditCommand<>(modelWrapper.get(), "scrumMaster", scrumMasterProperty().get()));
    }

    if (!(teamMembersProperty().get().containsAll(modelWrapper.get().getTeamMembers())
        && modelWrapper.get().getTeamMembers().containsAll(teamMembersProperty().get()))) {
      // BEWARE: magic
      ArrayList<Person> teamMembers = new ArrayList<>();
      teamMembers.addAll(teamMembersProperty().get());
      changes.add(new EditCommand<>(modelWrapper.get(), "teamMembers", teamMembers));
    }

    if (!(devTeamProperty().get().containsAll(modelWrapper.get().getDevTeam())
        && modelWrapper.get().getDevTeam().containsAll(devTeamProperty().get()))) {
      // BEWARE: magic
      ArrayList<Person> devTeam = new ArrayList<>();
      devTeam.addAll(devTeamProperty().get());
      changes.add(new EditCommand<>(modelWrapper.get(), "devTeam", devTeam));
    }

    final ArrayList<Person> newMembers = new ArrayList<>(teamMembersProperty().get());
    newMembers.removeAll(modelWrapper.get().observableTeamMembers());
    final ArrayList<Person> oldMembers =
        new ArrayList<>(modelWrapper.get().observableTeamMembers());
    oldMembers.removeAll(teamMembersProperty().get());

    // Loop through all the new members and add a command to set their team
    // Set the person's team field to this team
    changes.addAll(
        newMembers
            .stream()
            .map(person -> new EditCommand<>(person, "team", modelWrapper.get()))
            .collect(Collectors.toList()));

    // Loop through all the old members and add a command to remove their team
    // Set the person's team field to null, since they're no longer in the team
    changes.addAll(
        oldMembers
            .stream()
            .map(person -> new EditCommand<>(person, "team", null))
            .collect(Collectors.toList()));

    return new CompoundCommand("Edit Team", changes);
  }
Esempio n. 2
0
 public List<Allocation> getAllocations() {
   final ArrayList<Allocation> allocations1 = new ArrayList<>();
   allocations1.addAll(allocations);
   return allocations1;
   //        return Collections.unmodifiableList(allocations);
 }