Commit cde37948 authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

remove initalizing in repositories

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