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

knowledgepixels / nanodash / 27145358627

08 Jun 2026 02:39PM UTC coverage: 20.682% (-0.3%) from 20.947%
27145358627

push

github

web-flow
Merge pull request #479 from knowledgepixels/feat/about-pages-478

Resource-page tabs, presets, and role-gated view actions (#478, #302)

1052 of 6429 branches covered (16.36%)

Branch coverage included in aggregate %.

2642 of 11432 relevant lines covered (23.11%)

3.31 hits per line

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

17.86
src/main/java/com/knowledgepixels/nanodash/domain/IndividualAgent.java
1
package com.knowledgepixels.nanodash.domain;
2

3
import com.knowledgepixels.nanodash.NanodashSession;
4
import com.knowledgepixels.nanodash.Utils;
5
import com.knowledgepixels.nanodash.ViewDisplay;
6
import com.knowledgepixels.nanodash.vocabulary.KPXL_TERMS;
7
import org.eclipse.rdf4j.model.IRI;
8
import org.nanopub.Nanopub;
9

10
import com.google.common.cache.Cache;
11
import com.google.common.cache.CacheBuilder;
12

13
import java.util.Set;
14
import java.util.concurrent.TimeUnit;
15

16
// TODO Merge this class with User or otherwise make them aligned.
17
public class IndividualAgent extends AbstractResourceWithProfile {
18

19
    private static final Cache<String, IndividualAgent> instanceMap = CacheBuilder.newBuilder()
9✔
20
        .maximumSize(10_000)
9✔
21
        .expireAfterAccess(24, TimeUnit.HOURS)
3✔
22
        .build();
6✔
23

24
    public static IndividualAgent get(String id) {
25
        IndividualAgent cached = instanceMap.getIfPresent(id);
×
26
        if (cached == null) {
×
27
            cached = new IndividualAgent(id);
×
28
            instanceMap.put(id, cached);
×
29
        }
30
        return cached;
×
31
    }
32

33
    private IndividualAgent(String id) {
34
        super(id);
×
35
    }
×
36

37
    /**
38
     * Checks if a given string represents a user ID.
39
     *
40
     * @param userId The string to check.
41
     * @return True if the string represents a user ID, false otherwise.
42
     */
43
    public static boolean isUser(String userId) {
44
        return User.getUserData().isUser(userId);
12✔
45
    }
46

47
    /**
48
     * Checks if a given IRI represents a software agent.
49
     *
50
     * @param userIri The IRI to check.
51
     * @return True if the IRI represents a software agent, false otherwise.
52
     */
53
    public static boolean isSoftware(IRI userIri) {
54
        return User.getUserData().isSoftware(userIri);
×
55
    }
56

57
    @Override
58
    public String getNanopubId() {
59
        // FIXME this will be removed in the future
60
        return null;
×
61
    }
62

63
    @Override
64
    public Nanopub getNanopub() {
65
        // FIXME this will be removed in the future
66
        return null;
×
67
    }
68

69
    @Override
70
    public String getNamespace() {
71
        // FIXME this will be removed in the future
72
        return null;
×
73
    }
74

75
    @Override
76
    protected Set<IRI> getOwnClasses() {
77
        return Set.of(KPXL_TERMS.INDIVIDUAL_AGENT);
×
78
    }
79

80
    /**
81
     * Checks if this user is the currently logged-in user.
82
     *
83
     * @return True if this user is the currently logged-in user, false otherwise.
84
     */
85
    public boolean isCurrentUser() {
86
        IRI userIri = NanodashSession.get().getUserIri();
×
87
        if (userIri == null) {
×
88
            return false;
×
89
        }
90
        return getId().equals(userIri.stringValue());
×
91
    }
92

93
    @Override
94
    public String getLabel() {
95
        try {
96
            return User.getUserData().getShortDisplayName(Utils.vf.createIRI(getId()));
×
97
        } catch (Exception ex) {
×
98
        }
99
        return getId();
×
100
    }
101

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