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

knowledgepixels / nanodash / 26518296981

27 May 2026 02:41PM UTC coverage: 20.586% (+0.05%) from 20.537%
26518296981

push

github

web-flow
Merge pull request #471 from knowledgepixels/chore/bump-nanopub-1.90.0

Bump nanopub to 1.90.0 and drop placeholder/expansion code it now provides

1007 of 6204 branches covered (16.23%)

Branch coverage included in aggregate %.

2604 of 11337 relevant lines covered (22.97%)

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

3
import com.google.common.collect.ArrayListMultimap;
4
import com.google.common.collect.Multimap;
5
import com.knowledgepixels.nanodash.View;
6
import com.knowledgepixels.nanodash.ViewDisplay;
7
import com.knowledgepixels.nanodash.domain.AbstractResourceWithProfile;
8
import com.knowledgepixels.nanodash.domain.Space;
9
import com.knowledgepixels.nanodash.vocabulary.KPXL_TERMS;
10
import org.apache.wicket.Component;
11
import org.apache.wicket.markup.html.WebMarkupContainer;
12
import org.apache.wicket.markup.html.basic.Label;
13
import org.apache.wicket.markup.html.link.AbstractLink;
14
import org.apache.wicket.markup.html.list.ListItem;
15
import org.apache.wicket.markup.html.list.ListView;
16
import org.apache.wicket.markup.html.panel.Panel;
17
import org.eclipse.rdf4j.model.IRI;
18
import org.nanopub.extra.services.QueryRef;
19
import org.nanopub.extra.services.QueryTemplate;
20
import org.slf4j.Logger;
21
import org.slf4j.LoggerFactory;
22

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

27
public class ViewList extends Panel {
28

29
    private static final Logger logger = LoggerFactory.getLogger(ViewList.class);
×
30

31
    public ViewList(String markupId, AbstractResourceWithProfile resourceWithProfile) {
32
        this(markupId, resourceWithProfile, null, null, null, null, null, true, null);
×
33
    }
×
34

35
    public ViewList(String markupId, AbstractResourceWithProfile resourceWithProfile, String partId, String nanopubId, Set<IRI> partClasses) {
36
        this(markupId, resourceWithProfile, partId, nanopubId, partClasses, null, null, true, null);
×
37
    }
×
38

39
    public ViewList(String markupId, AbstractResourceWithProfile resourceWithProfile, String partId, String nanopubId, Set<IRI> partClasses, AbstractResourceWithProfile footerResource, List<AbstractLink> footerAdminButtons) {
40
        this(markupId, resourceWithProfile, partId, nanopubId, partClasses, footerResource, footerAdminButtons, true, null);
×
41
    }
×
42

43
    public ViewList(String markupId, AbstractResourceWithProfile resourceWithProfile, String partId, String nanopubId, Set<IRI> partClasses, AbstractResourceWithProfile footerResource, List<AbstractLink> footerAdminButtons, boolean showEmptyNotice) {
44
        this(markupId, resourceWithProfile, partId, nanopubId, partClasses, footerResource, footerAdminButtons, showEmptyNotice, null);
×
45
    }
×
46

47
    public ViewList(String markupId, AbstractResourceWithProfile resourceWithProfile, List<ViewDisplay> explicitViewDisplays) {
48
        this(markupId, resourceWithProfile, null, null, null, null, null, false, explicitViewDisplays);
×
49
    }
×
50

51
    public ViewList(String markupId, AbstractResourceWithProfile resourceWithProfile, List<ViewDisplay> explicitViewDisplays, AbstractResourceWithProfile footerResource, List<AbstractLink> footerAdminButtons) {
52
        this(markupId, resourceWithProfile, null, null, null, footerResource, footerAdminButtons, false, explicitViewDisplays);
×
53
    }
×
54

55
    private ViewList(String markupId, AbstractResourceWithProfile resourceWithProfile, String partId, String nanopubId, Set<IRI> partClasses, AbstractResourceWithProfile footerResource, List<AbstractLink> footerAdminButtons, boolean showEmptyNotice, List<ViewDisplay> explicitViewDisplays) {
56
        super(markupId);
×
57

58
        final String id = (partId == null ? resourceWithProfile.getId() : partId);
×
59
        final String npId = (nanopubId == null ? resourceWithProfile.getNanopubId() : nanopubId);
×
60
        final List<ViewDisplay> viewDisplays;
61
        if (explicitViewDisplays != null) {
×
62
            viewDisplays = explicitViewDisplays;
×
63
        } else if (partId == null) {
×
64
            viewDisplays = resourceWithProfile.getTopLevelViewDisplays();
×
65
        } else {
66
            viewDisplays = resourceWithProfile.getPartLevelViewDisplays(partId, partClasses);
×
67
        }
68

69
        // Group viewDisplays by the first segment of their structural position (e.g. "4" from "4.4.1.papers")
70
        List<List<ViewDisplay>> groups = new ArrayList<>();
×
71
        String currentGroupKey = null;
×
72
        List<ViewDisplay> currentGroup = null;
×
73
        for (ViewDisplay vd : viewDisplays) {
×
74
            String pos = vd.getStructuralPosition();
×
75
            int firstDot = pos.indexOf('.');
×
76
            String key = firstDot > 0 ? pos.substring(0, firstDot) : pos;
×
77
            if (!key.equals(currentGroupKey)) {
×
78
                currentGroup = new ArrayList<>();
×
79
                groups.add(currentGroup);
×
80
                currentGroupKey = key;
×
81
            }
82
            currentGroup.add(vd);
×
83
        }
×
84

85
        add(new ListView<List<ViewDisplay>>("groups", groups) {
×
86
            @Override
87
            protected void populateItem(ListItem<List<ViewDisplay>> groupItem) {
88
                List<ViewDisplay> group = groupItem.getModelObject();
×
89
                groupItem.add(new ListView<ViewDisplay>("views", group) {
×
90
                    @Override
91
                    protected void populateItem(ListItem<ViewDisplay> item) {
92
                        View view = item.getModelObject().getView();
×
93
                        Multimap<String, String> queryRefParams = ArrayListMultimap.create();
×
94
                        for (String p : view.getQuery().getPlaceholdersList()) {
×
95
                            String paramName = QueryTemplate.getParamName(p);
×
96
                            if (paramName.equals(view.getQueryField())) {
×
97
                                queryRefParams.put(view.getQueryField(), id);
×
98
                                if (QueryTemplate.isMultiPlaceholder(p) && resourceWithProfile instanceof Space space) {
×
99
                                    // TODO Support this also for maintained resources and users.
100
                                    for (String altId : space.getAltIDs()) {
×
101
                                        queryRefParams.put(view.getQueryField(), altId);
×
102
                                    }
×
103
                                }
104
                            } else if (paramName.equals(view.getQueryField() + "Namespace") && resourceWithProfile.getNamespace() != null) {
×
105
                                queryRefParams.put(view.getQueryField() + "Namespace", resourceWithProfile.getNamespace());
×
106
                            } else if (paramName.equals(view.getQueryField() + "Np")) {
×
107
                                if (!QueryTemplate.isOptionalPlaceholder(p) && npId == null) {
×
108
                                    queryRefParams.put(view.getQueryField() + "Np", "x:");
×
109
                                } else {
110
                                    queryRefParams.put(view.getQueryField() + "Np", npId);
×
111
                                }
112
                            } else if (!QueryTemplate.isOptionalPlaceholder(p)) {
×
113
                                item.add(new Label("view", "<span class=\"negative\">Error: Query has non-optional parameter</span>").setEscapeModelStrings(false));
×
114
                                logger.error("Error: Query has non-optional parameter: {} {}", view.getQuery().getQueryId(), p);
×
115
                                return;
×
116
                            }
117
                        }
×
118
                        QueryRef queryRef = new QueryRef(view.getQuery().getQueryId(), queryRefParams);
×
119
                        if (view.getViewType() != null && View.getSupportedViewTypes().contains(view.getViewType())) {
×
120
                            if (view.getViewType().equals(KPXL_TERMS.LIST_VIEW)) {
×
121
                                item.add(QueryResultListBuilder.create("view", queryRef, item.getModelObject())
×
122
                                        .resourceWithProfile(resourceWithProfile)
×
123
                                        .pageResource(resourceWithProfile)
×
124
                                        .id(id)
×
125
                                        .contextId(resourceWithProfile.getId())
×
126
                                        .build());
×
127
                            } else if (view.getViewType().equals(KPXL_TERMS.TABULAR_VIEW)) {
×
128
                                item.add(QueryResultTableBuilder.create("view", queryRef, item.getModelObject())
×
129
                                        .resourceWithProfile(resourceWithProfile)
×
130
                                        .contextId(resourceWithProfile.getId())
×
131
                                        .id(id)
×
132
                                        .build());
×
133
                            } else if (view.getViewType().equals(KPXL_TERMS.PLAIN_PARAGRAPH_VIEW)) {
×
134
                                item.add(QueryResultPlainParagraphBuilder.create("view", queryRef, item.getModelObject())
×
135
                                        .pageResource(resourceWithProfile)
×
136
                                        .contextId(resourceWithProfile.getId())
×
137
                                        .id(id)
×
138
                                        .build());
×
139
                            } else if (view.getViewType().equals(KPXL_TERMS.NANOPUB_SET_VIEW)) {
×
140
                                item.add(QueryResultNanopubSetBuilder.create("view", queryRef, item.getModelObject())
×
141
                                        .pageResource(resourceWithProfile)
×
142
                                        .contextId(resourceWithProfile.getId())
×
143
                                        .build());
×
144
                            } else if (view.getViewType().equals(KPXL_TERMS.ITEM_LIST_VIEW)) {
×
145
                                item.add(QueryResultItemListBuilder.create("view", queryRef, item.getModelObject())
×
146
                                        .resourceWithProfile(resourceWithProfile)
×
147
                                        .pageResource(resourceWithProfile)
×
148
                                        .id(id)
×
149
                                        .contextId(resourceWithProfile.getId())
×
150
                                        .build());
×
151
                            } else {
152
                                item.add(new Label("view", "<span class=\"negative\">View type \"" + view.getViewType().stringValue() + "\" is supported but its view is not implemented yet</span>").setEscapeModelStrings(false));
×
153
                                logger.error("View type \"{}\" is supported but its view is not implemented yet", view.getViewType().stringValue());
×
154
                            }
155
                        } else {
156
                            item.add(new Label("view", "<span class=\"negative\">Unsupported view type</span>").setEscapeModelStrings(false));
×
157
                            logger.error("Unsupported view type.");
×
158
                        }
159
                    }
×
160
                });
161
            }
×
162
        });
163

164
        add(new WebMarkupContainer("emptynotice").setVisible(showEmptyNotice && viewDisplays.isEmpty()));
×
165

166
        WebMarkupContainer footerSection = new WebMarkupContainer("footer-section");
×
167
        if (footerAdminButtons != null) {
×
168
            footerSection.add(new ButtonList("footer-buttons",
×
169
                    footerResource != null ? footerResource : resourceWithProfile,
×
170
                    null, null, footerAdminButtons));
171
        } else {
172
            footerSection.setVisible(false);
×
173
            footerSection.add(new Label("footer-buttons").setVisible(false));
×
174
        }
175
        add(footerSection);
×
176

177
        add(new WebMarkupContainer("page-footer").setVisible(false));
×
178
    }
×
179

180
    public void setPageFooter(Component footer) {
181
        replace(footer);
×
182
    }
×
183

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