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>
));
}
//todo: use datastore filter
public boolean exists(Solution solution)
{
//todo: refactor, ugly ;(
String value = solution.getFlag().getValue();
Optional<Solution> matchedSolution = getAll().stream()
.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();
return datastore.find(Solution.class)
.filter("flag.value", solution.getFlag().getValue())
.get() != null;
}
}
\ 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