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

knowledgepixels / nanodash / 22630596072

03 Mar 2026 03:41PM UTC coverage: 15.949% (-0.08%) from 16.03%
22630596072

Pull #369

github

web-flow
Merge 6951bc4cf into 85e0af2dc
Pull Request #369: Replace "^" for view displays with dropdown menu

699 of 5317 branches covered (13.15%)

Branch coverage included in aggregate %.

1721 of 9856 relevant lines covered (17.46%)

2.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/nanodash/QueryResult.java
1
package com.knowledgepixels.nanodash;
2

3
import com.knowledgepixels.nanodash.component.ButtonList;
4
import com.knowledgepixels.nanodash.component.ViewDisplayMenu;
5
import com.knowledgepixels.nanodash.domain.AbstractResourceWithProfile;
6
import com.knowledgepixels.nanodash.page.NanodashPage;
7
import org.apache.wicket.behavior.AttributeAppender;
8
import org.apache.wicket.markup.html.basic.Label;
9
import org.apache.wicket.markup.html.link.AbstractLink;
10
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
11
import org.apache.wicket.markup.html.panel.Panel;
12
import org.apache.wicket.model.Model;
13
import org.apache.wicket.request.mapper.parameter.PageParameters;
14
import org.nanopub.extra.services.ApiResponse;
15
import org.nanopub.extra.services.QueryRef;
16

17
import java.util.ArrayList;
18
import java.util.List;
19

20
/**
21
 * Abstract base class for displaying query results in different formats.
22
 */
23
public abstract class QueryResult extends Panel {
24

25
    protected final List<AbstractLink> buttons = new ArrayList<>();
×
26
    protected String contextId;
27
    protected String partId;
28
    protected boolean finalized = false;
×
29
    protected final QueryRef queryRef;
30
    protected final ViewDisplay viewDisplay;
31
    protected final ApiResponse response;
32
    protected AbstractResourceWithProfile resourceWithProfile;
33
    protected AbstractResourceWithProfile pageResource;
34
    protected boolean showViewDisplayMenu = true;
×
35
    protected final GrlcQuery grlcQuery;
36

37
    /**
38
     * Constructor for QueryResult.
39
     *
40
     * @param markupId    the markup ID
41
     * @param queryRef    the query reference
42
     * @param response    the API response
43
     * @param viewDisplay the view display
44
     */
45
    public QueryResult(String markupId, QueryRef queryRef, ApiResponse response, ViewDisplay viewDisplay) {
46
        super(markupId);
×
47
        this.queryRef = queryRef;
×
48
        this.viewDisplay = viewDisplay;
×
49
        this.response = response;
×
50
        this.grlcQuery = GrlcQuery.get(queryRef);
×
51

52
        add(new AttributeAppender("class", " col-" + viewDisplay.getDisplayWidth()));
×
53
    }
×
54

55
    @Override
56
    protected void onBeforeRender() {
57
        if (!finalized) {
×
58
            if (!buttons.isEmpty()) {
×
59
                add(new ButtonList("buttons", resourceWithProfile, buttons, null, null));
×
60
            } else {
61
                add(new Label("buttons").setVisible(false));
×
62
            }
63
            if (showViewDisplayMenu) {
×
64
                if (viewDisplay.getNanopubId() != null) {
×
65
                    add(new ViewDisplayMenu("np", viewDisplay, queryRef, pageResource));
×
66
                } else {
67
                    add(new Label("np").setVisible(false));
×
68
                }
69
            }
70
            finalized = true;
×
71
        }
72
        super.onBeforeRender();
×
73
    }
×
74

75
    /**
76
     * Set the resource with profile for this component.
77
     *
78
     * @param resourceWithProfile The resource with profile to set.
79
     */
80
    public void setProfiledResource(AbstractResourceWithProfile resourceWithProfile) {
81
        this.resourceWithProfile = resourceWithProfile;
×
82
    }
×
83

84
    public void setPageResource(AbstractResourceWithProfile pageResource) {
85
        this.pageResource = pageResource;
×
86
    }
×
87

88
    /**
89
     * Set the context ID for this component.
90
     *
91
     * @param contextId The context ID to set.
92
     */
93
    public void setContextId(String contextId) {
94
        this.contextId = contextId;
×
95
    }
×
96

97
    /**
98
     * Set the part ID when this view is shown on a part page (e.g. paper collection).
99
     * Used for redirect-after-publish to return to the part page.
100
     *
101
     * @param partId The part ID to set, or null when on the main context page.
102
     */
103
    public void setPartId(String partId) {
104
        this.partId = partId;
×
105
    }
×
106

107
    // TODO button adding method copied and adjusted from ItemListPanel
108
    // TODO Improve this (member/admin) button handling:
109
    public void addButton(String label, Class<? extends NanodashPage> pageClass, PageParameters parameters) {
110
        if (parameters == null) {
×
111
            parameters = new PageParameters();
×
112
        }
113
        if (contextId != null) {
×
114
            parameters.set("context", contextId);
×
115
        }
116
        AbstractLink button = new BookmarkablePageLink<NanodashPage>("button", pageClass, parameters);
×
117
        button.setBody(Model.of(label));
×
118
        buttons.add(button);
×
119
    }
×
120

121
    /**
122
     * Populate the component with the query results.
123
     */
124
    protected abstract void populateComponent();
125

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