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

knowledgepixels / nanodash / 18834771957

27 Oct 2025 08:37AM UTC coverage: 13.674% (+0.01%) from 13.662%
18834771957

push

github

tkuhn
feat(MaintainedResources): Add resource part pages

481 of 4418 branches covered (10.89%)

Branch coverage included in aggregate %.

1255 of 8278 relevant lines covered (15.16%)

0.68 hits per line

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

7.85
src/main/java/com/knowledgepixels/nanodash/component/NanopubItem.java
1
package com.knowledgepixels.nanodash.component;
2

3
import java.text.SimpleDateFormat;
4
import java.util.ArrayList;
5
import java.util.Arrays;
6
import java.util.HashMap;
7
import java.util.List;
8
import java.util.Map;
9
import java.util.Set;
10

11
import org.apache.wicket.markup.html.WebMarkupContainer;
12
import org.apache.wicket.markup.html.basic.Label;
13
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
14
import org.apache.wicket.markup.html.panel.Panel;
15
import org.apache.wicket.markup.repeater.Item;
16
import org.apache.wicket.markup.repeater.data.DataView;
17
import org.apache.wicket.markup.repeater.data.ListDataProvider;
18
import org.apache.wicket.model.Model;
19
import org.apache.wicket.request.mapper.parameter.PageParameters;
20
import org.eclipse.rdf4j.model.IRI;
21
import org.eclipse.rdf4j.model.Statement;
22
import org.nanopub.SimpleCreatorPattern;
23
import org.nanopub.extra.security.MalformedCryptoElementException;
24
import org.nanopub.extra.security.SignatureUtils;
25
import org.nanopub.vocabulary.NTEMPLATE;
26
import org.slf4j.Logger;
27
import org.slf4j.LoggerFactory;
28

29
import com.knowledgepixels.nanodash.NanodashPreferences;
30
import com.knowledgepixels.nanodash.NanodashSession;
31
import com.knowledgepixels.nanodash.NanopubElement;
32
import com.knowledgepixels.nanodash.User;
33
import com.knowledgepixels.nanodash.Utils;
34
import com.knowledgepixels.nanodash.action.NanopubAction;
35
import com.knowledgepixels.nanodash.page.ListPage;
36
import com.knowledgepixels.nanodash.page.UserPage;
37
import com.knowledgepixels.nanodash.template.ContextType;
38
import com.knowledgepixels.nanodash.template.Template;
39
import com.knowledgepixels.nanodash.template.TemplateContext;
40
import com.knowledgepixels.nanodash.template.TemplateData;
41
import com.knowledgepixels.nanodash.template.ValueFiller;
42

43
/**
44
 * A panel that displays a nanopublication with its header, footer, assertion, provenance, and pubinfo.
45
 */
46
public class NanopubItem extends Panel {
47

48
    /**
49
     * Date format for displaying the creation date and time of the nanopub.
50
     */
51
    public static SimpleDateFormat simpleDateTimeFormat = new SimpleDateFormat("d MMM yyyy, HH:mm:ss zzz");
5✔
52
    /**
53
     * Date format for displaying the creation time of the nanopub without time.
54
     */
55
    public static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("d MMM yyyy");
5✔
56

57
    private boolean isInitialized = false;
3✔
58
    private NanopubElement n;
59
    private boolean hideAssertion = false;
3✔
60
    private boolean hideProvenance = false;
3✔
61
    private boolean hidePubinfo = false;
3✔
62
    private boolean hideHeader = false;
3✔
63
    private boolean hideFooter = false;
3✔
64
    private boolean hideActionMenu = false;
3✔
65
    private List<NanopubAction> actions;
66
    private IRI signerId;
67
    private String templateId;
68
    private static final Logger logger = LoggerFactory.getLogger(NanopubItem.class);
4✔
69

70
    /**
71
     * Creates a NanopubItem panel.
72
     *
73
     * @param id         the Wicket component ID
74
     * @param n          the NanopubElement to display
75
     * @param templateId the ID of the template to use for rendering the assertion.
76
     */
77
    public NanopubItem(String id, NanopubElement n, String templateId) {
78
        super(id);
3✔
79
        this.n = n;
3✔
80
        this.templateId = templateId;
3✔
81
    }
1✔
82

83
    /**
84
     * Creates a NanopubItem panel with a default template ID.
85
     *
86
     * @param id the Wicket component ID
87
     * @param n  the NanopubElement to display
88
     */
89
    public NanopubItem(String id, NanopubElement n) {
90
        this(id, n, null);
×
91
    }
×
92

93
    private void initialize() {
94
        if (isInitialized) return;
×
95

96
        String pubkey = n.getPubkey();
×
97
        String pubkeyhash = n.getPubkeyhash();
×
98
        signerId = n.getSignerId();
×
99

100
        if (hideHeader) {
×
101
            add(new Label("header", "").setVisible(false));
×
102
        } else {
103
            WebMarkupContainer header = new WebMarkupContainer("header");
×
104
            String labelString = n.getLabel();
×
105
            if (labelString == null || labelString.isBlank()) labelString = Utils.getShortNanopubId(n.getUri());
×
106
            header.add(NanodashLink.createLink("nanopub-id-link", n.getUri(), labelString, null));
×
107
            if (!hideActionMenu && (actions == null || !actions.isEmpty())) {
×
108
                NanodashSession session = NanodashSession.get();
×
109
                final boolean isOwnNanopub = (session.getUserIri() != null && session.getUserIri().equals(User.getUserData().getUserIriForPubkeyhash(pubkeyhash, false))) ||
×
110
                                             ((pubkey != null) && pubkey.equals(session.getPubkeyString()));
×
111
                final boolean hasLocalPubkey = session.getUserIri() != null && session.getPubkeyString() != null && session.getPubkeyString().equals(pubkey);
×
112
                final List<NanopubAction> actionList = new ArrayList<>();
×
113
                final Map<String, NanopubAction> actionMap = new HashMap<>();
×
114
                List<NanopubAction> allActions = new ArrayList<>();
×
115
                if (actions == null) {
×
116
                    allActions.addAll(Arrays.asList(NanopubAction.defaultActions));
×
117
                    allActions.addAll(NanopubAction.getActionsFromPreferences(NanodashPreferences.get()));
×
118
                } else {
119
                    allActions.addAll(actions);
×
120
                }
121
                for (NanopubAction action : allActions) {
×
122
                    if (isOwnNanopub && !action.isApplicableToOwnNanopubs()) continue;
×
123
                    if (isOwnNanopub && !hasLocalPubkey && !action.isApplicableToOthersNanopubs() && !Utils.hasNanodashLocation(pubkeyhash))
×
124
                        continue;
×
125
                    if (!isOwnNanopub && !action.isApplicableToOthersNanopubs()) continue;
×
126
                    if (!action.isApplicableTo(n.getNanopub())) continue;
×
127
                    actionList.add(action);
×
128
                    actionMap.put(action.getLinkLabel(n.getNanopub()), action);
×
129
                }
×
130
                header.add(new ActionMenu("action-menu", actionList, n));
×
131
            } else {
×
132
                header.add(new Label("action-menu", "").setVisible(false));
×
133
            }
134
            header.add(new DataView<IRI>("typespan", new ListDataProvider<IRI>(Utils.getTypes(n.getNanopub()))) {
×
135

136
                @Override
137
                protected void populateItem(Item<IRI> item) {
138
                    IRI typeIri = item.getModelObject();
×
139
                    String label = Utils.getTypeLabel(typeIri);
×
140
                    item.add(new BookmarkablePageLink<Void>("type", ListPage.class, new PageParameters().add("type", typeIri)).setBody(Model.of(label)));
×
141
                }
×
142

143
            });
144
            add(header);
×
145
        }
146

147
        if (hideFooter) {
×
148
            add(new Label("footer", "").setVisible(false));
×
149
        } else {
150
            WebMarkupContainer footer = new WebMarkupContainer("footer");
×
151
            if (n.getCreationTime() != null) {
×
152
                footer.add(new Label("datetime", simpleDateTimeFormat.format(n.getCreationTime().getTime())));
×
153
            } else {
154
                footer.add(new Label("datetime", "(undated)"));
×
155
            }
156

157
            List<IRI> authors = SimpleCreatorPattern.getAuthorList(n.getNanopub());
×
158
            WebMarkupContainer authorsSpan = new WebMarkupContainer("authors-span");
×
159
            if (authors.isEmpty()) {
×
160
                authorsSpan.setVisible(false);
×
161
                footer.add(new Label("creator-post", "").setVisible(false));
×
162
            } else {
163
                IRI mainAuthor = authors.getFirst();
×
164
                BookmarkablePageLink<Void> mainAuthorLink = new BookmarkablePageLink<Void>("main-author-link", UserPage.class, new PageParameters().add("id", mainAuthor));
×
165
                String authorName = n.getFoafNameMap().get(mainAuthor.stringValue());
×
166
                if (authorName == null) {
×
167
                    authorName = User.getShortDisplayName(mainAuthor);
×
168
                }
169
                mainAuthorLink.add(new Label("main-author-text", authorName));
×
170
                authorsSpan.add(mainAuthorLink);
×
171
                if (authors.size() > 1) {
×
172
                    authorsSpan.add(new Label("authors-post", " et al. (authors)"));
×
173
                } else {
174
                    authorsSpan.add(new Label("authors-post", " (author)"));
×
175
                }
176
                footer.add(new Label("creator-post", " (creator)"));
×
177
            }
178
            footer.add(authorsSpan);
×
179

180
            PageParameters params = new PageParameters();
×
181

182
            // ----------
183
            // TODO Clean this up and move to helper method:
184
            IRI uIri = User.findSingleIdForPubkeyhash(pubkeyhash);
×
185
            if (uIri == null) {
×
186
                try {
187
                    Set<IRI> signers = SignatureUtils.getSignatureElement(n.getNanopub()).getSigners();
×
188
                    if (signers.size() == 1) {
×
189
                        uIri = signers.iterator().next();
×
190
                    } else {
191
                        Set<IRI> creators = SimpleCreatorPattern.getCreators(n.getNanopub());
×
192
                        if (creators.size() == 1) uIri = creators.iterator().next();
×
193
                    }
194
                } catch (MalformedCryptoElementException ex) {
×
195
                    logger.error("Error getting signer from nanopub {}", n.getUri(), ex);
×
196
                }
×
197
            }
198
            // ----------
199

200
            if (uIri != null) params.add("id", uIri);
×
201
            BookmarkablePageLink<Void> userLink = new BookmarkablePageLink<Void>("creator-link", UserPage.class, params);
×
202
            String userString;
203
            if (signerId != null) {
×
204
                userString = User.getShortDisplayNameForPubkeyhash(signerId, pubkeyhash);
×
205
            } else {
206
                userString = User.getShortDisplayNameForPubkeyhash(uIri, pubkeyhash);
×
207
            }
208
            userLink.add(new Label("creator-text", userString));
×
209
            footer.add(userLink);
×
210

211
            String positiveNotes = "";
×
212
            String negativeNotes = "";
×
213
            if (n.seemsToHaveSignature()) {
×
214
                try {
215
                    if (!n.hasValidSignature()) {
×
216
                        negativeNotes = "- invalid signature";
×
217
                    }
218
                } catch (Exception ex) {
×
219
                    logger.error("Error checking signature validity for nanopub {}", n.getUri(), ex);
×
220
                    negativeNotes = "- malformed or legacy signature";
×
221
                }
×
222
            }
223
            footer.add(new Label("positive-notes", positiveNotes));
×
224
            footer.add(new Label("negative-notes", negativeNotes));
×
225
            add(footer);
×
226
        }
227

228
        final TemplateData td = TemplateData.get();
×
229

230
        WebMarkupContainer assertion = new WebMarkupContainer("assertion");
×
231

232
        if (hideAssertion) {
×
233
            assertion.setVisible(false);
×
234
        } else {
235
            Template assertionTemplate = td.getTemplate(n.getNanopub());
×
236
            if (templateId != null) assertionTemplate = td.getTemplate(templateId);
×
237
            if (assertionTemplate == null) {
×
238
                assertionTemplate = td.getTemplate("http://purl.org/np/RAFu2BNmgHrjOTJ8SKRnKaRp-VP8AOOb7xX88ob0DZRsU");
×
239
            }
240
            List<StatementItem> assertionStatements = new ArrayList<>();
×
241
            ValueFiller assertionFiller = new ValueFiller(n.getNanopub(), ContextType.ASSERTION, false);
×
242
            TemplateContext context = new TemplateContext(ContextType.ASSERTION, assertionTemplate.getId(), "assertion-statement", n.getNanopub());
×
243
            populateStatementItemList(context, assertionFiller, assertionStatements);
×
244

245
            assertion.add(createStatementView("assertion-statements", assertionStatements));
×
246
            assertion.add(new DataView<Statement>("unused-assertion-statements", new ListDataProvider<Statement>(assertionFiller.getUnusedStatements())) {
×
247

248
                @Override
249
                protected void populateItem(Item<Statement> item) {
250
                    item.add(new TripleItem("unused-assertion-statement", item.getModelObject(), n.getNanopub(), null));
×
251
                }
×
252

253
            });
254
        }
255
        add(assertion);
×
256

257
        WebMarkupContainer provenance = new WebMarkupContainer("provenance");
×
258
        if (hideProvenance) {
×
259
            provenance.setVisible(false);
×
260
        } else {
261
            Template provenanceTemplate = td.getProvenanceTemplate(n.getNanopub());
×
262
            if (provenanceTemplate == null)
×
263
                provenanceTemplate = td.getTemplate("http://purl.org/np/RA3Jxq5JJjluUNEpiMtxbiIHa7Yt-w8f9FiyexEstD5R4");
×
264
            List<StatementItem> provenanceStatements = new ArrayList<>();
×
265
            ValueFiller provenanceFiller = new ValueFiller(n.getNanopub(), ContextType.PROVENANCE, false);
×
266
            TemplateContext prContext = new TemplateContext(ContextType.PROVENANCE, provenanceTemplate.getId(), "provenance-statement", n.getNanopub());
×
267
            populateStatementItemList(prContext, provenanceFiller, provenanceStatements);
×
268
            provenance.add(createStatementView("provenance-statements", provenanceStatements));
×
269
            provenance.add(new DataView<Statement>("unused-provenance-statements", new ListDataProvider<Statement>(provenanceFiller.getUnusedStatements())) {
×
270

271
                @Override
272
                protected void populateItem(Item<Statement> item) {
273
                    item.add(new TripleItem("unused-provenance-statement", item.getModelObject(), n.getNanopub(), null));
×
274
                }
×
275

276
            });
277
        }
278
        add(provenance);
×
279

280
        WebMarkupContainer pubInfo = new WebMarkupContainer("pubinfo");
×
281
        if (hidePubinfo) {
×
282
            pubInfo.setVisible(false);
×
283
        } else {
284
            ValueFiller pubinfoFiller = new ValueFiller(n.getNanopub(), ContextType.PUBINFO, false);
×
285

286
            // TODO We should do this better:
287
            List<String> pubinfoAuthorTemplateIds = new ArrayList<>();
×
288
            List<String> pubinfoTemplateIds = new ArrayList<>();
×
289
            for (IRI iri : td.getPubinfoTemplateIds(n.getNanopub())) {
×
290
                if (iri.stringValue().equals("https://w3id.org/np/RA16U9Wo30ObhrK1NzH7EsmVRiRtvEuEA_Dfc-u8WkUCA")) { // author list
×
291
                    pubinfoAuthorTemplateIds.add(iri.stringValue());
×
292
                } else if (iri.stringValue().equals("http://purl.org/np/RA4vTctL3Luaj8oI_sPiN7I_8xEnR_hkdz5gN7bCvZpNY")) { // authors
×
293
                    pubinfoAuthorTemplateIds.add(iri.stringValue());
×
294
                } else if (iri.stringValue().equals("http://purl.org/np/RAA2MfqdBCzmz9yVWjKLXNbyfBNcwsMmOqcNUxkk1maIM")) { // creator
×
295
                    pubinfoTemplateIds.add(0, iri.stringValue());
×
296
                } else {
297
                    pubinfoTemplateIds.add(iri.stringValue());
×
298
                }
299
            }
×
300
            pubinfoTemplateIds.addAll(0, pubinfoAuthorTemplateIds);
×
301
            pubinfoTemplateIds.add("https://w3id.org/np/RAXVsr624oEAJvCt1WZXoUJ90lFYC5LUMoYHgEUOwmrLw"); // user name
×
302
            pubinfoTemplateIds.add("https://w3id.org/np/RARJj78P72NR5edKOnu_f4ePE9NYYuW2m2pM-fEoobMBk"); // nanopub label
×
303
            pubinfoTemplateIds.add("https://w3id.org/np/RA8iXbwvOC7BwVHuvAhFV235j2582SyAYJ2sfov19ZOlg"); // nanopub type
×
304
            pubinfoTemplateIds.add("https://w3id.org/np/RALmzqHlrRfeTD8ESZdKFyDNYY6eFuyQ8GAe_4N5eVytc"); // timestamp
×
305
            pubinfoTemplateIds.add("https://w3id.org/np/RADVnztsdSc36ffAXTxiIdXpYEMLiJrRENqaJ2Qn2LX3Y"); // templates
×
306
            pubinfoTemplateIds.add("https://w3id.org/np/RAvqXPNKPf56b2226oqhKzARyvIhnpnTrRpLGC1cYweMw"); // introductions
×
307
            pubinfoTemplateIds.add("https://w3id.org/np/RAgIlomuR39mN-Z39bbv59-h2DgQBnLyNdL22YmOJ_VHM"); // labels from APIs
×
308
            pubinfoTemplateIds.add("https://w3id.org/np/RAoWx0AJvNw-WqkGgZO4k8udNCg6kMcGZARN3DgO_5TII"); // contributor names
×
309
            pubinfoTemplateIds.add("https://w3id.org/np/RAY_M7GUmyOTjXQbJArzhVVzQ5XvgHt0JR7h2LZo6TXvY"); // signature
×
310
            pubinfoTemplateIds.add("https://w3id.org/np/RA_TZ9tvF6sBewmbIGbTFguLOPUUS70huklacisZrYtYw"); // creation site
×
311
            pubinfoTemplateIds.add("https://w3id.org/np/RAE-zsHxw2VoE6emhSY_Fkr5p_li5Qb8FrREqUwdWdzyM"); // generic
×
312

313
            List<TemplateContext> contexts = new ArrayList<>();
×
314
            List<TemplateContext> genericContexts = new ArrayList<>();
×
315
            for (String s : pubinfoTemplateIds) {
×
316
                TemplateContext piContext = new TemplateContext(ContextType.PUBINFO, s, "pubinfo-statement", n.getNanopub());
×
317
                if (piContext.willMatchAnyTriple()) {
×
318
                    genericContexts.add(piContext);
×
319
                } else if (piContext.getTemplateId().equals("https://w3id.org/np/RAE-zsHxw2VoE6emhSY_Fkr5p_li5Qb8FrREqUwdWdzyM")) {
×
320
                    // TODO: This is a work-around; check why this template doesn't give true to willMatchAnyTriple()
321
                    genericContexts.add(piContext);
×
322
                } else {
323
                    contexts.add(piContext);
×
324
                }
325
            }
×
326
            contexts.addAll(genericContexts);  // make sure the generic one are at the end
×
327
            List<WebMarkupContainer> elements = new ArrayList<>();
×
328
            for (TemplateContext piContext : contexts) {
×
329
                WebMarkupContainer pubInfoElement = new WebMarkupContainer("pubinfo-element");
×
330
                List<StatementItem> pubinfoStatements = new ArrayList<>();
×
331
                populateStatementItemList(piContext, pubinfoFiller, pubinfoStatements);
×
332
                if (!pubinfoStatements.isEmpty()) {
×
333
                    pubInfoElement.add(createStatementView("pubinfo-statements", pubinfoStatements));
×
334
                    elements.add(pubInfoElement);
×
335
                }
336
            }
×
337
            pubInfo.add(new DataView<WebMarkupContainer>("pubinfo-elements", new ListDataProvider<WebMarkupContainer>(elements)) {
×
338

339
                @Override
340
                protected void populateItem(Item<WebMarkupContainer> item) {
341
                    item.add(item.getModelObject());
×
342
                }
×
343

344
            });
345
        }
346
        add(pubInfo);
×
347

348
        isInitialized = true;
×
349
    }
×
350

351
    /**
352
     * Hides the provenance part of the nanopub item.
353
     *
354
     * @return this NanopubItem instance for method chaining
355
     */
356
    public NanopubItem hideProvenance() {
357
        if (isInitialized) throw new RuntimeException("Nanopub item is already initialized");
×
358
        hideProvenance = true;
×
359
        return this;
×
360
    }
361

362
    /**
363
     * Sets whether the provenance part of the nanopub item should be hidden.
364
     *
365
     * @param hideProvenance true to hide provenance, false to show it
366
     * @return this NanopubItem instance for method chaining
367
     */
368
    public NanopubItem setProvenanceHidden(boolean hideProvenance) {
369
        if (isInitialized) throw new RuntimeException("Nanopub item is already initialized");
3!
370
        this.hideProvenance = hideProvenance;
3✔
371
        return this;
2✔
372
    }
373

374
    /**
375
     * Hides the pubinfo part of the nanopub item.
376
     *
377
     * @return this NanopubItem instance for method chaining
378
     */
379
    public NanopubItem hidePubinfo() {
380
        if (isInitialized) throw new RuntimeException("Nanopub item is already initialized");
×
381
        hidePubinfo = true;
×
382
        return this;
×
383
    }
384

385
    /**
386
     * Sets whether the pubinfo part of the nanopub item should be hidden.
387
     *
388
     * @param hidePubinfo true to hide pubinfo, false to show it
389
     * @return this NanopubItem instance for method chaining
390
     */
391
    public NanopubItem setPubinfoHidden(boolean hidePubinfo) {
392
        if (isInitialized) throw new RuntimeException("Nanopub item is already initialized");
3!
393
        this.hidePubinfo = hidePubinfo;
3✔
394
        return this;
2✔
395
    }
396

397
    /**
398
     * Hides the header part of the nanopub item.
399
     *
400
     * @return this NanopubItem instance for method chaining
401
     */
402
    public NanopubItem hideHeader() {
403
        if (isInitialized) throw new RuntimeException("Nanopub item is already initialized");
×
404
        hideHeader = true;
×
405
        return this;
×
406
    }
407

408
    /**
409
     * Sets whether the header part of the nanopub item should be hidden.
410
     *
411
     * @param hideHeader true to hide header, false to show it
412
     * @return this NanopubItem instance for method chaining
413
     */
414
    public NanopubItem setHeaderHidden(boolean hideHeader) {
415
        if (isInitialized) throw new RuntimeException("Nanopub item is already initialized");
3!
416
        this.hideHeader = hideHeader;
3✔
417
        return this;
2✔
418
    }
419

420
    /**
421
     * Hides the footer part of the nanopub item.
422
     *
423
     * @return this NanopubItem instance for method chaining
424
     */
425
    public NanopubItem hideFooter() {
426
        if (isInitialized) throw new RuntimeException("Nanopub item is already initialized");
×
427
        hideFooter = true;
×
428
        return this;
×
429
    }
430

431
    /**
432
     * Sets whether the footer part of the nanopub item should be hidden.
433
     *
434
     * @param hideFooter true to hide footer, false to show it
435
     * @return this NanopubItem instance for method chaining
436
     */
437
    public NanopubItem setFooterHidden(boolean hideFooter) {
438
        if (isInitialized) throw new RuntimeException("Nanopub item is already initialized");
3!
439
        this.hideFooter = hideFooter;
3✔
440
        return this;
2✔
441
    }
442

443
    /**
444
     * Sets the nanopub item to a minimal state, hiding assertion, action menu, provenance, and pubinfo.
445
     *
446
     * @return this NanopubItem instance for method chaining
447
     */
448
    public NanopubItem setMinimal() {
449
        if (isInitialized) throw new RuntimeException("Nanopub item is already initialized");
×
450
        this.hideAssertion = true;
×
451
        this.hideActionMenu = true;
×
452
        setProvenanceHidden(true).setPubinfoHidden(true);
×
453
        return this;
×
454
    }
455

456
    /**
457
     * Adds the given actions to the nanopub item.
458
     *
459
     * @param a a {@link com.knowledgepixels.nanodash.action.NanopubAction} object
460
     * @return this NanopubItem instance for method chaining
461
     */
462
    public NanopubItem addActions(NanopubAction... a) {
463
        if (isInitialized) throw new RuntimeException("Nanopub item is already initialized");
×
464
        if (actions == null) actions = new ArrayList<>();
×
465
        for (NanopubAction na : a) {
×
466
            actions.add(na);
×
467
        }
468
        return this;
×
469
    }
470

471
    /**
472
     * Sets the nanopub item to have no actions.
473
     *
474
     * @return this NanopubItem instance for method chaining
475
     */
476
    public NanopubItem noActions() {
477
        if (isInitialized) throw new RuntimeException("Nanopub item is already initialized");
×
478
        actions = new ArrayList<>();
×
479
        return this;
×
480
    }
481

482
    /**
483
     * {@inheritDoc}
484
     */
485
    @Override
486
    protected void onBeforeRender() {
487
        initialize();
×
488
        super.onBeforeRender();
×
489
    }
×
490

491
    private void populateStatementItemList(TemplateContext context, ValueFiller filler, List<StatementItem> list) {
492
        context.initStatements();
×
493
        if (signerId != null) {
×
494
            context.getComponentModels().put(NTEMPLATE.CREATOR_PLACEHOLDER, Model.of(signerId.stringValue()));
×
495
        }
496
        filler.fill(context);
×
497
        for (StatementItem si : context.getStatementItems()) {
×
498
            if (si.isMatched()) {
×
499
                list.add(si);
×
500
            }
501
        }
×
502
    }
×
503

504
    private DataView<StatementItem> createStatementView(String elementId, List<StatementItem> list) {
505
        return new DataView<StatementItem>(elementId, new ListDataProvider<StatementItem>(list)) {
×
506

507
            @Override
508
            protected void populateItem(Item<StatementItem> item) {
509
                item.add(item.getModelObject());
×
510
            }
×
511

512
        };
513
    }
514

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