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

knowledgepixels / nanodash / 17837235071

18 Sep 2025 05:58PM UTC coverage: 13.87%. Remained the same
17837235071

push

github

tkuhn
chore: Remove serialVersionUIDs

443 of 4022 branches covered (11.01%)

Branch coverage included in aggregate %.

1133 of 7341 relevant lines covered (15.43%)

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

38
            @Override
39
            protected void populateItem(Item<ApiResponseEntry> item) {
40
                // TODO Improve label determination and move this code to a more general place?
41
                String thingId = item.getModelObject().get(thingField);
×
42
                String thingLabel = item.getModelObject().get(thingField + "Label");
×
43
                String npLabel = item.getModelObject().get("npLabel");
×
44
                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()) {
×
45
                    thingLabel = Utils.getShortNameFromURI(thingId) + " in '" + npLabel.replaceFirst(" - [\\s\\S]*$", "") + "'";
×
46
                }
47
                item.add(new NanodashLink("thing-link", thingId, null, null, false, thingLabel));
×
48
                String npId = item.getModelObject().get("np");
×
49
                item.add(new BookmarkablePageLink<Void>("nanopub-link", ExplorePage.class, new PageParameters().add("id", npId)));
×
50
            }
×
51

52
        };
53
        dataView.setItemsPerPage(10);
×
54
        dataView.setOutputMarkupId(true);
×
55
        r.add(dataView);
×
56

57
        WebMarkupContainer navigation = new WebMarkupContainer("navigation");
×
58
        navigation.add(new NavigatorLabel("navigatorLabel", dataView));
×
59
        AjaxPagingNavigator pagingNavigator = new AjaxPagingNavigator("navigator", dataView);
×
60
        navigation.setVisible(dataView.getPageCount() > 1);
×
61
        navigation.add(pagingNavigator);
×
62
        r.add(navigation);
×
63

64
        return r;
×
65
    }
66

67
    private ThingResults(String id) {
68
        super(id);
×
69
        setOutputMarkupId(true);
×
70
    }
×
71

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