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

knowledgepixels / nanodash / 18531946059

15 Oct 2025 02:15PM UTC coverage: 13.615% (-0.9%) from 14.516%
18531946059

push

github

tkuhn
fix: Show pinned resources only once

452 of 4192 branches covered (10.78%)

Branch coverage included in aggregate %.

1171 of 7729 relevant lines covered (15.15%)

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

3
import java.io.Serializable;
4
import java.util.ArrayList;
5
import java.util.Collections;
6
import java.util.Comparator;
7
import java.util.List;
8

9
import org.apache.commons.lang3.tuple.Pair;
10
import org.apache.wicket.markup.html.WebMarkupContainer;
11
import org.apache.wicket.markup.html.panel.Panel;
12
import org.apache.wicket.markup.repeater.Item;
13
import org.apache.wicket.markup.repeater.data.DataView;
14
import org.apache.wicket.markup.repeater.data.ListDataProvider;
15
import org.apache.wicket.request.mapper.parameter.PageParameters;
16

17
import com.knowledgepixels.nanodash.GrlcQuery;
18
import com.knowledgepixels.nanodash.Space;
19
import com.knowledgepixels.nanodash.template.Template;
20

21
public class PinGroupList extends Panel {
22

23
    public PinGroupList(String markupId, Space space) {
24
        super(markupId);
×
25

26
        final PageParameters tParams = new PageParameters();
×
27
        tParams.add("param_space", space.getId());
×
28
        if (space.getDefaultProvenance() != null) {
×
29
            tParams.add("prtemplate", space.getDefaultProvenance().stringValue());
×
30
        }
31

32
        final PageParameters qParams = new PageParameters();
×
33
        qParams.add("queryparam_space", space.getId());
×
34

35
        List<Pair<String, List<Serializable>>> pinnedResourcesList = new ArrayList<>();
×
36
        List<String> pinGroupTags = new ArrayList<>(space.getPinGroupTags());
×
37
        Collections.sort(pinGroupTags);
×
38
        List<Serializable> pinnedResources = new ArrayList<>(space.getPinnedResources());
×
39
        for (String tag : pinGroupTags) {
×
40
            for (Object pinned : space.getPinnedResourceMap().get(tag)) {
×
41
                if (pinnedResources.contains(pinned)) pinnedResources.remove(pinned);
×
42
            }
×
43
            List<Serializable> list = new ArrayList<>(space.getPinnedResourceMap().get(tag));
×
44
            Collections.sort(list, new Comparator<Serializable>() {
×
45
                @Override
46
                public int compare(Serializable s0, Serializable s1) {
47
                    return getName(s0).compareTo(getName(s1));
×
48
                }
49
            });
50
            pinnedResourcesList.add(Pair.of(tag, list));
×
51
        }
×
52
        if (!pinnedResources.isEmpty()) {
×
53
            String l = pinnedResourcesList.isEmpty() ? "Resources" : "Other Resources";
×
54
            pinnedResourcesList.add(Pair.of(l, pinnedResources));
×
55
        }
56

57
        add(new DataView<Pair<String, List<Serializable>>>("pin-groups", new ListDataProvider<>(pinnedResourcesList)) {
×
58
            @Override
59
            protected void populateItem(Item<Pair<String, List<Serializable>>> item) {
60
               item.add(new ItemListPanel<Serializable>(
×
61
                        "pin-group",
62
                        item.getModelObject().getLeft(),
×
63
                        item.getModelObject().getRight(),
×
64
                        (o) -> {
65
                            if (o instanceof Template t) {
×
66
                                t.addToLabelMap(space.getId(), space.getLabel());
×
67
                                return new TemplateItem("item", t, tParams, false);
×
68
                            }
69
                            if (o instanceof GrlcQuery q) {
×
70
                                return new QueryItem("item", q, qParams, false);
×
71
                            }
72
                            return null;
×
73
                        }));
74
            }
×
75
        });
76

77
        add(new WebMarkupContainer("emptynotice").setVisible(pinnedResourcesList.isEmpty()));
×
78
    }
×
79

80
    private static final String getName(Serializable s) {
81
        if (s instanceof GrlcQuery q) return q.getLabel();
×
82
        if (s instanceof Template t) return t.getLabel();
×
83
        return s.toString();
×
84
    }
85

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