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

knowledgepixels / nanodash / 17549674654

08 Sep 2025 11:45AM UTC coverage: 12.054% (+0.2%) from 11.88%
17549674654

push

github

tkuhn
Add pagination to more views

335 of 3858 branches covered (8.68%)

Branch coverage included in aggregate %.

970 of 6968 relevant lines covered (13.92%)

0.61 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/ThingResults.java
1
package com.knowledgepixels.nanodash.component;
2

3
import java.util.List;
4

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

17
import com.knowledgepixels.nanodash.Utils;
18
import com.knowledgepixels.nanodash.page.ExplorePage;
19

20
/**
21
 * A panel that displays a list of things (e.g., nanopublications, entities) based on an API response.
22
 */
23
public class ThingResults extends Panel {
24

25
    private static final long serialVersionUID = 1L;
26

27
    /**
28
     * Creates a new ThingResults panel.
29
     *
30
     * @param id          the Wicket component ID
31
     * @param thingField  the field in the API response that contains the thing ID
32
     * @param apiResponse the API response containing the data
33
     * @return a ThingResults instance populated with the data from the API response
34
     */
35
    public static ThingResults fromApiResponse(String id, String thingField, ApiResponse apiResponse) {
36
        List<ApiResponseEntry> list = apiResponse.getData();
×
37
        ThingResults r = new ThingResults(id);
×
38
        DataView<ApiResponseEntry> dataView = new DataView<>("things", new ListDataProvider<ApiResponseEntry>(list)) {
×
39

40
            private static final long serialVersionUID = 1L;
41

42
            @Override
43
            protected void populateItem(Item<ApiResponseEntry> item) {
44
                // TODO Improve label determination and move this code to a more general place?
45
                String thingId = item.getModelObject().get(thingField);
×
46
                String thingLabel = item.getModelObject().get(thingField + "Label");
×
47
                String npLabel = item.getModelObject().get("npLabel");
×
48
                if (thingId.matches(".*[^A-Za-z0-9-_]RA[A-Za-z0-9-_]{43}[^A-Za-z0-9-_].*") && (thingLabel == null || thingLabel.isBlank()) && npLabel != null && !npLabel.isBlank()) {
×
49
                    thingLabel = Utils.getShortNameFromURI(thingId) + " in '" + npLabel.replaceFirst(" - [\\s\\S]*$", "") + "'";
×
50
                }
51
                item.add(new NanodashLink("thing-link", thingId, null, null, false, thingLabel));
×
52
                String npId = item.getModelObject().get("np");
×
53
                item.add(new BookmarkablePageLink<Void>("nanopub-link", ExplorePage.class, new PageParameters().add("id", npId)));
×
54
            }
×
55

56
        };
57
        dataView.setItemsPerPage(10);
×
58
        dataView.setOutputMarkupId(true);
×
59
        r.add(dataView);
×
60

61
        WebMarkupContainer navigation = new WebMarkupContainer("navigation");
×
62
        navigation.add(new NavigatorLabel("navigatorLabel", dataView));
×
63
        AjaxPagingNavigator pagingNavigator = new AjaxPagingNavigator("navigator", dataView);
×
64
        navigation.setVisible(dataView.getPageCount() > 1);
×
65
        navigation.add(pagingNavigator);
×
66
        r.add(navigation);
×
67

68
        return r;
×
69
    }
70

71
    private ThingResults(String id) {
72
        super(id);
×
73
        setOutputMarkupId(true);
×
74
    }
×
75

76
}
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