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

3
import com.knowledgepixels.nanodash.QueryRef;
4
import com.knowledgepixels.nanodash.template.Template;
5
import com.knowledgepixels.nanodash.template.TemplateData;
6
import jakarta.xml.bind.DatatypeConverter;
7
import org.apache.wicket.markup.html.panel.Panel;
8
import org.apache.wicket.markup.repeater.Item;
9
import org.apache.wicket.markup.repeater.data.DataView;
10
import org.apache.wicket.markup.repeater.data.ListDataProvider;
11
import org.nanopub.extra.services.ApiResponseEntry;
12

13
import java.io.Serializable;
14
import java.util.ArrayList;
15
import java.util.Calendar;
16
import java.util.HashMap;
17
import java.util.Map;
18

19
/**
20
 * A list of templates, grouped by topic.
21
 */
22
public class TemplateList extends Panel {
23

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

33
        add(new ItemListPanel<Template>(
×
34
                "popular-templates",
35
                "Popular Templates",
36
                new QueryRef("get-most-used-templates-last30d"),
37
                TemplateData::getTemplateList,
38
                (template) -> new TemplateItem("item", template)
×
39
        ));
40

41
        add(new ItemListPanel<Template>(
×
42
                "getstarted-templates",
43
                "Suggested Templates to Get Started",
44
                new QueryRef("get-suggested-templates-to-get-started"),
45
                TemplateData::getTemplateList,
46
                (template) -> new TemplateItem("item", template)
×
47
        ));
48

49
        ArrayList<ApiResponseEntry> templateList = new ArrayList<>(TemplateData.get().getAssertionTemplates());
×
50
        templateList.sort((t1, t2) -> {
×
51
            Calendar c1 = getTime(t1);
×
52
            Calendar c2 = getTime(t2);
×
53
            if (c1 == null && c2 == null) return 0;
×
54
            if (c1 == null) return 1;
×
55
            if (c2 == null) return -1;
×
56
            return c2.compareTo(c1);
×
57
        });
58

59
        Map<String, Topic> topics = new HashMap<>();
×
60
        for (ApiResponseEntry entry : templateList) {
×
61
            String tag = entry.get("tag");
×
62
            if (tag.isEmpty()) tag = null;
×
63
            if (!topics.containsKey(tag)) {
×
64
                topics.put(tag, new Topic(tag));
×
65
            }
66
            topics.get(tag).templates.add(entry);
×
67

68
        }
×
69
        ArrayList<Topic> topicList = new ArrayList<Topic>(topics.values());
×
70
        topicList.sort((t0, t1) -> {
×
71
            if (t0.tag == null) return 1;
×
72
            if (t1.tag == null) return -1;
×
73
            return t1.templates.size() - t0.templates.size();
×
74
        });
75
        DataView<Topic> topicDataView = new DataView<Topic>("topics", new ListDataProvider<Topic>(topicList)) {
×
76

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

93
    private static Calendar getTime(ApiResponseEntry entry) {
94
        return DatatypeConverter.parseDateTime(entry.get("date"));
×
95
    }
96

97

98
    private static class Topic implements Serializable {
99

100
        String tag;
101
        ArrayList<ApiResponseEntry> templates = new ArrayList<>();
×
102

103
        Topic(String tag) {
×
104
            this.tag = tag;
×
105
        }
×
106

107
    }
108

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