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

knowledgepixels / nanodash / 17380144000

01 Sep 2025 02:12PM UTC coverage: 12.03% (+0.05%) from 11.978%
17380144000

push

github

ashleycaselli
refactor: replace printStackTrace with logger.error for better error handling

330 of 3850 branches covered (8.57%)

Branch coverage included in aggregate %.

958 of 6857 relevant lines covered (13.97%)

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

3
import com.knowledgepixels.nanodash.GrlcQuery;
4
import com.knowledgepixels.nanodash.User;
5
import com.knowledgepixels.nanodash.Utils;
6
import com.knowledgepixels.nanodash.page.QueryPage;
7
import org.apache.wicket.markup.html.basic.Label;
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.eclipse.rdf4j.model.IRI;
15
import org.nanopub.SimpleTimestampPattern;
16
import org.nanopub.extra.security.NanopubSignatureElement;
17
import org.nanopub.extra.security.SignatureUtils;
18
import org.nanopub.extra.services.ApiResponse;
19
import org.nanopub.extra.services.ApiResponseEntry;
20
import org.slf4j.Logger;
21
import org.slf4j.LoggerFactory;
22

23
import java.text.SimpleDateFormat;
24
import java.util.ArrayList;
25
import java.util.Calendar;
26
import java.util.List;
27

28
/**
29
 * A component that displays a list of queries.
30
 * Each query is linked to its corresponding QueryPage.
31
 */
32
public class QueryList extends Panel {
33

34
    private static final long serialVersionUID = 1L;
35
    private static final Logger logger = LoggerFactory.getLogger(QueryList.class);
×
36

37
    /**
38
     * Constructor for QueryList.
39
     *
40
     * @param id   the component ID
41
     * @param resp the API response containing query data
42
     */
43
    public QueryList(String id, ApiResponse resp) {
44
        super(id);
×
45
        List<GrlcQuery> queries = new ArrayList<>();
×
46
        for (ApiResponseEntry e : resp.getData()) {
×
47
            try {
48
                queries.add(GrlcQuery.get(e.get("np")));
×
49
            } catch (Exception ex) {
×
50
                logger.error("Error processing query nanopub: {}", ex.getMessage());
×
51
            }
×
52
        }
×
53

54
        add(new DataView<GrlcQuery>("querylist", new ListDataProvider<GrlcQuery>(queries)) {
×
55

56
            private static final long serialVersionUID = 1L;
57

58
            @Override
59
            protected void populateItem(Item<GrlcQuery> item) {
60
                GrlcQuery q = item.getModelObject();
×
61
                PageParameters params = new PageParameters();
×
62
                params.add("id", q.getQueryId());
×
63
                BookmarkablePageLink<Void> l = new BookmarkablePageLink<Void>("querylink", QueryPage.class, params);
×
64
                l.add(new Label("linktext", q.getLabel()));
×
65
                item.add(l);
×
66

67
                String userString = "somebody";
×
68
                try {
69
                    NanopubSignatureElement se = SignatureUtils.getSignatureElement(q.getNanopub());
×
70
                    if (se != null) {
×
71
                        IRI signer = (se.getSigners().isEmpty() ? null : se.getSigners().iterator().next());
×
72
                        String pubkeyhash = Utils.createSha256HexHash(se.getPublicKeyString());
×
73
                        userString = User.getShortDisplayNameForPubkeyhash(signer, pubkeyhash);
×
74
                    }
75
                } catch (Exception ex) {
×
76
                    logger.error("Error retrieving signature info: {}", ex.getMessage());
×
77
                }
×
78
                item.add(new Label("user", userString));
×
79
                String timeString = "unknown date";
×
80
                Calendar c = SimpleTimestampPattern.getCreationTime(q.getNanopub());
×
81
                if (c != null) {
×
82
                    timeString = (new SimpleDateFormat("yyyy-MM-dd")).format(c.getTime());
×
83
                }
84
                item.add(new Label("timestamp", timeString));
×
85
            }
×
86

87
        });
88
    }
×
89

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