Commit 96d08d33 authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

fix add solution - temporary ssolution

parent 36c55089
......@@ -61,6 +61,7 @@ public class TasksResource
// }
//todo: move to solutions resource
@POST
public boolean submitSolution(@Auth User user,
String flag) throws Exception {
......
......@@ -2,9 +2,12 @@ package repositories;
import database.MongoDBConnector;
import objects.Solution;
import org.bson.Document;
import javax.inject.Inject;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -30,7 +33,13 @@ public class SolutionsRepository implements Repository {
}
public void add(Solution solution) { //todo
// mongoDBConnector.addDocument("solutions", new Document(solution.toMap()));
//todo: object/string
Map<String, Object> retypedMap = solution.toMap().entrySet().stream()
.collect(Collectors.toMap(
(Function<Map.Entry<String, String>, String>) Map.Entry::getKey,
(Function<Map.Entry<String, String>, Object>) Map.Entry::getValue
));
mongoDBConnector.addDocument("solutions", new Document(retypedMap));
}
public void clean() {
......
......@@ -92,6 +92,7 @@ public class TasksRepository implements Repository {
public boolean checkFlag(String username, String flagValue) throws Exception {
return compareHash(flagValue, username);
//todo: accept solution should be here
}
public Optional<String> getUserTaskFlag(String username, String taskId) {
......
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