コード例 #1
0
 @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;
 }
コード例 #2
0
 @Override
 public Answer remove(UserSystem sys) {
   return userSystemDAO.remove(sys);
 }