Commit e13e5810 authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

checking if not already subbmited flag - fixed

parent 2b5924d5
...@@ -13,12 +13,14 @@ public class Solution ...@@ -13,12 +13,14 @@ public class Solution
private Task task; private Task task;
private Team team; private Team team;
private Flag flag; private Flag flag;
private String hashValue;
public Solution(Team team, Task task, Flag flag) public Solution(Team team, Task task, Flag flag, String hashValue)
{ {
this.team = team; this.team = team;
this.task = task; this.task = task;
this.flag = flag; this.flag = flag;
this.hashValue = hashValue;
} }
public Solution() public Solution()
...@@ -54,4 +56,14 @@ public class Solution ...@@ -54,4 +56,14 @@ public class Solution
{ {
this.flag = flag; this.flag = flag;
} }
public String getHashValue()
{
return hashValue;
}
public void setHashValue(String hashValue)
{
this.hashValue = hashValue;
}
} }
...@@ -77,6 +77,7 @@ public class SolutionsRepository implements Repository ...@@ -77,6 +77,7 @@ public class SolutionsRepository implements Repository
@Override @Override
public boolean test(Solution solution) public boolean test(Solution solution)
{ {
//todo: compare flags, not flag values
return solution.getFlag().getValue().equals(value); return solution.getFlag().getValue().equals(value);
} }
}) })
......
...@@ -166,10 +166,11 @@ public class TasksRepository implements Repository ...@@ -166,10 +166,11 @@ public class TasksRepository implements Repository
Pair<Task, Flag> taskFlagPair = taskFlagPairOptional.get(); Pair<Task, Flag> taskFlagPair = taskFlagPairOptional.get();
Task task = taskFlagPair.getKey(); Task task = taskFlagPair.getKey();
Flag flag = taskFlagPair.getValue();
Optional<Team> team = teamsRepository.getTeamByUser(user); Optional<Team> team = teamsRepository.getTeamByUser(user);
if (team.isPresent()) { if (team.isPresent()) {
//todo: combine ifs //todo: combine ifs
Solution solution = new Solution(team.get(), task, hashValue); //todo: conflict, solution stores task flag, should store hashValue!! Solution solution = new Solution(team.get(), task, flag, hashValue);
if (!isAlreadySubmittedSolution(solution)) { if (!isAlreadySubmittedSolution(solution)) {
solutionsRepository.add(solution); solutionsRepository.add(solution);
return true; return true;
......
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