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

knowledgepixels / nanodash / 24334200781

13 Apr 2026 08:45AM UTC coverage: 16.094% (-0.05%) from 16.148%
24334200781

Pull #437

github

web-flow
Merge 91539235a into d46e750d5
Pull Request #437: feat: add filter field to all view types and convert publish page panels to proper views

789 of 6058 branches covered (13.02%)

Branch coverage included in aggregate %.

1977 of 11128 relevant lines covered (17.77%)

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

3
import java.io.Serializable;
4
import java.util.ArrayList;
5
import java.util.Calendar;
6
import java.util.HashMap;
7
import java.util.Map;
8

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.nanopub.extra.services.ApiResponseEntry;
14
import org.nanopub.extra.services.QueryRef;
15

16
import com.knowledgepixels.nanodash.View;
17
import com.knowledgepixels.nanodash.ViewDisplay;
18
import com.knowledgepixels.nanodash.template.TemplateData;
19

20
import jakarta.xml.bind.DatatypeConverter;
21

22
/**
23
 * A list of templates, grouped by topic.
24
 */
25
public class TemplateList extends Panel {
26

27
    /**
28
     * A list of templates, grouped by topic.
29
     *
30
     * @param id the wicket id of this component
31
     */
32
    public TemplateList(String id) {
33
        super(id);
×
34
        setOutputMarkupId(true);
×
35

36
        View popularTemplatesView = View.get("https://w3id.org/np/RAYMZEdmvjIS5QGFASa8L5hygapUlvK3feZBpG6quMYqc/popular-templates");
×
37
        QueryRef ptQueryRef = new QueryRef(popularTemplatesView.getQuery().getQueryId());
×
38
        add(QueryResultListBuilder.create("popular-templates", ptQueryRef, new ViewDisplay(popularTemplatesView)).build());
×
39

40
        View getStartedView = View.get("https://w3id.org/np/RAeFTjDGTQ-bdulJy4tUlWzRlK8EucXFCxqLrb7Qj35SM/suggested-templates-get-started");
×
41
        QueryRef gsQueryRef = new QueryRef(getStartedView.getQuery().getQueryId());
×
42
        add(QueryResultListBuilder.create("getstarted-templates", gsQueryRef, new ViewDisplay(getStartedView)).build());
×
43

44
        ArrayList<ApiResponseEntry> templateList = new ArrayList<>(TemplateData.get().getAssertionTemplates());
×
45
        templateList.sort((t1, t2) -> {
×
46
            Calendar c1 = getTime(t1);
×
47
            Calendar c2 = getTime(t2);
×
48
            if (c1 == null && c2 == null) return 0;
×
49
            if (c1 == null) return 1;
×
50
            if (c2 == null) return -1;
×
51
            return c2.compareTo(c1);
×
52
        });
53

54
        Map<String, Topic> topics = new HashMap<>();
×
55
        for (ApiResponseEntry entry : templateList) {
×
56
            String tag = entry.get("tag");
×
57
            if (tag.isEmpty()) tag = null;
×
58
            if (!topics.containsKey(tag)) {
×
59
                topics.put(tag, new Topic(tag));
×
60
            }
61
            topics.get(tag).templates.add(entry);
×
62

63
        }
×
64
        ArrayList<Topic> topicList = new ArrayList<Topic>(topics.values());
×
65
        topicList.sort((t0, t1) -> {
×
66
            if (t0.tag == null) return 1;
×
67
            if (t1.tag == null) return -1;
×
68
            return t1.templates.size() - t0.templates.size();
×
69
        });
70
        DataView<Topic> topicDataView = new DataView<Topic>("topics", new ListDataProvider<Topic>(topicList)) {
×
71

72
            @Override
73
            protected void populateItem(Item<Topic> item) {
74
                String tag = item.getModelObject().tag;
×
75
                if (tag == null) tag = "Other";
×
76
                item.add(new ItemListPanel<ApiResponseEntry>(
×
77
                        "templates",
78
                        tag,
79
                        item.getModelObject().templates,
×
80
                        (respEntry) -> new TemplateItem("item", respEntry)
×
81
                ));
82
            }
×
83
        };
84
        topicDataView.setOutputMarkupId(true);
×
85
        add(topicDataView);
×
86
    }
×
87

88
    private static Calendar getTime(ApiResponseEntry entry) {
89
        return DatatypeConverter.parseDateTime(entry.get("date"));
×
90
    }
91

92

93
    private static class Topic implements Serializable {
94

95
        String tag;
96
        ArrayList<ApiResponseEntry> templates = new ArrayList<>();
×
97

98
        Topic(String tag) {
×
99
            this.tag = tag;
×
100
        }
×
101

102
    }
103

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