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

knowledgepixels / nanodash / 22679314407

04 Mar 2026 04:42PM UTC coverage: 15.81% (-0.1%) from 15.951%
22679314407

Pull #372

github

web-flow
Merge 62604b6f9 into bf50833e3
Pull Request #372: Add component for showing full URIs as plain links + ExploreDisplayMenu

701 of 5379 branches covered (13.03%)

Branch coverage included in aggregate %.

1727 of 9978 relevant lines covered (17.31%)

2.37 hits per line

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

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

3
import com.knowledgepixels.nanodash.*;
4
import com.knowledgepixels.nanodash.action.NanopubAction;
5
import com.knowledgepixels.nanodash.action.RetractionAction;
6
import com.knowledgepixels.nanodash.component.menu.ActionMenu;
7
import com.knowledgepixels.nanodash.domain.User;
8
import com.knowledgepixels.nanodash.page.ListPage;
9
import com.knowledgepixels.nanodash.page.UserPage;
10
import com.knowledgepixels.nanodash.template.*;
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.NPX;
26
import org.nanopub.vocabulary.NTEMPLATE;
27
import org.slf4j.Logger;
28
import org.slf4j.LoggerFactory;
29

30
import java.text.SimpleDateFormat;
31
import java.util.*;
32

33
/**
34
 * A panel that displays a nanopublication with its header, footer, assertion, provenance, and pubinfo.
35
 */
36
public class NanopubItem extends Panel {
37

38
    /**
39
     * Date format for displaying the creation date and time of the nanopub.
40
     */
41
    public static SimpleDateFormat simpleDateTimeFormat = new SimpleDateFormat("d MMM yyyy, HH:mm:ss zzz");
15✔
42
    /**
43
     * Date format for displaying the creation time of the nanopub without time.
44
     */
45
    public static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("d MMM yyyy");
15✔
46

47
    private boolean isInitialized = false;
9✔
48
    private NanopubElement n;
49
    private boolean hideAssertion = false;
9✔
50
    private boolean hideProvenance = false;
9✔
51
    private boolean hidePubinfo = false;
9✔
52
    private boolean hideHeader = false;
9✔
53
    private boolean hideFooter = false;
9✔
54
    private boolean hideActionMenu = false;
9✔
55
    private List<NanopubAction> actions;
56
    private IRI signerId;
57
    private String templateId;
58
    private static final Logger logger = LoggerFactory.getLogger(NanopubItem.class);
12✔
59

60
    /**
61
     * Creates a NanopubItem panel.
62
     *
63
     * @param id         the Wicket component ID
64
     * @param n          the NanopubElement to display
65
     * @param templateId the ID of the template to use for rendering the assertion.
66
     */
67
    public NanopubItem(String id, NanopubElement n, String templateId) {
68
        super(id);
9✔
69
        this.n = n;
9✔
70
        this.templateId = templateId;
9✔
71
    }
3✔
72

73
    /**
74
     * Creates a NanopubItem panel with a default template ID.
75
     *
76
     * @param id the Wicket component ID
77
     * @param n  the NanopubElement to display
78
     */
79
    public NanopubItem(String id, NanopubElement n) {
80
        this(id, n, null);
×
81
    }
×
82

83
    private void initialize() {
84
        if (isInitialized) return;
×
85

86
        String pubkey = n.getPubkey();
×
87
        String pubkeyhash = n.getPubkeyhash();
×
88
        signerId = n.getSignerId();
×
89

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

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

139
            });
140
            add(header);
×
141
        }
142

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

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

176
            PageParameters params = new PageParameters();
×
177

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

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

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

224
        final TemplateData td = TemplateData.get();
×
225

226
        WebMarkupContainer assertion = new WebMarkupContainer("assertion");
×
227

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

241
            assertion.add(createStatementView("assertion-statements", assertionStatements));
×
242
            assertion.add(new DataView<Statement>("unused-assertion-statements", new ListDataProvider<Statement>(assertionFiller.getUnusedStatements())) {
×
243

244
                @Override
245
                protected void populateItem(Item<Statement> item) {
246
                    item.add(new TripleItem("unused-assertion-statement", item.getModelObject(), n.getNanopub(), null));
×
247
                }
×
248

249
            });
250
        }
251
        add(assertion);
×
252

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

267
                @Override
268
                protected void populateItem(Item<Statement> item) {
269
                    item.add(new TripleItem("unused-provenance-statement", item.getModelObject(), n.getNanopub(), null));
×
270
                }
×
271

272
            });
273
        }
274
        add(provenance);
×
275

276
        WebMarkupContainer pubInfo = new WebMarkupContainer("pubinfo");
×
277
        if (hidePubinfo) {
×
278
            pubInfo.setVisible(false);
×
279
        } else {
280
            ValueFiller pubinfoFiller = new ValueFiller(n.getNanopub(), ContextType.PUBINFO, false);
×
281

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

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

335
                @Override
336
                protected void populateItem(Item<WebMarkupContainer> item) {
337
                    item.add(item.getModelObject());
×
338
                }
×
339

340
            });
341
        }
342
        add(pubInfo);
×
343

344
        isInitialized = true;
×
345
    }
×
346

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

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

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

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

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

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

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

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

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

452
    /**
453
     * Adds the given actions to the nanopub item.
454
     *
455
     * @param a a {@link NanopubAction} object
456
     * @return this NanopubItem instance for method chaining
457
     */
458
    public NanopubItem addActions(NanopubAction... a) {
459
        if (isInitialized) {
×
460
            throw new RuntimeException("Nanopub item is already initialized");
×
461
        }
462
        if (actions == null) {
×
463
            actions = new ArrayList<>();
×
464
        }
465
        actions.addAll(Arrays.asList(a));
×
466
        return this;
×
467
    }
468

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

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

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

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

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

510
        };
511
    }
512

513
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc