Commit cde37948 authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

remove initalizing in repositories

parent 811a548a
......@@ -8,7 +8,6 @@ import java.util.List;
public interface Repository {
// void getByTaskName(UUID uuid);
List getAll();
void initialize();
// void add(User user); //todo: not user //todo: use generics?
}
......@@ -17,26 +17,14 @@ public class SolutionsRepository implements Repository {
@Inject
public SolutionsRepository(Datastore datastore) {
this.datastore = datastore;
initialize();
}
public List<Solution> getAll() {
return datastore.createQuery(Solution.class).asList();
}
@Override
public void initialize() {
this.clean();
}
public void add(Solution solution) { //todo
datastore.save(solution); //todo: error handling?
//todo: do not add if already exists
}
public void clean() {
datastore.getCollection(Solution.class).drop();
}
}
//todo: generify!
\ No newline at end of file
}
\ No newline at end of file
......@@ -41,7 +41,6 @@ public class TasksRepository implements Repository
this.datastore = datastore;
this.teamsRepository = teamsRepository;
this.solutionsRepository = solutionsRepository;
initialize();
}
public Task getByLevel(int level)
......@@ -73,7 +72,7 @@ public class TasksRepository implements Repository
return datastore.createQuery(Task.class).asList();
}
@Override
//todo: rethink, move to command?
public void initialize()
{
List<TextTaskConfig> cryptoTasks = applicationConfiguration.getTextTasks();
......
......@@ -27,7 +27,6 @@ public class TeamsRepository implements Repository {
this.datastore = datastore;
this.applicationConfiguration = applicationConfiguration;
this.usersRepository = usersRepository;
initialize();
}
public Optional<Team> getTeamByUser(User user) {
......@@ -49,7 +48,7 @@ public class TeamsRepository implements Repository {
return datastore.createQuery(Team.class).asList();
}
@Override
//todo: move to command
public void initialize() {
this.clean();
applicationConfiguration.getTeams().forEach(team -> {
......
......@@ -53,10 +53,4 @@ public class UsersRepository implements Repository
{
return null;
}
@Override
public void initialize()
{
}
}
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