@Override
 public Answer updateSystemsByUser(User user, List<UserSystem> newGroups) {
   Answer a = new Answer(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));
   AnswerList an = this.readByUser(user.getLogin());
   if (an.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
     List<UserSystem> oldGroups = an.getDataList();
     // delete if don't exist in new
     for (UserSystem old : oldGroups) {
       if (!newGroups.contains(old)) {
         Answer del = userSystemDAO.remove(old);
         if (!del.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
           a = del;
         }
       }
     }
     // insert if don't exist in old
     for (UserSystem group : newGroups) {
       if (!oldGroups.contains(group)) {
         Answer add = userSystemDAO.create(group);
         if (!add.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
           a = add;
         }
       }
     }
   }
   return a;
 }
 @Override
 public Answer remove(UserSystem sys) {
   return userSystemDAO.remove(sys);
 }
 @Override
 public Answer create(UserSystem sys) {
   return userSystemDAO.create(sys);
 }
 @Override
 public AnswerList<UserSystem> readByUser(String login) {
   return userSystemDAO.readByUser(login);
 }
 @Override
 public void deleteUserSystem(UserSystem userSystem) throws CerberusException {
   userSystemDAO.deleteUserSystem(userSystem);
 }
 @Override
 public void insertUserSystem(UserSystem useSystem) throws CerberusException {
   userSystemDAO.insertUserSystem(useSystem);
 }
 @Override
 public List<UserSystem> findUserSystemBySystem(String system) throws CerberusException {
   return userSystemDAO.findUserSystemBySystem(system);
 }
 @Override
 public List<UserSystem> findUserSystemByUser(String login) throws CerberusException {
   return userSystemDAO.findUserSystemByUser(login);
 }
 @Override
 public List<UserSystem> findallUser() throws CerberusException {
   return userSystemDAO.findallUser();
 }
Example #10
0
 @Override
 public UserSystem findUserSystemByKey(String login, String system) throws CerberusException {
   return userSystemDAO.findUserSystemByKey(login, system);
 }