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

knowledgepixels / nanodash / 18155160356

01 Oct 2025 07:42AM UTC coverage: 13.788% (-0.03%) from 13.817%
18155160356

push

github

ashleycaselli
docs: add missing or update Javadoc annotations

445 of 4084 branches covered (10.9%)

Branch coverage included in aggregate %.

1155 of 7520 relevant lines covered (15.36%)

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/page/UserPage.java
1
package com.knowledgepixels.nanodash.page;
2

3
import com.google.common.collect.ArrayListMultimap;
4
import com.google.common.collect.Multimap;
5
import com.knowledgepixels.nanodash.*;
6
import com.knowledgepixels.nanodash.component.ItemListElement;
7
import com.knowledgepixels.nanodash.component.ItemListPanel;
8
import com.knowledgepixels.nanodash.component.NanopubResults;
9
import com.knowledgepixels.nanodash.component.TitleBar;
10
import org.apache.wicket.Component;
11
import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
12
import org.apache.wicket.markup.html.basic.Label;
13
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
14
import org.apache.wicket.markup.html.link.ExternalLink;
15
import org.apache.wicket.request.flow.RedirectToUrlException;
16
import org.apache.wicket.request.mapper.parameter.PageParameters;
17
import org.eclipse.rdf4j.model.IRI;
18
import org.nanopub.extra.services.ApiResponse;
19
import org.nanopub.extra.services.QueryRef;
20
import org.slf4j.Logger;
21
import org.slf4j.LoggerFactory;
22

23
import java.util.ArrayList;
24
import java.util.List;
25

26
/**
27
 * Page that shows a user profile, including their nanopubs and stats.
28
 */
29
public class UserPage extends NanodashPage {
30

31
    private static final Logger logger = LoggerFactory.getLogger(UserPage.class);
×
32

33
    /**
34
     * The mount path for this page.
35
     */
36
    public static final String MOUNT_PATH = "/user";
37

38
    /**
39
     * {@inheritDoc}
40
     */
41
    @Override
42
    public String getMountPath() {
43
        return MOUNT_PATH;
×
44
    }
45

46
    private IRI userIri;
47
    private String pubkeyHashes = "";
×
48

49
    /**
50
     * Constructor for UserPage.
51
     *
52
     * @param parameters Page parameters, must include "id" with the user IRI.
53
     */
54
    public UserPage(final PageParameters parameters) {
55
        super(parameters);
×
56

57
        if (parameters.get("id") == null) throw new RedirectToUrlException(ProfilePage.MOUNT_PATH);
×
58
        final String userIriString = parameters.get("id").toString();
×
59
        userIri = Utils.vf.createIRI(userIriString);
×
60
        //NanodashSession session = NanodashSession.get();
61

62
        for (String pk : User.getPubkeyhashes(userIri, null)) {
×
63
            pubkeyHashes += " " + pk;
×
64
        }
×
65
        if (!pubkeyHashes.isEmpty()) pubkeyHashes = pubkeyHashes.substring(1);
×
66

67
        String pageType = "users";
×
68
        add(new TitleBar("titlebar", this, pageType));
×
69

70
        final String displayName = User.getShortDisplayName(userIri);
×
71
        add(new Label("pagetitle", displayName + " (user) | nanodash"));
×
72
        add(new Label("username", displayName));
×
73

74
        add(new ExternalLink("fullid", userIriString, userIriString));
×
75

76
        add(new BookmarkablePageLink<Void>("showprofile", ProfilePage.class).setVisible(userIri.equals(NanodashSession.get().getUserIri())));
×
77

78
//                final Map<String,String> statsParams = new HashMap<>();
79
//                final String statsQueryName;
80
//                if (pubkeyHashes.isEmpty()) {
81
//                        statsQueryName = "get-user-stats-from-userid";
82
//                        statsParams.put("userid", userIriString);
83
//                } else {
84
//                        statsQueryName = "get-user-stats-from-pubkeys";
85
//                        statsParams.put("userid", userIriString);
86
//                        statsParams.put("pubkeyhashes", pubkeyHashes);
87
//                } 
88
//                Map<String,String> statsMap = ApiCache.retrieveMap(statsQueryName, statsParams);
89
//                if (statsMap != null) {
90
//                        add(new StatsPanel("stats", userIriString, pubkeyHashes, statsMap));
91
//                } else {
92
//                        add(new AjaxLazyLoadPanel<Component>("stats") {
93
//        
94
//                                @Override
95
//                                public Component getLazyLoadComponent(String markupId) {
96
//                                        Map<String,String> m = null;
97
//                                        while (true) {
98
//                                                try {
99
//                                                        Thread.sleep(500);
100
//                                                } catch (InterruptedException ex) {
101
//                                                        logger.error();
102
//                                                }
103
//                                                if (!ApiCache.isRunning(statsQueryName, statsParams)) {
104
//                                                        m = ApiCache.retrieveMap(statsQueryName, statsParams);
105
//                                                        if (m != null) break;
106
//                                                }
107
//                                        }
108
//                                        return new StatsPanel(markupId, userIriString, pubkeyHashes, m);
109
//                                }
110
//
111
//                                @Override
112
//                                protected void onContentLoaded(Component content, Optional<AjaxRequestTarget> target) {
113
//                                        super.onContentLoaded(content, target);
114
//                                        if (target.get() != null) target.get().appendJavaScript("updateElements();");
115
//                                }
116
//        
117
//                        });
118
//                }
119

120
        add(new BookmarkablePageLink<Void>("showchannel", ListPage.class, new PageParameters().add("userid", userIriString)));
×
121

122
        final Multimap<String, String> params = ArrayListMultimap.create();
×
123
        final String queryName;
124
        if (pubkeyHashes.isEmpty()) {
×
125
            queryName = "get-latest-nanopubs-from-userid";
×
126
            params.put("userid", userIri.stringValue());
×
127
        } else {
128
            queryName = "get-latest-nanopubs-from-pubkeys";
×
129
            params.put("pubkeyhashes", pubkeyHashes);
×
130
            params.put("userid", userIri.stringValue());
×
131
        }
132
        final QueryRef queryRef = new QueryRef(queryName, params);
×
133
        ApiResponse response = ApiCache.retrieveResponse(queryRef);
×
134
        if (response != null) {
×
135
            add(makeNanopubResultComponent("latestnanopubs", response));
×
136
        } else {
137
            add(new AjaxLazyLoadPanel<Component>("latestnanopubs") {
×
138

139
                @Override
140
                public Component getLazyLoadComponent(String markupId) {
141
                    ApiResponse r = null;
×
142
                    while (true) {
143
                        try {
144
                            Thread.sleep(500);
×
145
                        } catch (InterruptedException ex) {
×
146
                            logger.error("Thread interrupted while waiting for API response", ex);
×
147
                        }
×
148
                        if (!ApiCache.isRunning(queryRef)) {
×
149
                            r = ApiCache.retrieveResponse(queryRef);
×
150
                            if (r != null) break;
×
151
                        }
152
                    }
153
                    return makeNanopubResultComponent(markupId, r);
×
154
                }
155

156
//                                @Override
157
//                                protected void onContentLoaded(Component content, Optional<AjaxRequestTarget> target) {
158
//                                        super.onContentLoaded(content, target);
159
//                                        if (target.get() != null) target.get().appendJavaScript("updateElements();");
160
//                                }
161

162
            });
163
        }
164

165
        add(new ItemListPanel<Space>(
×
166
                "spaces",
167
                "Spaces",
168
                () -> Space.isLoaded(),
×
169
                () -> {
170
                    List<Space> spaces = new ArrayList<>();
×
171
                    for (Space space : Space.getSpaceList()) {
×
172
                        if (space.isMember(userIri)) spaces.add(space);
×
173
                    }
×
174
                    return spaces;
×
175
                },
176
                (s) -> new ItemListElement("item", SpacePage.class, new PageParameters().add("id", s.getId()), s.getLabel(), "(" + s.getTypeLabel() + ")")
×
177
        ));
178
    }
×
179

180
    private static Component makeNanopubResultComponent(String markupId, ApiResponse response) {
181
        if (response.getData().isEmpty()) {
×
182
            return new Label(markupId, "(none)");
×
183
        } else {
184
            return NanopubResults.fromApiResponse(markupId, response);
×
185
        }
186
    }
187

188
    /**
189
     * <p>hasAutoRefreshEnabled.</p>
190
     *
191
     * @return a boolean
192
     */
193
    protected boolean hasAutoRefreshEnabled() {
194
        return true;
×
195
    }
196

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