コード例 #1
0
 /** {@inheritDoc} */
 @Override
 @SuppressWarnings("unchecked")
 public Collection<Action> findAllActions(User user) {
   Collection<UserPreference> userPrefs =
       confSrv.findByType(UserPreference.class, user.getUsername());
   PreferenceKey pKey =
       new PreferenceKey(PropertyScope.USER, user.getUsername(), "lastSearchActions");
   for (UserPreference pref : userPrefs) {
     if (pref.getPrefKey().equals(pKey)) {
       return (Collection<Action>) pref.getBinValue();
     }
   }
   return new HashSet<Action>(0);
 }
コード例 #2
0
 /** {@inheritDoc} */
 @SuppressWarnings("unchecked")
 @Override
 public Collection<Action> save(User user, Collection<Action> actions) {
   Collection<UserPreference> userPrefs =
       confSrv.findByType(UserPreference.class, user.getUsername());
   PreferenceKey pKey =
       new PreferenceKey(PropertyScope.USER, user.getUsername(), "lastSearchActions");
   UserPreference result = null;
   for (UserPreference pref : userPrefs) {
     if (pref.getPrefKey().equals(pKey)) {
       result = pref;
       break;
     }
   }
   if (result == null) {
     result = new UserPreference(user.getUsername(), "lastSearchActions");
     result.setDescription("All UI actions the User has previously chosen");
     Set<Action> all = new HashSet<Action>();
     all.addAll(actions);
     result.setBinValue((Serializable) all);
   } else {
     result.setBinValue((Serializable) actions);
   }
   result = confSrv.save(result);
   return (Collection<Action>) result.getBinValue();
 }