• 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/QueryResultPlainParagraphBuilder.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 QueryResultPlainParagraph components.
16
 */
17
public class QueryResultPlainParagraphBuilder 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
    // This method is the result of refactoring and copying code from other classes done
27
    // by Cursor. This should in general be aligned and refactored more with the other classes.
28
    private void addResultButtons(QueryResultPlainParagraph resultPlainParagraph) {
29
        ResourceView view = viewDisplay.getView();
×
30
        if (view == null) return;
×
31
        for (IRI actionIri : view.getViewResultActionList()) {
×
32
            Template t = view.getTemplateForAction(actionIri);
×
33
            if (t == null) continue;
×
34
            String targetField = view.getTemplateTargetFieldForAction(actionIri);
×
35
            if (targetField == null) targetField = "resource";
×
36
            String label = view.getLabelForAction(actionIri);
×
37
            if (label == null) label = "action...";
×
38
            PageParameters params = new PageParameters().set("template", t.getId())
×
39
                    .set("param_" + targetField, id)
×
40
                    .set("context", contextId)
×
41
                    .set("template-version", "latest");
×
42
            if (id != null && contextId != null && !id.equals(contextId)) {
×
43
                params.set("part", id);
×
44
            }
45
            String partField = view.getTemplatePartFieldForAction(actionIri);
×
46
            if (partField != null) {
×
47
                // TODO Find a better way to pass the MaintainedResource object to this method:
48
                MaintainedResource r = MaintainedResource.get(contextId);
×
49
                if (r != null && r.getNamespace() != null) {
×
50
                    params.set("param_" + partField, r.getNamespace() + "<SET-SUFFIX>");
×
51
                }
52
            }
53
            String queryMapping = view.getTemplateQueryMapping(actionIri);
×
54
            if (queryMapping != null && queryMapping.contains(":")) {
×
55
                params.set("values-from-query", queryRef.getAsUrlString());
×
56
                params.set("values-from-query-mapping", queryMapping);
×
57
            }
58
            params.set("refresh-upon-publish", queryRef.getAsUrlString());
×
59
            resultPlainParagraph.addButton(label, PublishPage.class, params);
×
60
        }
×
61
    }
×
62

63
    private QueryResultPlainParagraphBuilder(String markupId, QueryRef queryRef, ViewDisplay viewDisplay) {
×
64
        this.markupId = markupId;
×
65
        this.queryRef = queryRef;
×
66
        this.viewDisplay = viewDisplay;
×
67
    }
×
68

69
    /**
70
     * Creates a new QueryResultPlainParagraphBuilder instance.
71
     *
72
     * @param markupId    the markup ID for the component
73
     * @param queryRef    the query reference
74
     * @param viewDisplay the view display
75
     * @return a new QueryResultPlainParagraphBuilder instance
76
     */
77
    public static QueryResultPlainParagraphBuilder create(String markupId, QueryRef queryRef, ViewDisplay viewDisplay) {
78
        return new QueryResultPlainParagraphBuilder(markupId, queryRef, viewDisplay);
×
79
    }
80

81
    /**
82
     * Sets the context ID for the QueryResultPlainParagraph.
83
     *
84
     * @param contextId the context ID
85
     * @return the current QueryResultPlainParagraphBuilder instance
86
     */
87
    public QueryResultPlainParagraphBuilder contextId(String contextId) {
88
        this.contextId = contextId;
×
89
        return this;
×
90
    }
91

92
    public QueryResultPlainParagraphBuilder id(String id) {
93
        this.id = id;
×
94
        return this;
×
95
    }
96

97
    /**
98
     * Builds the QueryResultPlainParagraph component.
99
     *
100
     * @return the QueryResultPlainParagraph component
101
     */
102
    public Component build() {
103
        ApiResponse response = ApiCache.retrieveResponseAsync(queryRef);
×
104
        if (space != null) {
×
105
            if (response != null) {
×
106
                QueryResultPlainParagraph resultPlainParagraph = new QueryResultPlainParagraph(markupId, queryRef, response, viewDisplay);
×
107
                resultPlainParagraph.setProfiledResource(space);
×
108
                resultPlainParagraph.setContextId(contextId);
×
109
                addResultButtons(resultPlainParagraph);
×
110
                return resultPlainParagraph;
×
111
            } else {
112
                return new ApiResultComponent(markupId, queryRef) {
×
113
                    @Override
114
                    public Component getApiResultComponent(String markupId, ApiResponse response) {
115
                        QueryResultPlainParagraph resultPlainParagraph = new QueryResultPlainParagraph(markupId, queryRef, response, viewDisplay);
×
116
                        resultPlainParagraph.setProfiledResource(space);
×
117
                        resultPlainParagraph.setContextId(contextId);
×
118
                        addResultButtons(resultPlainParagraph);
×
119
                        return resultPlainParagraph;
×
120
                    }
121
                };
122
            }
123
        } else {
124
            if (response != null) {
×
125
                QueryResultPlainParagraph resultPlainParagraph = new QueryResultPlainParagraph(markupId, queryRef, response, viewDisplay);
×
126
                resultPlainParagraph.setContextId(contextId);
×
127
                addResultButtons(resultPlainParagraph);
×
128
                return resultPlainParagraph;
×
129
            } else {
130
                return new ApiResultComponent(markupId, queryRef) {
×
131
                    @Override
132
                    public Component getApiResultComponent(String markupId, ApiResponse response) {
133
                        QueryResultPlainParagraph resultPlainParagraph = new QueryResultPlainParagraph(markupId, queryRef, response, viewDisplay);
×
134
                        resultPlainParagraph.setContextId(contextId);
×
135
                        addResultButtons(resultPlainParagraph);
×
136
                        return resultPlainParagraph;
×
137
                    }
138
                };
139
            }
140
        }
141
    }
142

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