Checkpint - algorythm works
This commit is contained in:
@ -5,6 +5,7 @@ import java.util.Optional;
|
||||
|
||||
import com.plannaplan.entities.Assignment;
|
||||
import com.plannaplan.entities.Commision;
|
||||
import com.plannaplan.entities.Groups;
|
||||
import com.plannaplan.entities.User;
|
||||
import com.plannaplan.repositories.AssignmentRepository;
|
||||
|
||||
@ -21,6 +22,12 @@ public class AssignmentService {
|
||||
@Autowired
|
||||
private AssignmentRepository repo;
|
||||
|
||||
@Autowired
|
||||
private CommisionService service;
|
||||
|
||||
@Autowired
|
||||
private GroupService groupService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@ -65,7 +72,17 @@ public class AssignmentService {
|
||||
final List<User> students = this.userService.getStudentsSortedByRanking();
|
||||
|
||||
students.forEach(e -> {
|
||||
System.out.println(e.getRanking());
|
||||
final Optional<Commision> com = this.service.getNewestCommision(e);
|
||||
if (com.isPresent()) {
|
||||
final List<Assignment> assignments = this.getCommisionAssignments(com.get());
|
||||
assignments.forEach(a -> {
|
||||
final Groups group = a.getGroup();
|
||||
if (group.getCapacity() > group.getRegisteredStudents().size()) {
|
||||
e.claimGroup(group);
|
||||
this.userService.save(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user