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

knowledgepixels / nanodash / 19768361433

28 Nov 2025 03:44PM UTC coverage: 13.855% (-0.05%) from 13.909%
19768361433

push

github

tkuhn
feat(UserPage): Support for view displays (buttons still missing)

521 of 4896 branches covered (10.64%)

Branch coverage included in aggregate %.

1398 of 8955 relevant lines covered (15.61%)

0.69 hits per line

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

16.67
src/main/java/com/knowledgepixels/nanodash/ProfiledResource.java
1
package com.knowledgepixels.nanodash;
2

3
import java.io.Serializable;
4
import java.util.ArrayList;
5
import java.util.Collections;
6
import java.util.HashSet;
7
import java.util.List;
8
import java.util.Set;
9

10
import org.eclipse.rdf4j.model.IRI;
11
import org.nanopub.Nanopub;
12
import org.nanopub.extra.services.ApiResponseEntry;
13
import org.nanopub.extra.services.QueryRef;
14
import org.slf4j.Logger;
15
import org.slf4j.LoggerFactory;
16

17
import com.knowledgepixels.nanodash.vocabulary.KPXL_TERMS;
18

19
public class ProfiledResource implements Serializable {
20

21
    private static final Logger logger = LoggerFactory.getLogger(ProfiledResource.class);
4✔
22

23
    protected static class ResourceData implements Serializable {
2✔
24
        List<ViewDisplay> viewDisplays = new ArrayList<>();
6✔
25
    }
26

27
    private String id;
28
    private Space space;
29
    private ResourceData data = new ResourceData();
5✔
30
    private boolean dataInitialized = false;
3✔
31
    private boolean dataNeedsUpdate = true;
3✔
32

33
    protected ProfiledResource(String id, Space space) {
2✔
34
        this.id = id;
3✔
35
        this.space = space;
3✔
36
    }
1✔
37

38
    public String getId() {
39
        return id;
3✔
40
    }
41

42
    protected synchronized void triggerDataUpdate() {
43
        if (dataNeedsUpdate) {
×
44
            new Thread(() -> {
×
45
                try {
46
                    ResourceData newData = new ResourceData();
×
47

48
                    for (ApiResponseEntry r : QueryApiAccess.get(new QueryRef("get-view-displays", "resource", id)).getData()) {
×
49
                        if (space != null && !space.isAdminPubkey(r.get("pubkey"))) continue;
×
50
                        try {
51
                            newData.viewDisplays.add(ViewDisplay.get(r.get("display")));
×
52
                        } catch (IllegalArgumentException ex) {
×
53
                            logger.error("Couldn't generate view display object", ex);
×
54
                        }
×
55
                    }
×
56
                    data = newData;
×
57
                    dataInitialized = true;
×
58
                } catch (Exception ex) {
×
59
                    logger.error("Error while trying to update space data: {}", ex);
×
60
                    dataNeedsUpdate = true;
×
61
                }
×
62
            }).start();
×
63
            dataNeedsUpdate = false;
×
64
        }
65
    }
×
66

67
    public Space getSpace() {
68
        return space;
×
69
    }
70

71
    public String getNanopubId() {
72
        return null;
×
73
    }
74

75
    public Nanopub getNanopub() {
76
        return null;
×
77
    }
78
    public String getNamespace() {
79
        return null;
×
80
    }
81

82
    public void setDataNeedsUpdate() {
83
        dataNeedsUpdate = true;
3✔
84
    }
1✔
85

86
    public boolean isDataInitialized() {
87
        triggerDataUpdate();
×
88
        return dataInitialized;
×
89
    }
90

91
    public List<ViewDisplay> getViewDisplays() {
92
        return data.viewDisplays;
×
93
    }
94

95
    public List<ViewDisplay> getViewDisplays(boolean toplevel, Set<IRI> classes) {
96
        triggerDataUpdate();
×
97
        List<ViewDisplay> viewDisplays = new ArrayList<>();
×
98
        Set<IRI> viewKinds = new HashSet<>();
×
99

100
        for (ViewDisplay vd : getViewDisplays()) {
×
101
            IRI kind = vd.getViewKindIri();
×
102
            if (kind != null) {
×
103
                if (viewKinds.contains(kind)) continue;
×
104
                viewKinds.add(vd.getViewKindIri());
×
105
            }
106
            if (vd.hasType(KPXL_TERMS.DEACTIVATED_VIEW_DISPLAY)) continue;
×
107

108
            if (vd.appliesTo(getId(), null)) {
×
109
                viewDisplays.add(vd);
×
110
            } else if (toplevel && vd.hasType(KPXL_TERMS.TOP_LEVEL_VIEW_DISPLAY)) {
×
111
                // Deprecated
112
                viewDisplays.add(vd);
×
113
            }
114
        }
×
115

116
        Collections.sort(viewDisplays);
×
117
        return viewDisplays;
×
118
    }
119

120
    @Override
121
    public String toString() {
122
        return id;
×
123
    }
124

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