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

knowledgepixels / nanodash / 18970010046

31 Oct 2025 10:37AM UTC coverage: 14.282% (-0.02%) from 14.299%
18970010046

push

github

ashleycaselli
fix(NanopubItem): remove 'retract' option from UI for retraction nanopubs

Closes #268

512 of 4514 branches covered (11.34%)

Branch coverage included in aggregate %.

1331 of 8390 relevant lines covered (15.86%)

0.71 hits per line

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

7.56
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.page.ListPage;
7
import com.knowledgepixels.nanodash.page.UserPage;
8
import com.knowledgepixels.nanodash.template.*;
9
import org.apache.wicket.markup.html.WebMarkupContainer;
10
import org.apache.wicket.markup.html.basic.Label;
11
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
12
import org.apache.wicket.markup.html.panel.Panel;
13
import org.apache.wicket.markup.repeater.Item;
14
import org.apache.wicket.markup.repeater.data.DataView;
15
import org.apache.wicket.markup.repeater.data.ListDataProvider;
16
import org.apache.wicket.model.Model;
17
import org.apache.wicket.request.mapper.parameter.PageParameters;
18
import org.eclipse.rdf4j.model.IRI;
19
import org.eclipse.rdf4j.model.Statement;
20
import org.nanopub.SimpleCreatorPattern;
21
import org.nanopub.extra.security.MalformedCryptoElementException;
22
import org.nanopub.extra.security.SignatureUtils;
23
import org.nanopub.vocabulary.NPX;
24
import org.nanopub.vocabulary.NTEMPLATE;
25
import org.slf4j.Logger;
26
import org.slf4j.LoggerFactory;
27

28
import java.text.SimpleDateFormat;
29
import java.util.*;
30

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

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

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

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

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

81
    private void initialize() {
82
        if (isInitialized) return;
×
83

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

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

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

137
            });
138
            add(header);
×
139
        }
140

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

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

174
            PageParameters params = new PageParameters();
×
175

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

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

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

222
        final TemplateData td = TemplateData.get();
×
223

224
        WebMarkupContainer assertion = new WebMarkupContainer("assertion");
×
225

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

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

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

247
            });
248
        }
249
        add(assertion);
×
250

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

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

270
            });
271
        }
272
        add(provenance);
×
273

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

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

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

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

338
            });
339
        }
340
        add(pubInfo);
×
341

342
        isInitialized = true;
×
343
    }
×
344

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

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

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

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

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

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

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

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

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

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

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

476
    /**
477
     * {@inheritDoc}
478
     */
479
    @Override
480
    protected void onBeforeRender() {
481
        initialize();
×
482
        super.onBeforeRender();
×
483
    }
×
484

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

498
    private DataView<StatementItem> createStatementView(String elementId, List<StatementItem> list) {
499
        return new DataView<StatementItem>(elementId, new ListDataProvider<StatementItem>(list)) {
×
500

501
            @Override
502
            protected void populateItem(Item<StatementItem> item) {
503
                item.add(item.getModelObject());
×
504
            }
×
505

506
        };
507
    }
508

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