DmitryZakharov / homeBudgetWeb

1 stars 0 forks source link

DAO in controllers $2 = 2 #36

Closed DmitryZakharov closed 11 years ago

DmitryZakharov commented 11 years ago

All the controllers must be cleaned up. They must not contain any dao injection. Also, any related to the service tasks must be moved from controllers to the services: Account Controller :

  if (account != null) {
     final UserDetails owner = userRepositoryDaoImpl.findByUserUsername(getSessionUser().getUsername());
     account.setOwner(owner);
     accountRepositoryDaoImpl.save(account);

the owner must be set in the service.

Controllers must not now how to create and initialize objects, they must ask services to do so:

  UserDetails userDetails = new UserDetails();
  UserRole aUserRole = new UserRole();
  aUserRole.setUserRole(UserRole.Role.USER_ROLE);
  model.addAttribute(userDetails);
  return "registration";

new User must be created in the appropriate controller.

Clean all the related bugs in the controllers.