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

knowledgepixels / nanodash / 20264440287

16 Dec 2025 10:18AM UTC coverage: 15.358% (-0.1%) from 15.457%
20264440287

push

github

tkuhn
feat: Make use of template-version=latest in more places

593 of 4976 branches covered (11.92%)

Branch coverage included in aggregate %.

1571 of 9114 relevant lines covered (17.24%)

2.22 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.retrieveResponse(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
                        String partField = view.getTemplatePartFieldForAction(actionIri);
×
91
                        if (partField != null) {
×
92
                            // TODO Find a better way to pass the MaintainedResource object to this method:
93
                            MaintainedResource r = MaintainedResource.get(contextId);
×
94
                            if (r != null && r.getNamespace() != null) {
×
95
                                params.set("param_" + partField, r.getNamespace() + "<SET-SUFFIX>");
×
96
                            }
97
                        }
98
                        String queryMapping = view.getTemplateQueryMapping(actionIri);
×
99
                        if (queryMapping != null && queryMapping.contains(":")) {
×
100
                            params.set("values-from-query", queryRef.getAsUrlString());
×
101
                            params.set("values-from-query-mapping", queryMapping);
×
102
                        }
103
                        params.set("refresh-upon-publish", queryRef.getAsUrlString());
×
104
                        resultList.addButton(label, PublishPage.class, params);
×
105
                    }
×
106
                }
107
                return resultList;
×
108
            } else {
109
                return new ApiResultComponent(markupId, queryRef) {
×
110
                    @Override
111
                    public Component getApiResultComponent(String markupId, ApiResponse response) {
112
                        QueryResultList resultList = new QueryResultList(markupId, queryRef, response, viewDisplay);
×
113
                        resultList.setProfiledResource(space);
×
114
                        resultList.setContextId(contextId);
×
115
                        ResourceView view = viewDisplay.getView();
×
116
                        if (view != null) {
×
117
                            for (IRI actionIri : view.getViewResultActionList()) {
×
118
                                Template t = view.getTemplateForAction(actionIri);
×
119
                                if (t == null) continue;
×
120
                                String targetField = view.getTemplateTargetFieldForAction(actionIri);
×
121
                                if (targetField == null) targetField = "resource";
×
122
                                String label = view.getLabelForAction(actionIri);
×
123
                                if (label == null) label = "action...";
×
124
                                PageParameters params = new PageParameters().set("template", t.getId())
×
125
                                        .set("param_" + targetField, id)
×
126
                                        .set("context", contextId)
×
127
                                        .set("template-version", "latest");
×
128
                                String partField = view.getTemplatePartFieldForAction(actionIri);
×
129
                                if (partField != null) {
×
130
                                    // TODO Find a better way to pass the MaintainedResource object to this method:
131
                                    MaintainedResource r = MaintainedResource.get(contextId);
×
132
                                    if (r != null && r.getNamespace() != null) {
×
133
                                        params.set("param_" + partField, r.getNamespace() + "<SET-SUFFIX>");
×
134
                                    }
135
                                }
136
                                String queryMapping = view.getTemplateQueryMapping(actionIri);
×
137
                                if (queryMapping != null && queryMapping.contains(":")) {
×
138
                                    params.set("values-from-query", queryRef.getAsUrlString());
×
139
                                    params.set("values-from-query-mapping", queryMapping);
×
140
                                }
141
                                params.set("refresh-upon-publish", queryRef.getAsUrlString());
×
142
                                resultList.addButton(label, PublishPage.class, params);
×
143
                            }
×
144
                        }
145
                        return resultList;
×
146
                    }
147
                };
148
            }
149
        } else {
150
            if (response != null) {
×
151
                QueryResultList resultList = new QueryResultList(markupId, queryRef, response, viewDisplay);
×
152
                resultList.setContextId(contextId);
×
153
                return resultList;
×
154
            } else {
155
                return new ApiResultComponent(markupId, queryRef) {
×
156
                    @Override
157
                    public Component getApiResultComponent(String markupId, ApiResponse response) {
158
                        QueryResultList resultList = new QueryResultList(markupId, queryRef, response, viewDisplay);
×
159
                        resultList.setContextId(contextId);
×
160
                        return resultList;
×
161
                    }
162
                };
163
            }
164
        }
165
    }
166

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