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

knowledgepixels / nanodash / 28794658420

06 Jul 2026 01:21PM UTC coverage: 28.458% (-0.05%) from 28.504%
28794658420

Pull #537

github

web-flow
Merge 0a65bcede into 5ef3629cc
Pull Request #537: fix: treat home resource context as plain Home in navigation

1811 of 7203 branches covered (25.14%)

Branch coverage included in aggregate %.

3713 of 12208 relevant lines covered (30.41%)

4.52 hits per line

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

41.3
src/main/java/com/knowledgepixels/nanodash/component/ReadonlyItem.java
1
package com.knowledgepixels.nanodash.component;
2

3
import com.knowledgepixels.nanodash.LocalUri;
4
import com.knowledgepixels.nanodash.NavigationContext;
5
import com.knowledgepixels.nanodash.RestrictedChoice;
6
import com.knowledgepixels.nanodash.domain.User;
7
import com.knowledgepixels.nanodash.Utils;
8
import com.knowledgepixels.nanodash.component.StatementItem.RepetitionGroup;
9
import com.knowledgepixels.nanodash.domain.IndividualAgent;
10
import com.knowledgepixels.nanodash.domain.MaintainedResource;
11
import com.knowledgepixels.nanodash.domain.Space;
12
import com.knowledgepixels.nanodash.page.ExplorePage;
13
import com.knowledgepixels.nanodash.repository.MaintainedResourceRepository;
14
import com.knowledgepixels.nanodash.repository.SpaceRepository;
15
import com.knowledgepixels.nanodash.template.ContextType;
16
import com.knowledgepixels.nanodash.template.Template;
17
import com.knowledgepixels.nanodash.template.UnificationException;
18
import net.trustyuri.TrustyUriUtils;
19
import org.apache.commons.codec.Charsets;
20
import org.apache.wicket.behavior.AttributeAppender;
21
import org.apache.wicket.markup.html.basic.Label;
22
import org.apache.wicket.markup.html.link.ExternalLink;
23
import org.apache.wicket.model.IModel;
24
import org.apache.wicket.model.Model;
25
import org.apache.wicket.validation.IValidatable;
26
import org.apache.wicket.validation.IValidator;
27
import org.apache.wicket.validation.Validatable;
28
import org.apache.wicket.validation.ValidationError;
29
import org.eclipse.rdf4j.common.net.ParsedIRI;
30
import org.eclipse.rdf4j.model.IRI;
31
import org.eclipse.rdf4j.model.Literal;
32
import org.eclipse.rdf4j.model.Value;
33
import org.eclipse.rdf4j.model.ValueFactory;
34
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
35
import org.eclipse.rdf4j.model.util.Literals;
36
import org.eclipse.rdf4j.model.vocabulary.XSD;
37
import org.nanopub.Nanopub;
38
import org.nanopub.NanopubUtils;
39
import org.nanopub.SimpleCreatorPattern;
40
import org.nanopub.vocabulary.NTEMPLATE;
41
import org.slf4j.Logger;
42
import org.slf4j.LoggerFactory;
43

44
import java.net.URISyntaxException;
45
import java.net.URLEncoder;
46
import java.util.HashMap;
47
import java.util.Map;
48

49
/**
50
 * ReadonlyItem is a component that displays a read-only item in the form.
51
 */
52
public class ReadonlyItem extends AbstractContextComponent {
53

54
    private static final int LONG_LITERAL_LENGTH = 100;
55
    private static final Logger logger = LoggerFactory.getLogger(ReadonlyItem.class);
9✔
56
    private static final ValueFactory vf = SimpleValueFactory.getInstance();
9✔
57

58
    private IModel<String> model;
59
    private String prefix;
60
    private ExternalLink linkComp;
61
    private Label extraComp, languageComp, datatypeComp;
62
    private IModel<String> extraModel, languageModel, datatypeModel;
63
    private IRI iri;
64
    private RestrictedChoice restrictedChoice;
65
    private Label showMoreLabelLiteral, showMoreLabelHTML;
66
    private final Template template;
67

68
    /**
69
     * Constructor for ReadonlyItem.
70
     *
71
     * @param id              the component id
72
     * @param parentId        the parent id (e.g., "subj", "obj")
73
     * @param iriP            the IRI of the item
74
     * @param statementPartId the statement part ID
75
     * @param rg              the repetition group
76
     */
77
    public ReadonlyItem(String id, String parentId, final IRI iriP, IRI statementPartId, final RepetitionGroup rg) {
78
        super(id, rg.getContext());
15✔
79
        this.iri = iriP;
9✔
80
        template = context.getTemplate();
15✔
81
        model = (IModel<String>) context.getComponentModels().get(iri);
27✔
82
        boolean modelIsNew = false;
6✔
83
        if (model == null) {
9✔
84
            model = Model.of("");
12✔
85
            context.getComponentModels().put(iri, model);
27✔
86
            modelIsNew = true;
6✔
87
        }
88
        String postfix = Utils.getUriPostfix(iri);
12✔
89
        if (modelIsNew && context.hasParam(postfix)) {
21!
90
            model.setObject(context.getParam(postfix));
×
91
        }
92
        if (model.getObject().isEmpty() && template.isRootNanopubPlaceholder(iri) && context.getReferenceNanopub() == null) {
36!
93
            model.setObject(LocalUri.of("nanopub").stringValue());
×
94
        }
95

96
        final Map<String, String> foafNameMap;
97
        if (context.getExistingNanopub() == null) {
12✔
98
            foafNameMap = new HashMap<>();
15✔
99
        } else {
100
            foafNameMap = Utils.getFoafNameMap(context.getExistingNanopub());
15✔
101
        }
102

103
        prefix = template.getPrefix(iri);
21✔
104
        if (prefix == null) prefix = "";
18!
105
        if (template.isRestrictedChoicePlaceholder(iri)) {
18✔
106
            restrictedChoice = new RestrictedChoice(iri, context);
27✔
107
        }
108
        add(new Label("prefix", new Model<String>() {
90✔
109

110
            @Override
111
            public String getObject() {
112
                String prefixLabel = template.getPrefixLabel(iri);
×
113
                String v = getFullValue();
×
114
                if (prefixLabel == null || IndividualAgent.isUser(v) || foafNameMap.containsKey(v)) {
×
115
                    return "";
×
116
                } else if (prefixLabel.matches("https?://.*")) {
×
117
                    // Hide prefix label that leaks through as a raw URL.
118
                    return "";
×
119
                } else {
120
                    if (!prefixLabel.isEmpty() && parentId.equals("subj")) {
×
121
                        // Capitalize first letter of label if at subject position:
122
                        prefixLabel = prefixLabel.substring(0, 1).toUpperCase() + prefixLabel.substring(1);
×
123
                    }
124
                    return prefixLabel;
×
125
                }
126
            }
127

128
        }));
129

130
        linkComp = new ExternalLink("link", new Model<String>() {
63✔
131

132
            @Override
133
            public String getObject() {
134
                String obj = getFullValue();
12✔
135
                if (obj == null) return "";
6!
136
                if (obj.equals(LocalUri.of("nanopub").stringValue())) {
18!
137
                    if (context.getExistingNanopub() != null) {
×
138
                        obj = context.getExistingNanopub().getUri().stringValue();
×
139
                        return ExplorePage.MOUNT_PATH + "?id=" + URLEncoder.encode(obj, Charsets.UTF_8);
×
140
                    } else {
141
                        return "";
×
142
                    }
143
                } else if (obj.equals(LocalUri.of("assertion").stringValue())) {
18!
144
                    if (context.getExistingNanopub() != null) {
×
145
                        obj = context.getExistingNanopub().getAssertionUri().stringValue();
×
146
                        return ExplorePage.MOUNT_PATH + "?id=" + URLEncoder.encode(obj, Charsets.UTF_8);
×
147
                    } else {
148
                        return "";
×
149
                    }
150
                } else if (obj.matches("https?://.+")) {
12!
151
                    return NanodashLink.getPageUrl(obj);
×
152
                } else {
153
                    return "";
6✔
154
                }
155
            }
156

157
        }, new Model<String>() {
27✔
158

159
            @Override
160
            public String getObject() {
161
                String obj = getFullValue();
×
162
                if (rootResolvesToThisNanopub()) {
×
163
                    // No prior value migrated (e.g. supersede with a newer template that added this slot),
164
                    // or we are deriving. Either way the root resolves to the new nanopub in
165
                    // TemplateContext.processValue, so surface that to the user in the form.
166
                    return "this nanopublication";
×
167
                }
168
                if (obj != null && obj.equals(LocalUri.of("nanopub").stringValue())) {
×
169
                    return "this nanopublication";
×
170
                }
171
                if (obj != null && obj.equals(LocalUri.of("assertion").stringValue())) {
×
172
                    return context.getType() == ContextType.ASSERTION ? "this assertion" : "the assertion above";
×
173
                }
174
                if (obj != null && obj.matches("https?://.+")) {
×
175
                    IRI objIri = vf.createIRI(obj);
×
176
                    if (iri.equals(NTEMPLATE.CREATOR_PLACEHOLDER)) {
×
177
                        // TODO We might want to introduce a "(you)" flag here at some point
178
                        return User.getShortDisplayName(objIri);
×
179
                    } else if (isAssertionValue(objIri)) {
×
180
                        if (context.getType() == ContextType.ASSERTION) {
×
181
                            return "this assertion";
×
182
                        } else {
183
                            return "the assertion above";
×
184
                        }
185
                    } else if (isNanopubValue(objIri)) {
×
186
                        return "this nanopublication";
×
187
                    } else if (IndividualAgent.isUser(obj)) {
×
188
                        return User.getShortDisplayName(objIri);
×
189
                    } else if (foafNameMap.containsKey(obj)) {
×
190
                        return foafNameMap.get(obj);
×
191
                    }
192
                    Space space = SpaceRepository.get().findById(obj);
×
193
                    if (space != null) return Utils.truncateLinkLabel(space.getLabel());
×
194
                    space = SpaceRepository.get().findByAltId(obj);
×
195
                    if (space != null) return Utils.truncateLinkLabel(space.getLabel());
×
196
                    MaintainedResource mr = MaintainedResourceRepository.get().findById(obj);
×
197
                    if (mr != null) return Utils.truncateLinkLabel(mr.getLabel());
×
198
                    return Utils.truncateLinkLabel(getLabelString(objIri));
×
199
                }
200
                return obj;
×
201
            }
202

203
        });
204
        if (template.isIntroducedResource(iri) || template.isEmbeddedResource(iri)) {
36!
205
            linkComp.add(AttributeAppender.append("class", "introduced"));
×
206
        }
207
        linkComp.add(NavigationContext.hrefContextFallback());
30✔
208
        add(linkComp);
30✔
209
        add(new Label("description", new Model<String>() {
66✔
210

211
            @Override
212
            public String getObject() {
213
                String obj = getFullValue();
×
214
                if (rootResolvesToThisNanopub()) {
×
215
                    return "This is the identifier for this whole nanopublication.";
×
216
                }
217
                if (obj != null && obj.matches("https?://.+")) {
×
218
                    IRI objIri = vf.createIRI(obj);
×
219
                    if (isAssertionValue(objIri)) {
×
220
                        return "This is the identifier for the assertion of this nanopublication.";
×
221
                    } else if (isNanopubValue(objIri)) {
×
222
                        return "This is the identifier for this whole nanopublication.";
×
223
                    } else if (context.isReadOnly() && obj.startsWith(context.getExistingNanopub().getUri().stringValue())) {
×
224
                        return "This is a local identifier minted within the nanopublication.";
×
225
                    }
226
                    String labelString = getLabelString(objIri);
×
227
                    String description = "";
×
228
                    if (labelString.contains(" - ")) description = labelString.replaceFirst("^.* - ", "");
×
229
                    return description;
×
230
                } else if (obj != null && obj.startsWith("\"")) {
×
231
                    return "(this is a literal)";
×
232
                }
233
                return "";
×
234
            }
235

236
        }));
237
        Model<String> uriModel = new Model<String>() {
33✔
238

239
            @Override
240
            public String getObject() {
241
                String obj = getFullValue();
×
242
                if (rootResolvesToThisNanopub()) {
×
243
                    return LocalUri.of("nanopub").stringValue();
×
244
                }
245
                if (obj != null && obj.startsWith("\"")) return "";
×
246
                if (isAssertionValue(obj)) {
×
247
                    return getAssertionValue();
×
248
                } else if (isNanopubValue(obj)) {
×
249
                    return getNanopubValue();
×
250
                }
251
                return obj;
×
252
            }
253

254
        };
255
        add(Utils.getUriLink("uri", uriModel));
33✔
256
        extraModel = Model.of("");
12✔
257
        extraComp = new Label("extra", extraModel);
24✔
258
        extraComp.setVisible(false);
15✔
259
        add(extraComp);
30✔
260
        languageModel = Model.of("");
12✔
261
        languageComp = new Label("language", languageModel);
24✔
262
        languageComp.setVisible(false);
15✔
263
        add(languageComp);
30✔
264
        datatypeModel = Model.of("");
12✔
265
        datatypeComp = new Label("datatype", datatypeModel);
24✔
266
        datatypeComp.setVisible(false);
15✔
267
        add(datatypeComp);
30✔
268

269
        showMoreLabelLiteral = new Label("show-more-literal", "");
21✔
270
        add(showMoreLabelLiteral);
30✔
271
        showMoreLabelLiteral.setVisible(false);
15✔
272

273
        showMoreLabelHTML = new Label("show-more-html", "");
21✔
274
        add(showMoreLabelHTML);
30✔
275
        showMoreLabelHTML.setVisible(false);
15✔
276
    }
3✔
277

278
    /**
279
     * {@inheritDoc}
280
     */
281
    @Override
282
    public void fillFinished() {
283
        String obj = getFullValue();
9✔
284
        if (obj != null) {
6!
285
            if (isAssertionValue(obj)) {
12!
286
                linkComp.add(new AttributeAppender("class", "this-assertion"));
×
287
            } else if (isNanopubValue(obj)) {
12!
288
                linkComp.add(new AttributeAppender("class", "this-nanopub"));
×
289
            } else if (context.getExistingNanopub() != null) {
12!
290
                Nanopub np = context.getExistingNanopub();
12✔
291
                if (NanopubUtils.getIntroducedIriIds(np).contains(obj) || NanopubUtils.getEmbeddedIriIds(np).contains(obj)) {
30!
292
                    linkComp.add(AttributeAppender.append("class", "introduced"));
×
293
                }
294
            }
295
        }
296
    }
3✔
297

298
    /**
299
     * {@inheritDoc}
300
     */
301
    @Override
302
    public void finalizeValues() {
303
    }
3✔
304

305
    private String getLabelString(IRI iri) {
306
        if (template.getLabel(iri) != null) {
×
307
            return template.getLabel(iri).replaceFirst(" - .*$", "");
×
308
        } else if (context.getLabel(iri) != null) {
×
309
            return context.getLabel(iri).replaceFirst(" - .*$", "");
×
310
        } else {
311
            return Utils.getShortNameFromURI(iri.stringValue());
×
312
        }
313
    }
314

315
    /**
316
     * {@inheritDoc}
317
     */
318
    @Override
319
    public void removeFromContext() {
320
        // Nothing to be done here.
321
    }
3✔
322

323
    private String getFullValue() {
324
        String s = model.getObject();
15✔
325
        if (s == null) return null;
6!
326
        if (template.isAutoEscapePlaceholder(iri)) {
18!
327
            s = Utils.urlEncode(s);
×
328
        }
329
        if (!prefix.isEmpty()) {
12!
330
            s = prefix + s;
×
331
        }
332
        return s;
6✔
333
    }
334

335
    // True when the root-nanopub placeholder will resolve to the new nanopub itself:
336
    // either no prior root value was migrated, or we are deriving (which resets the root
337
    // to the new nanopub, see TemplateContext.processValue / issue #527).
338
    private boolean rootResolvesToThisNanopub() {
339
        if (!template.isRootNanopubPlaceholder(iri)) return false;
×
340
        String obj = getFullValue();
×
341
        return obj == null || obj.isEmpty() || context.getFillMode() == PublishForm.FillMode.DERIVE;
×
342
    }
343

344
    private boolean isNanopubValue(Object obj) {
345
        if (obj == null) return false;
6!
346
        if (obj.toString().equals(LocalUri.of("nanopub").stringValue())) return true;
21!
347
        // A fillSource match means a *prior* nanopub (supersede/derive), not "this" one — don't label it as such.
348
        if (context.getExistingNanopub() == null) return false;
12!
349
        return obj.toString().equals(context.getExistingNanopub().getUri().stringValue());
27✔
350
    }
351

352
    private String getNanopubValue() {
353
        Nanopub ref = context.getReferenceNanopub();
×
354
        if (ref != null) {
×
355
            return ref.getUri().stringValue();
×
356
        } else {
357
            return LocalUri.of("nanopub").stringValue();
×
358
        }
359
    }
360

361
    private boolean isAssertionValue(Object obj) {
362
        if (obj == null) return false;
6!
363
        if (obj.toString().equals(LocalUri.of("assertion").stringValue())) return true;
21!
364
        // A fillSource match means a *prior* assertion (supersede/derive), not "this" one.
365
        if (context.getExistingNanopub() == null) return false;
12!
366
        return obj.toString().equals(context.getExistingNanopub().getAssertionUri().stringValue());
27✔
367
    }
368

369
    private String getAssertionValue() {
370
        Nanopub ref = context.getReferenceNanopub();
×
371
        if (ref != null) {
×
372
            return ref.getAssertionUri().stringValue();
×
373
        } else {
374
            return LocalUri.of("assertion").stringValue();
×
375
        }
376
    }
377

378
    /**
379
     * {@inheritDoc}
380
     */
381
    @Override
382
    public boolean isUnifiableWith(Value v) {
383
        if (v == null) return true;
6!
384
        if (v instanceof IRI) {
9✔
385
            String vs = v.stringValue();
9✔
386
            if (vs.equals(LocalUri.of("nanopub").stringValue())) {
18!
387
                vs = getNanopubValue();
×
388
            } else if (vs.equals(LocalUri.of("assertion").stringValue())) {
18!
389
                vs = getAssertionValue();
×
390
            }
391
            if (vs.startsWith(prefix)) vs = vs.substring(prefix.length());
33!
392
//                        if (Utils.isLocalURI(vs)) vs = vs.replaceFirst("^" + LocalUri.PREFIX, "");
393
            if (template.isAutoEscapePlaceholder(iri)) {
18!
394
                vs = Utils.urlDecode(vs);
×
395
            }
396
            Validatable<String> validatable = new Validatable<>(vs);
15✔
397
//                        if (template.isLocalResource(iri) && !Utils.isUriPostfix(vs)) {
398
//                                vs = Utils.getUriPostfix(vs);
399
//                        }
400
            new Validator().validate(validatable);
18✔
401
            if (!validatable.isValid()) {
9✔
402
                return false;
6✔
403
            }
404
            if (model.getObject().isEmpty()) {
18✔
405
                return true;
6✔
406
            }
407
            return vs.equals(model.getObject());
18✔
408
        } else if (v instanceof Literal vL) {
18!
409
            if (template.getRegex(iri) != null && !v.stringValue().matches(template.getRegex(iri))) {
18!
410
                return false;
×
411
            }
412
            String languagetag = template.getLanguageTag(iri);
18✔
413
            IRI datatype = template.getDatatype(iri);
18✔
414
            if (languagetag != null) {
6!
415
                if (vL.getLanguage().isEmpty() || !Literals.normalizeLanguageTag(vL.getLanguage().get()).equals(languagetag)) {
×
416
                    return false;
×
417
                }
418
            } else if (datatype != null) {
6!
419
                if (!vL.getDatatype().equals(datatype)) {
×
420
                    return false;
×
421
                }
422
            }
423
            if (linkComp.getDefaultModelObject() == null || linkComp.getDefaultModelObject().toString().isEmpty()) {
30!
424
                return true;
6✔
425
            }
426
            return linkComp.getDefaultModelObject().equals("\"" + v.stringValue() + "\"");
×
427
        }
428
        return false;
×
429
    }
430

431
    /**
432
     * {@inheritDoc}
433
     */
434
    @Override
435
    public void unifyWith(Value v) throws UnificationException {
436
        if (v == null) return;
6!
437
        String vs = v.stringValue();
9✔
438
        if (!isUnifiableWith(v)) {
12!
439
            logger.error("Cannot unify {}", v);
×
440
            throw new UnificationException(vs);
×
441
        }
442
        if (v instanceof IRI) {
9✔
443
            if (vs.equals(LocalUri.of("nanopub").stringValue())) {
18!
444
                vs = getNanopubValue();
×
445
            } else if (vs.equals(LocalUri.of("assertion").stringValue())) {
18!
446
                vs = getAssertionValue();
×
447
            }
448
            if (!prefix.isEmpty() && vs.startsWith(prefix)) {
12!
449
                vs = vs.substring(prefix.length());
×
450
                // With read-only items, we don't need preliminary local identifiers:
451
//                        } else if (Utils.isLocalURI(vs)) {
452
//                                vs = vs.replaceFirst("^" + LocalUri.PREFIX, "");
453
//                        } else if (template.isLocalResource(iri) && !Utils.isUriPostfix(vs)) {
454
//                                vs = Utils.getUriPostfix(vs);
455
            }
456
            if (template.isAutoEscapePlaceholder(iri)) {
18!
457
                vs = Utils.urlDecode(vs);
×
458
            }
459
            model.setObject(vs);
15✔
460
        } else if (v instanceof Literal vL) {
18!
461
            if (vs.length() >= LONG_LITERAL_LENGTH) {
12✔
462
                linkComp.add(AttributeAppender.append("class", "long-literal collapsed"));
36✔
463
                showMoreLabelLiteral.setVisible(true);
15✔
464
            }
465
            if (vL.getLanguage().isPresent()) {
12!
466
                model.setObject("\"" + vs + "\"");
×
467
                languageModel.setObject("(" + Literals.normalizeLanguageTag(vL.getLanguage().get()) + ")");
×
468
                languageComp.setVisible(true);
×
469
            } else if (!vL.getDatatype().equals(XSD.STRING)) {
15!
470
                model.setObject("\"" + vs + "\"");
×
471
                datatypeModel.setObject("(" + vL.getDatatype().stringValue().replace(XSD.NAMESPACE, "xsd:") + ")");
×
472
                datatypeComp.setVisible(true);
×
473
            } else {
474
                model.setObject("\"" + vs + "\"");
15✔
475
            }
476
            if (Utils.looksLikeHtml(vs)) {
9✔
477
                linkComp.setVisible(false);
15✔
478
                extraModel.setObject(Utils.sanitizeHtml(vs));
15✔
479
                extraComp.setEscapeModelStrings(false);
15✔
480
                extraComp.setVisible(true);
15✔
481
                showMoreLabelLiteral.setVisible(false);
15✔
482
                showMoreLabelHTML.setVisible(true);
15✔
483
            }
484
        }
485
    }
3✔
486

487
    /**
488
     * Validator class for validating the input.
489
     */
490
    protected class Validator extends InvalidityHighlighting implements IValidator<String> {
491

492
        /**
493
         * Default constructor for Validator.
494
         */
495
        public Validator() {
15✔
496
        }
3✔
497

498
        @Override
499
        public void validate(IValidatable<String> s) {
500
            String sv = s.getValue();
12✔
501
            String p = prefix;
12✔
502
            if (template.isAutoEscapePlaceholder(iri)) {
24!
503
                sv = Utils.urlEncode(sv);
×
504
            }
505
            if (sv.matches("https?://.+")) {
12!
506
                p = "";
9✔
507
            } else if (sv.contains(":")) {
×
508
                s.error(new ValidationError("Colon character is not allowed in postfix"));
×
509
            }
510
            String iriString = p + sv;
12✔
511
            if (iriString.matches("[^:# ]+")) {
12!
512
                p = LocalUri.PREFIX;
×
513
                iriString = p + sv;
×
514
            }
515
            try {
516
                ParsedIRI piri = new ParsedIRI(iriString);
15✔
517
                if (!piri.isAbsolute()) {
9!
518
                    s.error(new ValidationError("IRI not well-formed"));
×
519
                }
520
                if (p.isEmpty() && !Utils.isLocalURI(sv) && !sv.matches("https?://.+")) {
30!
521
                    s.error(new ValidationError("Only http(s):// IRIs are allowed here"));
×
522
                }
523
            } catch (URISyntaxException ex) {
×
524
                s.error(new ValidationError("IRI not well-formed"));
×
525
            }
3✔
526
            String regex = template.getRegex(iri);
24✔
527
            if (regex != null) {
6!
528
                if (!sv.matches(regex)) {
×
529
                    s.error(new ValidationError("Value '" + sv + "' doesn't match the pattern '" + regex + "'"));
×
530
                }
531
            }
532
            if (template.isRestrictedChoicePlaceholder(iri)) {
24✔
533
                if (!restrictedChoice.getPossibleValues().contains(iriString) && !restrictedChoice.hasPossibleRefValues()) {
36✔
534
                    // not checking the possible ref values can overgenerate, but normally works
535
                    s.error(new ValidationError("Invalid choice"));
18✔
536
                }
537
            }
538
            if (template.isExternalUriPlaceholder(iri)) {
24!
539
                if (!iriString.matches("https?://.+")) {
×
540
                    s.error(new ValidationError("Not an external IRI"));
×
541
                }
542
            }
543
            if (template.isTrustyUriPlaceholder(iri)) {
24!
544
                if (!TrustyUriUtils.isPotentialTrustyUri(iriString)) {
×
545
                    s.error(new ValidationError("Not a trusty URI"));
×
546
                }
547
            }
548
            if (iri.equals(NTEMPLATE.CREATOR_PLACEHOLDER) && context.getExistingNanopub() != null) {
18!
549
                boolean found = false;
×
550
                for (IRI creator : SimpleCreatorPattern.getCreators(context.getExistingNanopub())) {
×
551
                    if (creator.stringValue().equals(iriString)) {
×
552
                        found = true;
×
553
                        break;
×
554
                    }
555
                }
×
556
                if (!found) {
×
557
                    s.error(new ValidationError("Not a creator of nanopub"));
×
558
                }
559
            }
560
        }
3✔
561

562
    }
563

564
    /**
565
     * <p>toString.</p>
566
     *
567
     * @return a {@link java.lang.String} object
568
     */
569
    public String toString() {
570
        return "[read-only IRI item: " + iri + "]";
×
571
    }
572

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