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

knowledgepixels / nanodash / 22760576088

06 Mar 2026 11:01AM UTC coverage: 15.877% (+0.009%) from 15.868%
22760576088

Pull #379

github

web-flow
Merge 0a1e075b8 into 68d77318d
Pull Request #379: Users can set a profile picture

705 of 5393 branches covered (13.07%)

Branch coverage included in aggregate %.

1741 of 10013 relevant lines covered (17.39%)

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

3
import com.knowledgepixels.nanodash.domain.IndividualAgent;
4
import com.knowledgepixels.nanodash.domain.User;
5
import com.knowledgepixels.nanodash.page.UserPage;
6
import org.apache.wicket.Component;
7
import org.apache.wicket.markup.html.WebMarkupContainer;
8
import org.apache.wicket.markup.html.WebPage;
9
import org.apache.wicket.markup.html.basic.Label;
10
import org.apache.wicket.markup.html.image.ExternalImage;
11
import org.apache.wicket.markup.html.image.Image;
12
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
13
import org.apache.wicket.markup.html.panel.Panel;
14
import org.apache.wicket.model.Model;
15
import org.apache.wicket.request.mapper.parameter.PageParameters;
16
import org.apache.wicket.request.resource.ContextRelativeResourceReference;
17
import org.eclipse.rdf4j.model.IRI;
18
import org.eclipse.rdf4j.model.util.Values;
19
import org.nanopub.Nanopub;
20

21
/**
22
 * A reusable component that represents an item in a list with a link and an optional note.
23
 */
24
public class ItemListElement extends Panel {
25
    /**
26
     * Constructor for ItemListElement.
27
     *
28
     * @param markupId              the Wicket markup ID
29
     * @param pageClass             the class of the page to link to
30
     * @param parameters            the page parameters for the link
31
     * @param linkText              the text to display for the link
32
     * @param note                  an optional note to display alongside the link
33
     * @param sourceNanopublication the source nanopublication
34
     */
35
    public ItemListElement(String markupId, Class<? extends WebPage> pageClass, final PageParameters parameters, String linkText, String note, Nanopub sourceNanopublication) {
36
        super(markupId);
×
37

38
        IRI userIri = getUserIri(pageClass, parameters);
×
39
        IRI profilePicIri = (userIri != null) ? User.getProfilePicture(userIri) : null;
×
40

41
        if (profilePicIri != null) {
×
42
            ExternalImage profilePic = new ExternalImage("user-icon", profilePicIri.stringValue());
×
43
            add(profilePic);
×
44
        } else {
×
45
            Component userIcon;
46
            if (userIri == null) {
×
47
                userIcon = new WebMarkupContainer("user-icon").setVisible(false);
×
48
            } else {
49
                if (IndividualAgent.isSoftware(userIri)) {
×
50
                    userIcon = new Image("user-icon", new ContextRelativeResourceReference("images/bot-icon.svg", false));
×
51
                } else {
52
                    userIcon = new Image("user-icon", new ContextRelativeResourceReference("images/user-icon.svg", false));
×
53
                }
54
            }
55
            add(userIcon);
×
56
        }
57

58
        add(new BookmarkablePageLink<>("link", pageClass, parameters).setBody(Model.of(linkText)));
×
59
        if (note == null) {
×
60
            add(new Label("note").setVisible(false));
×
61
        } else {
62
            add(new Label("note", note));
×
63
        }
64
        if (sourceNanopublication == null) {
×
65
            add(new Label("np").setVisible(false));
×
66
        } else {
67
            add(new SourceNanopub("np", sourceNanopublication.getUri()));
×
68
        }
69
    }
×
70

71
    /**
72
     * Overloaded constructor without note.
73
     *
74
     * @param markupId   the Wicket markup ID
75
     * @param pageClass  the class of the page to link to
76
     * @param parameters the page parameters for the link
77
     * @param linkText   the text to display for the link
78
     */
79
    public ItemListElement(String markupId, Class<? extends WebPage> pageClass, final PageParameters parameters, String linkText) {
80
        this(markupId, pageClass, parameters, linkText, null, null);
×
81
    }
×
82

83
    /**
84
     * Returns the user IRI if this list element links to a user page, otherwise null.
85
     */
86
    private IRI getUserIri(Class<? extends WebPage> pageClass, PageParameters parameters) {
87
        if (pageClass == null || !pageClass.equals(UserPage.class) || parameters == null) {
×
88
            return null;
×
89
        }
90
        String id = parameters.get("id").toString("");
×
91
        if (id.isEmpty()) {
×
92
            return null;
×
93
        }
94
        try {
95
            return Values.iri(id);
×
96
        } catch (IllegalArgumentException e) {
×
97
            return null;
×
98
        }
99
    }
100

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