Commit cb3c2b61 authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

points stub

parent 5e4bf875
package com.telephoners.krakyournet.ctf.beans;
import com.fasterxml.jackson.annotation.JsonIgnore;
public class Flag {
private String value;
private String description;
......@@ -14,10 +16,12 @@ public class Flag {
this.points = points;
}
@JsonIgnore
public String getValue() {
return value;
}
@JsonIgnore
public void setValue(String value) {
this.value = value;
}
......
package com.telephoners.krakyournet.ctf.repositories;
import com.telephoners.krakyournet.ctf.beans.Flag;
import com.telephoners.krakyournet.ctf.beans.Solution;
import com.telephoners.krakyournet.ctf.beans.Team;
import com.telephoners.krakyournet.ctf.beans.tasks.Task;
......@@ -26,7 +27,7 @@ public class SolutionsRepository extends Repository<Solution>
this.tasksRepository = tasksRepository;
}
public Map<Integer, List<String>> getTeamSolutions(Team team)
public Map<Integer, List<Flag>> getTeamSolutions(Team team)
{
//todo: do not identify team by name? conflict in team ids?
return datastore.createQuery(Solution.class)
......@@ -45,7 +46,7 @@ public class SolutionsRepository extends Repository<Solution>
.collect(Collectors.toMap(
taskSolutions -> taskSolutions.getKey().getLevel(),
taskSolutions -> taskSolutions.getValue().stream()
.map(solution -> solution.getFlag().getDescription()).collect(Collectors.toList())
.map(Solution::getFlag).collect(Collectors.toList())
));
}
......@@ -59,10 +60,10 @@ public class SolutionsRepository extends Repository<Solution>
public List<Integer> getCompletedTasks(Team team)
{
Map<Integer, List<String>> teamSolutions = getTeamSolutions(team);
Map<Integer, List<Flag>> teamSolutions = getTeamSolutions(team);
return tasksRepository.getAll().stream()
.filter(task -> {
List<String> teamTaskSolutions = teamSolutions.get(task.getLevel());
List<Flag> teamTaskSolutions = teamSolutions.get(task.getLevel());
return teamTaskSolutions != null && teamTaskSolutions.size() == task.getFlags().size();
})
.map(Task::getLevel)
......
......@@ -76,7 +76,7 @@ public class SolutionsResource
@GET
@Path("/all")
public Map<String, Map<Integer, List<String>>> getTeamsSolutions()
public Map<String, Map<Integer, List<Flag>>> getTeamsSolutions()
{
return teamsRepository.getAll()
.stream()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment