use of cz.metacentrum.perun.core.api.Paginated in project perun by CESNET.
the class MembersManagerBlImpl method getMembersPage.
@Override
public Paginated<RichMember> getMembersPage(PerunSession sess, Vo vo, MembersPageQuery query, List<String> attrNames) {
Paginated<Member> paginatedMembers = membersManagerImpl.getMembersPage(sess, vo, query);
List<RichMember> richMembers = convertMembersToRichMembers(sess, paginatedMembers.getData());
List<AttributeDefinition> attrDefs = new ArrayList<>();
for (String attrsName : attrNames) {
try {
attrDefs.add(getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, attrsName));
} catch (AttributeNotExistsException e) {
// pass
}
}
if (query.getGroupId() == null) {
richMembers = convertMembersToRichMembersWithAttributes(sess, richMembers, attrDefs);
} else {
try {
richMembers = convertMembersToRichMembersWithAttributes(sess, perunBl.getGroupsManagerBl().getGroupById(sess, query.getGroupId()), richMembers, attrDefs);
} catch (GroupNotExistsException | MemberGroupMismatchException e) {
throw new InternalErrorException(e);
}
}
return new Paginated<>(richMembers, paginatedMembers.getOffset(), paginatedMembers.getPageSize(), paginatedMembers.getTotalCount());
}
use of cz.metacentrum.perun.core.api.Paginated in project perun by CESNET.
the class AuditMessagesManagerEntryIntegrationTest method getMessagesPage_allEntries.
@Test
public void getMessagesPage_allEntries() throws Exception {
System.out.println(CLASS_NAME + "getMessagesPage_allEntries");
for (int i = 0; i < 5; i++) {
perun.getAuditer().logWithoutTransaction(sess, new StringMessageEvent("Test cislo: " + i));
}
MessagesPageQuery query = new MessagesPageQuery(5, 0, SortingOrder.DESCENDING);
Paginated<AuditMessage> messages = perun.getAuditMessagesManager().getMessagesPage(sess, query);
assertThat(messages.getData().size()).isEqualTo(5);
assertThat(messages.getData().stream().map(a -> a.getEvent().getMessage()).collect(Collectors.toList())).isEqualTo(List.of("Test cislo: 4", "Test cislo: 3", "Test cislo: 2", "Test cislo: 1", "Test cislo: 0"));
}
Aggregations