Ejemplo n.º 1
0
 private Collection<GroupData> fetchGroupDataForUser(
     final User user, final boolean restrictToSuscribed) {
   final String ifConnectedColumns =
       "max(ifnull(USER_ID=:userId, false))>0, sum(ifnull(USER_ID=:userId AND LAST_VISIT<PUBLIC_MESSAGES.`DATE`, false))";
   final Query query =
       entityManager.createNativeQuery(
           "select GROUPS.ID, name, count(DISTINCT GROUP_USER.USER_ID), "
               + (user != null ? ifConnectedColumns : " 0,0")
               + " from GROUPS left join  GROUP_USER on GROUP_ID=ID "
               + " left join PUBLIC_MESSAGES on PUBLIC_MESSAGES.GROUP_ID=GROUP_USER.GROUP_ID "
               + (restrictToSuscribed ? " where GROUP_USER.USER_ID=:userId" : "")
               + " group by GROUPS.ID order by CREATION_DATE");
   if (user != null) query.setParameter("userId", user.getId());
   final List<Object[]> list = query.getResultList();
   final Collection<GroupData> result = new ArrayList<GroupData>(list.size());
   for (final Object[] o : list)
     result.add(
         new GroupData(
             ((Number) o[0]).longValue(),
             UserStringImpl.valueOf(String.valueOf(o[1])),
             ((Number) o[2]).longValue(),
             ((Number) o[3]).intValue() != 0,
             ((Number) o[4]).intValue()));
   return result;
 }
Ejemplo n.º 2
0
 @Override
 public Collection<? extends GrantedAuthority> getAuthorities() {
   Collection<GrantedAuthority> grantedAuthorities = new HashSet<GrantedAuthority>();
   for (UserRole role : this.getUserRoles()) {
     grantedAuthorities.add(new SimpleGrantedAuthority(role.getRoleName()));
   }
   return grantedAuthorities;
 }
Ejemplo n.º 3
0
 public void testValidValuesInList() throws Exception {
   int quantity = getListRowCount();
   assertTrue("For this test is needed at least one created delivery", quantity > 0);
   Collection values = new ArrayList();
   values.add("Lokal");
   values.add("Nachional");
   values.add("Internachional");
   boolean thereIsOne = false;
   for (int i = 0; i < quantity; i++) {
     String value = getValueInList(i, "distance");
     if (Is.emptyString(value)) continue;
     if (values.contains(value)) {
       thereIsOne = true;
       continue;
     }
     fail("Only the next values are valid: " + values);
   }
   assertTrue(
       "For this test is need at least one delivery with value in 'distance' property",
       thereIsOne);
 }
Ejemplo n.º 4
0
  @Transient
  @JsonIgnore
  public Collection<? extends GrantedAuthority> getAuthorities() {

    if (authorities.isEmpty()) {

      for (Role role : roles) {

        String[] rights = role.getRights().split(";");

        for (String right : rights) {

          if (NullEmptyChecker.isNotNullOrEmpty(right)) {
            authorities.add(new SimpleGrantedAuthority("ROLE_" + right));
          }
        }
      }
    }
    return authorities;
  }
Ejemplo n.º 5
0
 public void addAssigmentTask(TaskAssigment taskAssigment) {
   assignTasks.add(taskAssigment);
 }