code: public static PrincipalUserDto transformToDto(PrincipalUser user) {
          if (user == null) {
              throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
          }
  
          PrincipalUserDto result = createDtoObject(PrincipalUserDto.class, user);
  
          for (Dashboard dashboard : user.getOwnedDashboards()) {
              result.addOwnedDashboardId(dashboard.getId());
          }
          return result;
      }
docs: Converts a user entity to DTO.
  
  @param   user  The entity to convert.
  
  @return  The DTO.
  
  @throws  WebApplicationException  If an error occurs.