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

knowledgepixels / nanodash / 19235243637

10 Nov 2025 02:36PM UTC coverage: 13.754% (-0.6%) from 14.373%
19235243637

push

github

tkuhn
feat(ViewDisplay): Support for specifying width and structural position

514 of 4708 branches covered (10.92%)

Branch coverage included in aggregate %.

1329 of 8692 relevant lines covered (15.29%)

0.68 hits per line

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

32.55
src/main/java/com/knowledgepixels/nanodash/Space.java
1
package com.knowledgepixels.nanodash;
2

3
import static com.knowledgepixels.nanodash.Utils.vf;
4

5
import java.io.Serializable;
6
import java.util.ArrayList;
7
import java.util.Calendar;
8
import java.util.Collections;
9
import java.util.HashMap;
10
import java.util.HashSet;
11
import java.util.List;
12
import java.util.Map;
13
import java.util.Set;
14

15
import org.eclipse.rdf4j.model.IRI;
16
import org.eclipse.rdf4j.model.Literal;
17
import org.eclipse.rdf4j.model.Statement;
18
import org.eclipse.rdf4j.model.vocabulary.DCTERMS;
19
import org.eclipse.rdf4j.model.vocabulary.OWL;
20
import org.nanopub.Nanopub;
21
import org.nanopub.extra.services.ApiResponse;
22
import org.nanopub.extra.services.ApiResponseEntry;
23
import org.nanopub.extra.services.QueryRef;
24
import org.nanopub.vocabulary.NTEMPLATE;
25
import org.slf4j.Logger;
26
import org.slf4j.LoggerFactory;
27

28
import com.github.jsonldjava.shaded.com.google.common.collect.Ordering;
29
import com.google.common.collect.ArrayListMultimap;
30
import com.google.common.collect.Multimap;
31
import com.knowledgepixels.nanodash.template.Template;
32
import com.knowledgepixels.nanodash.template.TemplateData;
33

34
import jakarta.xml.bind.DatatypeConverter;
35

36
/**
37
 * Class representing a "Space", which can be any kind of collaborative unit, like a project, group, or event.
38
 */
39
public class Space implements Serializable {
40

41
    private static final Logger logger = LoggerFactory.getLogger(Space.class);
3✔
42

43
    /**
44
     * The predicate to assign the admins of the space.
45
     */
46
    public static final IRI HAS_ADMIN = vf.createIRI("https://w3id.org/kpxl/gen/terms/hasAdmin");
4✔
47

48
    /**
49
     * The predicate for pinned templates in the space.
50
     */
51
    public static final IRI HAS_PINNED_TEMPLATE = vf.createIRI("https://w3id.org/kpxl/gen/terms/hasPinnedTemplate");
4✔
52

53
    /**
54
     * The predicate for pinned queries in the space.
55
     */
56
    public static final IRI HAS_PINNED_QUERY = vf.createIRI("https://w3id.org/kpxl/gen/terms/hasPinnedQuery");
4✔
57

58
    private static List<Space> spaceList;
59
    private static Map<String, List<Space>> spaceListByType;
60
    private static Map<String, Space> spacesByCoreInfo = new HashMap<>();
4✔
61
    private static Map<String, Space> spacesById;
62
    private static Map<Space, Set<Space>> subspaceMap;
63
    private static Map<Space, Set<Space>> superspaceMap;
64
    private static boolean loaded = false;
3✔
65

66
    /**
67
     * Refresh the list of spaces from the API response.
68
     *
69
     * @param resp The API response containing space data.
70
     */
71
    public static synchronized void refresh(ApiResponse resp) {
72
        spaceList = new ArrayList<>();
4✔
73
        spaceListByType = new HashMap<>();
4✔
74
        Map<String, Space> prevSpacesByCoreInfoPrev = spacesByCoreInfo;
2✔
75
        spacesByCoreInfo = new HashMap<>();
4✔
76
        spacesById = new HashMap<>();
4✔
77
        subspaceMap = new HashMap<>();
4✔
78
        superspaceMap = new HashMap<>();
4✔
79
        for (ApiResponseEntry entry : resp.getData()) {
11✔
80
            Space space = new Space(entry);
5✔
81
            Space prevSpace = prevSpacesByCoreInfoPrev.get(space.getCoreInfoString());
6✔
82
            if (prevSpace != null) space = prevSpace;
4✔
83
            spaceList.add(space);
4✔
84
            spaceListByType.computeIfAbsent(space.getType(), k -> new ArrayList<>()).add(space);
13✔
85
            spacesByCoreInfo.put(space.getCoreInfoString(), space);
6✔
86
            spacesById.put(space.getId(), space);
6✔
87
        }
1✔
88
        for (Space space : spaceList) {
10✔
89
            Space superSpace = space.getIdSuperspace();
3✔
90
            if (superSpace == null) continue;
3✔
91
            subspaceMap.computeIfAbsent(superSpace, k -> new HashSet<>()).add(space);
12✔
92
            superspaceMap.computeIfAbsent(space, k -> new HashSet<>()).add(superSpace);
12✔
93
        }
1✔
94
        loaded = true;
2✔
95
    }
1✔
96

97
    /**
98
     * Check if the spaces have been loaded.
99
     *
100
     * @return true if loaded, false otherwise.
101
     */
102
    public static boolean isLoaded() {
103
        return loaded;
×
104
    }
105

106
    public static boolean areAllSpacesInitialized() {
107
        for (Space space : spaceList) {
×
108
            if (!space.isDataInitialized()) return false;
×
109
        }
×
110
        return true;
×
111
    }
112

113
    public static void triggerAllDataUpdates() {
114
        for (Space space : spaceList) {
×
115
            space.triggerDataUpdate();
×
116
        }
×
117
    }
×
118

119
    /**
120
     * Ensure that the spaces are loaded, fetching them from the API if necessary.
121
     */
122
    public static void ensureLoaded() {
123
        if (spaceList == null) {
2✔
124
            refresh(QueryApiAccess.forcedGet(new QueryRef("get-spaces")));
6✔
125
        }
126
    }
1✔
127

128
    /**
129
     * Get the list of all spaces.
130
     *
131
     * @return List of spaces.
132
     */
133
    public static List<Space> getSpaceList() {
134
        ensureLoaded();
×
135
        return spaceList;
×
136
    }
137

138
    /**
139
     * Get the list of spaces of a specific type.
140
     *
141
     * @param type The type of spaces to retrieve.
142
        System.err.println("REFRESH...");
143
     * @return List of spaces of the specified type.
144
     */
145
    public static List<Space> getSpaceList(String type) {
146
        ensureLoaded();
×
147
        return spaceListByType.computeIfAbsent(type, k -> new ArrayList<>());
×
148
    }
149

150
    /**
151
     * Get a space by its id.
152
     *
153
     * @param id The id of the space.
154
     * @return The corresponding Space object, or null if not found.
155
     */
156
    public static Space get(String id) {
157
        ensureLoaded();
1✔
158
        return spacesById.get(id);
5✔
159
    }
160

161
    /**
162
     * Mark all spaces as needing a data update.
163
     */
164
    public static void refresh() {
165
        refresh(QueryApiAccess.forcedGet(new QueryRef("get-spaces")));
6✔
166
        for (Space space : spaceList) {
10✔
167
            space.dataNeedsUpdate = true;
3✔
168
        }
1✔
169
    }
1✔
170

171
    private String id, label, rootNanopubId, type;
172
    private Nanopub rootNanopub = null;
3✔
173
    private SpaceData data = new SpaceData();
5✔
174

175
    private static class SpaceData implements Serializable {
2✔
176

177
        List<String> altIds = new ArrayList<>();
5✔
178

179
        String description = null;
3✔
180
        Calendar startDate, endDate;
181
        IRI defaultProvenance = null;
3✔
182

183
        List<IRI> admins = new ArrayList<>();
5✔
184
        Map<IRI, Set<SpaceMemberRole>> users = new HashMap<>();
5✔
185
        List<SpaceMemberRole> roles = new ArrayList<>();
5✔
186
        Map<IRI, SpaceMemberRole> roleMap = new HashMap<>();
5✔
187

188
        Map<String, IRI> adminPubkeyMap = new HashMap<>();
5✔
189
        Set<Serializable> pinnedResources = new HashSet<>();
5✔
190
        List<ViewDisplay> topLevelViews = new ArrayList<>();
5✔
191
        List<ViewDisplay> partLevelViews = new ArrayList<>();
5✔
192
        Set<String> pinGroupTags = new HashSet<>();
5✔
193
        Map<String, Set<Serializable>> pinnedResourceMap = new HashMap<>();
6✔
194

195
        void addAdmin(IRI admin) {
196
            // TODO This isn't efficient for long owner lists:
197
            if (admins.contains(admin)) return;
5!
198
            admins.add(admin);
5✔
199
            UserData ud = User.getUserData();
2✔
200
            for (String pubkeyhash : ud.getPubkeyhashes(admin, true)) {
14✔
201
                adminPubkeyMap.put(pubkeyhash, admin);
6✔
202
            }
1✔
203
            users.computeIfAbsent(admin, (k) -> new HashSet<>()).add(SpaceMemberRole.ADMIN_ROLE);
13✔
204
        }
1✔
205

206
    }
207

208
    private boolean dataInitialized = false;
3✔
209
    private boolean dataNeedsUpdate = true;
3✔
210

211
    private Space(ApiResponseEntry resp) {
2✔
212
        this.id = resp.get("space");
5✔
213
        this.label = resp.get("label");
5✔
214
        this.type = resp.get("type");
5✔
215
        this.rootNanopubId = resp.get("np");
5✔
216
        this.rootNanopub = Utils.getAsNanopub(rootNanopubId);
5✔
217
        setCoreData(data);
4✔
218
    }
1✔
219

220
    /**
221
     * Get the ID of the space.
222
     *
223
     * @return The space ID.
224
     */
225
    public String getId() {
226
        return id;
3✔
227
    }
228

229
    /**
230
     * Get the root nanopublication ID of the space.
231
     *
232
     * @return The root nanopub ID.
233
     */
234
    public String getRootNanopubId() {
235
        return rootNanopubId;
×
236
    }
237

238
    /**
239
     * Get a string combining the space ID and root nanopub ID for core identification.
240
     *
241
     * @return The core info string.
242
     */
243
    public String getCoreInfoString() {
244
        return id + " " + rootNanopubId;
6✔
245
    }
246

247
    /**
248
     * Get the root nanopublication of the space.
249
     *
250
     * @return The root Nanopub object.
251
     */
252
    public Nanopub getRootNanopub() {
253
        return rootNanopub;
×
254
    }
255

256
    /**
257
     * Get the label of the space.
258
     *
259
     * @return The space label.
260
     */
261
    public String getLabel() {
262
        return label;
×
263
    }
264

265
    /**
266
     * Get the type of the space.
267
     *
268
     * @return The space type.
269
     */
270
    public String getType() {
271
        return type;
3✔
272
    }
273

274
    /**
275
     * Get the start date of the space.
276
     *
277
     * @return The start date as a Calendar object, or null if not set.
278
     */
279
    public Calendar getStartDate() {
280
        return data.startDate;
×
281
    }
282

283
    /**
284
     * Get the end date of the space.
285
     *
286
     * @return The end date as a Calendar object, or null if not set.
287
     */
288
    public Calendar getEndDate() {
289
        return data.endDate;
×
290
    }
291

292
    /**
293
     * Get a simplified label for the type of space by removing any namespace prefix.
294
     *
295
     * @return The simplified type label.
296
     */
297
    public String getTypeLabel() {
298
        return type.replaceFirst("^.*/", "");
×
299
    }
300

301
    /**
302
     * Get the description of the space.
303
     *
304
     * @return The description string.
305
     */
306
    public String getDescription() {
307
        return data.description;
×
308
    }
309

310
    /**
311
     * Check if the space data has been initialized.
312
     *
313
     * @return true if initialized, false otherwise.
314
     */
315
    public boolean isDataInitialized() {
316
        triggerDataUpdate();
×
317
        return dataInitialized;
×
318
    }
319

320
    /**
321
     * Get the list of admins in this space.
322
     *
323
     * @return List of admin IRIs.
324
     */
325
    public List<IRI> getAdmins() {
326
        ensureInitialized();
×
327
        return data.admins;
×
328
    }
329

330
    /**
331
     * Get the list of members in this space.
332
     *
333
     * @return List of member IRIs.
334
     */
335
    public List<IRI> getUsers() {
336
        ensureInitialized();
×
337
        List<IRI> users = new ArrayList<IRI>(data.users.keySet());
×
338
        users.sort(User.getUserData().userComparator);
×
339
        return users;
×
340
    }
341

342
    /**
343
     * Get the roles of a specific member in this space.
344
     *
345
     * @param userId The IRI of the member.
346
     * @return Set of roles assigned to the member, or null if the member is not part of this space.
347
     */
348
    public Set<SpaceMemberRole> getMemberRoles(IRI userId) {
349
        ensureInitialized();
×
350
        return data.users.get(userId);
×
351
    }
352

353
    /**
354
     * Check if a user is a member of this space.
355
     *
356
     * @param userId The IRI of the user to check.
357
     * @return true if the user is a member, false otherwise.
358
     */
359
    public boolean isMember(IRI userId) {
360
        ensureInitialized();
×
361
        return data.users.containsKey(userId);
×
362
    }
363

364
    public boolean isAdminPubkey(String pubkey) {
365
        ensureInitialized();
×
366
        return data.adminPubkeyMap.containsKey(pubkey);
×
367
    }
368

369
    /**
370
     * Get the list of pinned resources in this space.
371
     *
372
     * @return List of pinned resources.
373
     */
374
    public Set<Serializable> getPinnedResources() {
375
        ensureInitialized();
×
376
        return data.pinnedResources;
×
377
    }
378

379
    /**
380
     * Get the set of tags used for grouping pinned resources.
381
     *
382
     * @return Set of tags.
383
     */
384
    public Set<String> getPinGroupTags() {
385
        ensureInitialized();
×
386
        return data.pinGroupTags;
×
387
    }
388

389
    /**
390
     * Get a map of pinned resources grouped by their tags.
391
     *
392
     * @return Map where keys are tags and values are lists of pinned resources (Templates or GrlcQueries).
393
     */
394
    public Map<String, Set<Serializable>> getPinnedResourceMap() {
395
        ensureInitialized();
×
396
        return data.pinnedResourceMap;
×
397
    }
398

399
    /**
400
     * Returns the view displays and their associated nanopub IDs.
401
     *
402
     * @return Map of views to nanopub IDs
403
     */
404
    public List<ViewDisplay> getTopLevelViews() {
405
        return data.topLevelViews;
×
406
    }
407

408
    public List<ViewDisplay> getPartLevelViews(Set<IRI> classes) {
409
        triggerDataUpdate();
×
410
        List<ViewDisplay> viewDisplays = new ArrayList<>();
×
411
        for (ViewDisplay v : data.partLevelViews) {
×
412
            if (v.getView().hasTargetClasses()) {
×
413
                for (IRI c : classes) {
×
414
                    if (v.getView().hasTargetClass(c)) {
×
415
                        viewDisplays.add(v);
×
416
                        break;
×
417
                    }
418
                }
×
419
            } else {
420
                viewDisplays.add(v);
×
421
            }
422
        }
×
423
        return viewDisplays;
×
424
    }
425

426
    public boolean coversElement(String elementId) {
427
        triggerDataUpdate();
×
428
        for (ViewDisplay v : data.topLevelViews) {
×
429
            if (v.getView().coversElement(elementId)) return true;
×
430
        }
×
431
        for (ViewDisplay v : data.partLevelViews) {
×
432
            if (v.getView().coversElement(elementId)) return true;
×
433
        }
×
434
        return false;
×
435
    }
436

437
    /**
438
     * Get the default provenance IRI for this space.
439
     *
440
     * @return The default provenance IRI, or null if not set.
441
     */
442
    public IRI getDefaultProvenance() {
443
        return data.defaultProvenance;
×
444
    }
445

446
    /**
447
     * Get the roles defined in this space.
448
     *
449
     * @return List of roles.
450
     */
451
    public List<SpaceMemberRole> getRoles() {
452
        return data.roles;
×
453
    }
454

455
    /**
456
     * Get the super ID of the space.
457
     *
458
     * @return Always returns null. Use getIdSuperspace() instead.
459
     */
460
    public String getSuperId() {
461
        return null;
×
462
    }
463

464
    /**
465
     * Get the superspace ID.
466
     *
467
     * @return The superspace, or null if not applicable.
468
     */
469
    public Space getIdSuperspace() {
470
        if (!id.matches("https?://[^/]+/.*/[^/]*/?")) return null;
5!
471
        String superId = id.replaceFirst("(https?://[^/]+/.*)/[^/]*/?", "$1");
6✔
472
        if (spacesById.containsKey(superId)) {
4✔
473
            return spacesById.get(superId);
5✔
474
        }
475
        return null;
2✔
476
    }
477

478
    /**
479
     * Get superspaces of this space.
480
     *
481
     * @return List of superspaces.
482
     */
483
    public List<Space> getSuperspaces() {
484
        if (superspaceMap.containsKey(this)) {
×
485
            List<Space> superspaces = new ArrayList<>(superspaceMap.get(this));
×
486
            Collections.sort(superspaces, Ordering.usingToString());
×
487
            return superspaces;
×
488
        }
489
        return new ArrayList<>();
×
490
    }
491

492
    /**
493
     * Get subspaces of this space.
494
     *
495
     * @return List of subspaces.
496
     */
497
    public List<Space> getSubspaces() {
498
        if (subspaceMap.containsKey(this)) {
×
499
            List<Space> subspaces = new ArrayList<>(subspaceMap.get(this));
×
500
            Collections.sort(subspaces, Ordering.usingToString());
×
501
            return subspaces;
×
502
        }
503
        return new ArrayList<>();
×
504
    }
505

506
    /**
507
     * Get subspaces of a specific type.
508
     *
509
     * @param type The type of subspaces to retrieve.
510
     * @return List of subspaces of the specified type.
511
     */
512
    public List<Space> getSubspaces(String type) {
513
        List<Space> l = new ArrayList<>();
×
514
        for (Space s : getSubspaces()) {
×
515
            if (s.getType().equals(type)) l.add(s);
×
516
        }
×
517
        return l;
×
518
    }
519

520
    /**
521
     * Get alternative IDs for the space.
522
     *
523
     * @return List of alternative IDs.
524
     */
525
    public List<String> getAltIDs() {
526
        return data.altIds;
×
527
    }
528

529
    private synchronized void ensureInitialized() {
530
        Thread thread = triggerDataUpdate();
×
531
        if (!dataInitialized && thread != null) {
×
532
            try {
533
                thread.join();
×
534
            } catch (InterruptedException ex) {
×
535
                logger.error("failed to join thread", ex);
×
536
            }
×
537
        }
538
    }
×
539

540
    private synchronized Thread triggerDataUpdate() {
541
        if (dataNeedsUpdate) {
×
542
            Thread thread = new Thread(() -> {
×
543
                try {
544
                    SpaceData newData = new SpaceData();
×
545
                    setCoreData(newData);
×
546

547
                    newData.roles.add(SpaceMemberRole.ADMIN_ROLE);
×
548
                    newData.roleMap.put(SpaceMemberRole.HAS_ADMIN_PREDICATE, SpaceMemberRole.ADMIN_ROLE);
×
549

550
                    // TODO Improve this:
551
                    Multimap<String, String> spaceIds = ArrayListMultimap.create();
×
552
                    Multimap<String, String> resourceIds = ArrayListMultimap.create();
×
553
                    spaceIds.put("space", id);
×
554
                    resourceIds.put("resource", id);
×
555
                    for (String id : newData.altIds) {
×
556
                        spaceIds.put("space", id);
×
557
                        resourceIds.put("resource", id);
×
558
                    }
×
559

560
                    ApiResponse getAdminsResponse = QueryApiAccess.get(new QueryRef("get-admins", spaceIds));
×
561
                    boolean continueAddingAdmins = true;
×
562
                    while (continueAddingAdmins) {
×
563
                        continueAddingAdmins = false;
×
564
                        for (ApiResponseEntry r : getAdminsResponse.getData()) {
×
565
                            String pubkeyhash = r.get("pubkey");
×
566
                            if (newData.adminPubkeyMap.containsKey(pubkeyhash)) {
×
567
                                IRI adminId = Utils.vf.createIRI(r.get("admin"));
×
568
                                if (!newData.admins.contains(adminId)) {
×
569
                                    continueAddingAdmins = true;
×
570
                                    newData.addAdmin(adminId);
×
571
                                }
572
                            }
573
                        }
×
574
                    }
575
                    newData.admins.sort(User.getUserData().userComparator);
×
576

577
                    Multimap<String, String> getSpaceMemberParams = ArrayListMultimap.create(spaceIds);
×
578

579
                    for (ApiResponseEntry r : QueryApiAccess.get(new QueryRef("get-space-member-roles", spaceIds)).getData()) {
×
580
                        if (!newData.adminPubkeyMap.containsKey(r.get("pubkey"))) continue;
×
581
                        SpaceMemberRole role = new SpaceMemberRole(r);
×
582
                        newData.roles.add(role);
×
583

584
                        // TODO Handle cases of overlapping properties:
585
                        for (IRI p : role.getRegularProperties()) newData.roleMap.put(p, role);
×
586
                        for (IRI p : role.getInverseProperties()) newData.roleMap.put(p, role);
×
587

588
                        role.addRoleParams(getSpaceMemberParams);
×
589
                    }
×
590

591
                    for (ApiResponseEntry r : QueryApiAccess.get(new QueryRef("get-space-members", getSpaceMemberParams)).getData()) {
×
592
                        IRI memberId = Utils.vf.createIRI(r.get("member"));
×
593
                        SpaceMemberRole role = newData.roleMap.get(Utils.vf.createIRI(r.get("role")));
×
594
                        newData.users.computeIfAbsent(memberId, (k) -> new HashSet<>()).add(role);
×
595
                    }
×
596

597
                    for (ApiResponseEntry r : QueryApiAccess.get(new QueryRef("get-pinned-templates", spaceIds)).getData()) {
×
598
                        if (!newData.adminPubkeyMap.containsKey(r.get("pubkey"))) continue;
×
599
                        Template t = TemplateData.get().getTemplate(r.get("template"));
×
600
                        if (t == null) continue;
×
601
                        newData.pinnedResources.add(t);
×
602
                        String tag = r.get("tag");
×
603
                        if (tag != null && !tag.isEmpty()) {
×
604
                            newData.pinGroupTags.add(r.get("tag"));
×
605
                            newData.pinnedResourceMap.computeIfAbsent(tag, k -> new HashSet<>()).add(TemplateData.get().getTemplate(r.get("template")));
×
606
                        }
607
                    }
×
608
                    for (ApiResponseEntry r : QueryApiAccess.get(new QueryRef("get-pinned-queries", spaceIds)).getData()) {
×
609
                        if (!newData.adminPubkeyMap.containsKey(r.get("pubkey"))) continue;
×
610
                        GrlcQuery query = GrlcQuery.get(r.get("query"));
×
611
                        if (query == null) continue;
×
612
                        newData.pinnedResources.add(query);
×
613
                        String tag = r.get("tag");
×
614
                        if (tag != null && !tag.isEmpty()) {
×
615
                            newData.pinGroupTags.add(r.get("tag"));
×
616
                            newData.pinnedResourceMap.computeIfAbsent(tag, k -> new HashSet<>()).add(query);
×
617
                        }
618
                    }
×
619
                    for (ApiResponseEntry r : QueryApiAccess.get(new QueryRef("get-view-displays", resourceIds)).getData()) {
×
620
                        if (!newData.adminPubkeyMap.containsKey(r.get("pubkey"))) continue;
×
621
                        try {
622
                            ViewDisplay vd = ViewDisplay.get(r.get("display"));
×
623
                            if (ResourceView.PART_LEVEL_VIEW_DISPLAY.stringValue().equals(r.get("displayType"))) {
×
624
                                newData.partLevelViews.add(vd);
×
625
                            } else {
626
                                newData.topLevelViews.add(vd);
×
627
                            }
628
                        } catch (IllegalArgumentException ex) {
×
629
                            logger.error("Couldn't generate view display object", ex);
×
630
                        }
×
631
                    }
×
632
                    Collections.sort(newData.topLevelViews);
×
633
                    Collections.sort(newData.partLevelViews);
×
634
                    data = newData;
×
635
                    dataInitialized = true;
×
636
                } catch (Exception ex) {
×
637
                    logger.error("Error while trying to update space data: {}", ex);
×
638
                }
×
639
            });
×
640
            thread.start();
×
641
            dataNeedsUpdate = false;
×
642
            return thread;
×
643
        }
644
        return null;
×
645
    }
646

647
    private void setCoreData(SpaceData data) {
648
        for (Statement st : rootNanopub.getAssertion()) {
12✔
649
            if (st.getSubject().stringValue().equals(getId())) {
7!
650
                if (st.getPredicate().equals(OWL.SAMEAS) && st.getObject() instanceof IRI objIri) {
14!
651
                    data.altIds.add(objIri.stringValue());
7✔
652
                } else if (st.getPredicate().equals(DCTERMS.DESCRIPTION)) {
5✔
653
                    data.description = st.getObject().stringValue();
6✔
654
                } else if (st.getPredicate().stringValue().equals("http://schema.org/startDate")) {
6✔
655
                    try {
656
                        data.startDate = DatatypeConverter.parseDateTime(st.getObject().stringValue());
6✔
657
                    } catch (IllegalArgumentException ex) {
×
658
                        logger.error("Failed to parse date {}", st.getObject().stringValue());
×
659
                    }
1✔
660
                } else if (st.getPredicate().stringValue().equals("http://schema.org/endDate")) {
6✔
661
                    try {
662
                        data.endDate = DatatypeConverter.parseDateTime(st.getObject().stringValue());
6✔
663
                    } catch (IllegalArgumentException ex) {
×
664
                        logger.error("Failed to parse date {}", st.getObject().stringValue());
×
665
                    }
1✔
666
                } else if (st.getPredicate().equals(HAS_ADMIN) && st.getObject() instanceof IRI obj) {
14!
667
                    data.addAdmin(obj);
4✔
668
                } else if (st.getPredicate().equals(HAS_PINNED_TEMPLATE) && st.getObject() instanceof IRI obj) {
5!
669
                    data.pinnedResources.add(TemplateData.get().getTemplate(obj.stringValue()));
×
670
                } else if (st.getPredicate().equals(HAS_PINNED_QUERY) && st.getObject() instanceof IRI obj) {
5!
671
                    data.pinnedResources.add(GrlcQuery.get(obj.stringValue()));
×
672
                } else if (st.getPredicate().equals(NTEMPLATE.HAS_DEFAULT_PROVENANCE) && st.getObject() instanceof IRI obj) {
5!
673
                    data.defaultProvenance = obj;
1✔
674
                }
675
            } else if (st.getPredicate().equals(NTEMPLATE.HAS_TAG) && st.getObject() instanceof Literal l) {
×
676
                data.pinGroupTags.add(l.stringValue());
×
677
                Set<Serializable> list = data.pinnedResourceMap.get(l.stringValue());
×
678
                if (list == null) {
×
679
                    list = new HashSet<>();
×
680
                    data.pinnedResourceMap.put(l.stringValue(), list);
×
681
                }
682
                list.add(TemplateData.get().getTemplate(st.getSubject().stringValue()));
×
683
            }
684
        }
1✔
685
    }
1✔
686

687
    @Override
688
    public String toString() {
689
        return id;
×
690
    }
691

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