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

knowledgepixels / nanodash / 22618039211

03 Mar 2026 10:05AM UTC coverage: 16.058% (+0.2%) from 15.884%
22618039211

Pull #365

github

web-flow
Merge 1e7e700f0 into a8c4b4a77
Pull Request #365: Refactor of `ResourceWithProfile` and related classes

699 of 5287 branches covered (13.22%)

Branch coverage included in aggregate %.

1721 of 9783 relevant lines covered (17.59%)

2.41 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.domain.AbstractResourceWithProfile;
5
import com.knowledgepixels.nanodash.page.NanodashPage;
6
import org.apache.wicket.behavior.AttributeAppender;
7
import org.apache.wicket.markup.html.basic.Label;
8
import org.apache.wicket.markup.html.link.AbstractLink;
9
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
10
import org.apache.wicket.markup.html.panel.Panel;
11
import org.apache.wicket.model.Model;
12
import org.apache.wicket.request.mapper.parameter.PageParameters;
13
import org.nanopub.extra.services.ApiResponse;
14
import org.nanopub.extra.services.QueryRef;
15

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

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

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

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

49
        add(new AttributeAppender("class", " col-" + viewDisplay.getDisplayWidth()));
×
50
    }
×
51

52
    @Override
53
    protected void onBeforeRender() {
54
        if (!finalized) {
×
55
            if (!buttons.isEmpty()) {
×
56
                add(new ButtonList("buttons", resourceWithProfile, buttons, null, null));
×
57
            } else {
58
                add(new Label("buttons").setVisible(false));
×
59
            }
60
            finalized = true;
×
61
        }
62
        super.onBeforeRender();
×
63
    }
×
64

65
    /**
66
     * Set the resource with profile for this component.
67
     *
68
     * @param resourceWithProfile The resource with profile to set.
69
     */
70
    public void setProfiledResource(AbstractResourceWithProfile resourceWithProfile) {
71
        this.resourceWithProfile = resourceWithProfile;
×
72
    }
×
73

74
    /**
75
     * Set the context ID for this component.
76
     *
77
     * @param contextId The context ID to set.
78
     */
79
    public void setContextId(String contextId) {
80
        this.contextId = contextId;
×
81
    }
×
82

83
    /**
84
     * Set the part ID when this view is shown on a part page (e.g. paper collection).
85
     * Used for redirect-after-publish to return to the part page.
86
     *
87
     * @param partId The part ID to set, or null when on the main context page.
88
     */
89
    public void setPartId(String partId) {
90
        this.partId = partId;
×
91
    }
×
92

93
    // TODO button adding method copied and adjusted from ItemListPanel
94
    // TODO Improve this (member/admin) button handling:
95
    public void addButton(String label, Class<? extends NanodashPage> pageClass, PageParameters parameters) {
96
        if (parameters == null) {
×
97
            parameters = new PageParameters();
×
98
        }
99
        if (contextId != null) {
×
100
            parameters.set("context", contextId);
×
101
        }
102
        AbstractLink button = new BookmarkablePageLink<NanodashPage>("button", pageClass, parameters);
×
103
        button.setBody(Model.of(label));
×
104
        buttons.add(button);
×
105
    }
×
106

107
    /**
108
     * Populate the component with the query results.
109
     */
110
    protected abstract void populateComponent();
111

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