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

knowledgepixels / nanodash / 21569970831

01 Feb 2026 08:46PM UTC coverage: 14.11% (-0.2%) from 14.273%
21569970831

push

github

tkuhn
style: Remove "beta" from logo and "by Knowledge Pixels" link

549 of 5182 branches covered (10.59%)

Branch coverage included in aggregate %.

1506 of 9382 relevant lines covered (16.05%)

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

3
import com.knowledgepixels.nanodash.*;
4
import com.knowledgepixels.nanodash.page.PublishPage;
5
import com.knowledgepixels.nanodash.template.Template;
6
import org.apache.wicket.Component;
7
import org.apache.wicket.request.mapper.parameter.PageParameters;
8
import org.eclipse.rdf4j.model.IRI;
9
import org.nanopub.extra.services.ApiResponse;
10
import org.nanopub.extra.services.QueryRef;
11

12
import java.io.Serializable;
13

14
/**
15
 * Builder class for creating QueryResultList components.
16
 */
17
public class QueryResultListBuilder implements Serializable {
18

19
    private String markupId;
20
    private ViewDisplay viewDisplay;
21
    private String contextId = null;
×
22
    private QueryRef queryRef;
23
    private Space space = null;
×
24
    private String id = null;
×
25

26
    private QueryResultListBuilder(String markupId, QueryRef queryRef, ViewDisplay viewDisplay) {
×
27
        this.markupId = markupId;
×
28
        this.queryRef = queryRef;
×
29
        this.viewDisplay = viewDisplay;
×
30
    }
×
31

32
    /**
33
     * Creates a new QueryResultListBuilder instance.
34
     *
35
     * @param markupId    the markup ID for the component
36
     * @param queryRef    the query reference
37
     * @param viewDisplay the view display
38
     * @return a new QueryResultListBuilder instance
39
     */
40
    public static QueryResultListBuilder create(String markupId, QueryRef queryRef, ViewDisplay viewDisplay) {
41
        return new QueryResultListBuilder(markupId, queryRef, viewDisplay);
×
42
    }
43

44
    public QueryResultListBuilder space(Space space) {
45
        this.space = space;
×
46
        return this;
×
47
    }
48

49
    /**
50
     * Sets the context ID for the QueryResultList.
51
     *
52
     * @param contextId the context ID
53
     * @return the current QueryResultListBuilder instance
54
     */
55
    public QueryResultListBuilder contextId(String contextId) {
56
        this.contextId = contextId;
×
57
        return this;
×
58
    }
59

60
    public QueryResultListBuilder id(String id) {
61
        this.id = id;
×
62
        return this;
×
63
    }
64

65
    /**
66
     * Builds the QueryResultList component.
67
     *
68
     * @return the QueryResultList component
69
     */
70
    public Component build() {
71
        ApiResponse response = ApiCache.retrieveResponseAsync(queryRef);
×
72
        if (space != null) {
×
73
            if (response != null) {
×
74
                QueryResultList resultList = new QueryResultList(markupId, queryRef, response, viewDisplay);
×
75
                resultList.setProfiledResource(space);
×
76
                resultList.setContextId(contextId);
×
77
                ResourceView view = viewDisplay.getView();
×
78
                if (view != null) {
×
79
                    for (IRI actionIri : view.getViewResultActionList()) {
×
80
                        Template t = view.getTemplateForAction(actionIri);
×
81
                        if (t == null) continue;
×
82
                        String targetField = view.getTemplateTargetFieldForAction(actionIri);
×
83
                        if (targetField == null) targetField = "resource";
×
84
                        String label = view.getLabelForAction(actionIri);
×
85
                        if (label == null) label = "action...";
×
86
                        PageParameters params = new PageParameters().set("template", t.getId())
×
87
                                .set("param_" + targetField, id)
×
88
                                .set("context", contextId)
×
89
                                .set("template-version", "latest");
×
90
                        if (id != null && contextId != null && !id.equals(contextId)) {
×
91
                            params.set("part", id);
×
92
                        }
93
                        String partField = view.getTemplatePartFieldForAction(actionIri);
×
94
                        if (partField != null) {
×
95
                            // TODO Find a better way to pass the MaintainedResource object to this method:
96
                            MaintainedResource r = MaintainedResource.get(contextId);
×
97
                            if (r != null && r.getNamespace() != null) {
×
98
                                params.set("param_" + partField, r.getNamespace() + "<SET-SUFFIX>");
×
99
                            }
100
                        }
101
                        String queryMapping = view.getTemplateQueryMapping(actionIri);
×
102
                        if (queryMapping != null && queryMapping.contains(":")) {
×
103
                            params.set("values-from-query", queryRef.getAsUrlString());
×
104
                            params.set("values-from-query-mapping", queryMapping);
×
105
                        }
106
                        params.set("refresh-upon-publish", queryRef.getAsUrlString());
×
107
                        resultList.addButton(label, PublishPage.class, params);
×
108
                    }
×
109
                }
110
                return resultList;
×
111
            } else {
112
                return new ApiResultComponent(markupId, queryRef) {
×
113
                    @Override
114
                    public Component getApiResultComponent(String markupId, ApiResponse response) {
115
                        QueryResultList resultList = new QueryResultList(markupId, queryRef, response, viewDisplay);
×
116
                        resultList.setProfiledResource(space);
×
117
                        resultList.setContextId(contextId);
×
118
                        ResourceView view = viewDisplay.getView();
×
119
                        if (view != null) {
×
120
                            for (IRI actionIri : view.getViewResultActionList()) {
×
121
                                Template t = view.getTemplateForAction(actionIri);
×
122
                                if (t == null) continue;
×
123
                                String targetField = view.getTemplateTargetFieldForAction(actionIri);
×
124
                                if (targetField == null) targetField = "resource";
×
125
                                String label = view.getLabelForAction(actionIri);
×
126
                                if (label == null) label = "action...";
×
127
                                PageParameters params = new PageParameters().set("template", t.getId())
×
128
                                        .set("param_" + targetField, id)
×
129
                                        .set("context", contextId)
×
130
                                        .set("template-version", "latest");
×
131
                                if (id != null && contextId != null && !id.equals(contextId)) {
×
132
                                    params.set("part", id);
×
133
                                }
134
                                String partField = view.getTemplatePartFieldForAction(actionIri);
×
135
                                if (partField != null) {
×
136
                                    // TODO Find a better way to pass the MaintainedResource object to this method:
137
                                    MaintainedResource r = MaintainedResource.get(contextId);
×
138
                                    if (r != null && r.getNamespace() != null) {
×
139
                                        params.set("param_" + partField, r.getNamespace() + "<SET-SUFFIX>");
×
140
                                    }
141
                                }
142
                                String queryMapping = view.getTemplateQueryMapping(actionIri);
×
143
                                if (queryMapping != null && queryMapping.contains(":")) {
×
144
                                    params.set("values-from-query", queryRef.getAsUrlString());
×
145
                                    params.set("values-from-query-mapping", queryMapping);
×
146
                                }
147
                                params.set("refresh-upon-publish", queryRef.getAsUrlString());
×
148
                                resultList.addButton(label, PublishPage.class, params);
×
149
                            }
×
150
                        }
151
                        return resultList;
×
152
                    }
153
                };
154
            }
155
        } else {
156
            if (response != null) {
×
157
                QueryResultList resultList = new QueryResultList(markupId, queryRef, response, viewDisplay);
×
158
                resultList.setContextId(contextId);
×
159
                return resultList;
×
160
            } else {
161
                return new ApiResultComponent(markupId, queryRef) {
×
162
                    @Override
163
                    public Component getApiResultComponent(String markupId, ApiResponse response) {
164
                        QueryResultList resultList = new QueryResultList(markupId, queryRef, response, viewDisplay);
×
165
                        resultList.setContextId(contextId);
×
166
                        return resultList;
×
167
                    }
168
                };
169
            }
170
        }
171
    }
172

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