/** As per enhancement added new group b2bviewergroup */
 @Override
 public void populateUserRoles(final SearchPageData<CustomerData> b2bCustomer) {
   List<String> roles = null;
   for (int i = 0; i < b2bCustomer.getResults().size(); i++) {
     roles = new ArrayList<String>();
     final EnergizerB2BCustomerModel customerModel =
         userService.getUserForUID(
             b2bCustomer.getResults().get(i).getUid(), EnergizerB2BCustomerModel.class);
     final Set<PrincipalGroupModel> roleModels =
         new HashSet<PrincipalGroupModel>(customerModel.getGroups());
     for (final PrincipalGroupModel role : roleModels) {
       // only display allowed usergroups
       if (energizerGroupsLookUpStrategy.getUserGroups().contains(role.getUid())) {
         roles.add(role.getUid());
       }
     }
     b2bCustomer.getResults().get(i).setRoles(roles);
   }
 }
 /** As per enhancement added new group b2bviewergroup */
 public void populateRolesByCustomer(final String uuid, final CustomerData target) {
   final List<String> roles = new ArrayList<String>();
   final EnergizerB2BCustomerModel model =
       userService.getUserForUID(uuid, EnergizerB2BCustomerModel.class);
   final Set<PrincipalGroupModel> roleModels = new HashSet<PrincipalGroupModel>(model.getGroups());
   CollectionUtils.filter(
       roleModels,
       PredicateUtils.notPredicate(PredicateUtils.instanceofPredicate(B2BUnitModel.class)));
   CollectionUtils.filter(
       roleModels,
       PredicateUtils.notPredicate(PredicateUtils.instanceofPredicate(B2BUserGroupModel.class)));
   for (final PrincipalGroupModel role : roleModels) {
     // only display allowed usergroups
     if (energizerGroupsLookUpStrategy.getUserGroups().contains(role.getUid())) {
       roles.add(role.getUid());
     }
   }
   target.setRoles(roles);
 }
Esempio n. 3
0
 public String getPartnerID(final UserModel user) {
   for (final PrincipalGroupModel group : user.getGroups()) {
     if (group.getItemtype().contains(TN_CONTRACTOR)) {
       for (final PrincipalGroupModel innerGroup : group.getGroups()) {
         if (innerGroup.getItemtype().contains(TN_PARTNER)) {
           return innerGroup.getUid();
         }
       }
     } else {
       if (group.getItemtype().contains(TN_PARTNER)) {
         return group.getUid();
       }
     }
   }
   return "";
 }