• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanodash / 17592217047

09 Sep 2025 06:31PM UTC coverage: 13.801% (-0.02%) from 13.819%
17592217047

push

github

tkuhn
Use ItemListPanel for all user lists on UserListPage

415 of 3902 branches covered (10.64%)

Branch coverage included in aggregate %.

1102 of 7090 relevant lines covered (15.54%)

0.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/nanodash/component/UserList.java
1
package com.knowledgepixels.nanodash.component;
2

3
import java.util.ArrayList;
4
import java.util.List;
5

6
import org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator;
7
import org.apache.wicket.extensions.markup.html.repeater.data.table.NavigatorLabel;
8
import org.apache.wicket.markup.html.WebMarkupContainer;
9
import org.apache.wicket.markup.html.basic.Label;
10
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
11
import org.apache.wicket.markup.html.panel.Panel;
12
import org.apache.wicket.markup.repeater.Item;
13
import org.apache.wicket.markup.repeater.data.DataView;
14
import org.apache.wicket.markup.repeater.data.ListDataProvider;
15
import org.apache.wicket.request.mapper.parameter.PageParameters;
16
import org.eclipse.rdf4j.model.IRI;
17
import org.nanopub.extra.services.ApiResponse;
18
import org.nanopub.extra.services.ApiResponseEntry;
19

20
import com.knowledgepixels.nanodash.User;
21
import com.knowledgepixels.nanodash.Utils;
22
import com.knowledgepixels.nanodash.page.UserPage;
23

24
/**
25
 * A panel that displays a list of users with links to their user pages.
26
 * Optionally, it can also display notes associated with each user.
27
 */
28
public class UserList extends Panel {
29

30
    private static final long serialVersionUID = 1L;
31

32
    /**
33
     * Constructor for UserList with a list of user IRI objects.
34
     *
35
     * @param id    the component id
36
     * @param users a list of user IRI objects
37
     */
38
    public UserList(String id, List<IRI> users, boolean sorted) {
39
        super(id);
×
40
        setOutputMarkupId(true);
×
41
        init(users, sorted);
×
42
    }
×
43

44
    /**
45
     * Constructor for UserList that initializes from an ApiResponse.
46
     *
47
     * @param id        the component id
48
     * @param resp      the ApiResponse containing user data
49
     * @param userIdKey the key in the ApiResponse entries that contains the user IRI
50
     */
51
    public UserList(String id, ApiResponse resp, String userIdKey, boolean sorted) {
52
        super(id);
×
53
        setOutputMarkupId(true);
×
54
        List<IRI> users = new ArrayList<>();
×
55
        for (ApiResponseEntry e : resp.getData()) {
×
56
            users.add(Utils.vf.createIRI(e.get(userIdKey)));
×
57
        }
×
58
        init(users, sorted);
×
59
    }
×
60

61
    private void init(List<IRI> users, boolean sorted) {
62
        if (sorted) {
×
63
            users.sort(User.getUserData().userComparator);
×
64
        }
65
        DataView<IRI> dataView = new DataView<>("userlist", new ListDataProvider<IRI>(users)) {
×
66

67
            private static final long serialVersionUID = 1L;
68

69
            @Override
70
            protected void populateItem(Item<IRI> item) {
71
                IRI userIri = item.getModelObject();
×
72
                PageParameters params = new PageParameters();
×
73
                params.add("id", userIri);
×
74
                BookmarkablePageLink<Void> l = new BookmarkablePageLink<Void>("userlink", UserPage.class, params);
×
75
                l.add(new Label("linktext", User.getDisplayName(userIri)));
×
76
                item.add(l);
×
77
            }
×
78

79
        };
80
        dataView.setItemsPerPage(10);
×
81
        dataView.setOutputMarkupId(true);
×
82
        add(dataView);
×
83

84
        WebMarkupContainer navigation = new WebMarkupContainer("navigation");
×
85
        navigation.add(new NavigatorLabel("navigatorLabel", dataView));
×
86
        AjaxPagingNavigator pagingNavigator = new AjaxPagingNavigator("navigator", dataView);
×
87
        navigation.setVisible(dataView.getPageCount() > 1);
×
88
        navigation.add(pagingNavigator);
×
89
        add(navigation);
×
90
    }
×
91

92
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc