Commit ac6514f5 authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

use morphia filter

parent dc8677f7
...@@ -46,22 +46,10 @@ public class SolutionsRepository extends Repository<Solution> ...@@ -46,22 +46,10 @@ public class SolutionsRepository extends Repository<Solution>
)); ));
} }
//todo: use datastore filter
public boolean exists(Solution solution) public boolean exists(Solution solution)
{ {
//todo: refactor, ugly ;( return datastore.find(Solution.class)
String value = solution.getFlag().getValue(); .filter("flag.value", solution.getFlag().getValue())
Optional<Solution> matchedSolution = getAll().stream() .get() != null;
.filter(new Predicate<Solution>()
{
@Override
public boolean test(Solution solution)
{
//todo: compare flags, not flag values
return solution.getFlag().getValue().equals(value);
}
})
.findFirst();
return matchedSolution.isPresent();
} }
} }
\ No newline at end of file
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