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

knowledgepixels / nanodash / 28446987688

30 Jun 2026 01:12PM UTC coverage: 28.036% (+0.001%) from 28.035%
28446987688

push

github

web-flow
Merge pull request #523 from knowledgepixels/feat/orcid-uri-as-user

feat: route ORCID URIs to the user page, keeping query-supplied labels

1727 of 7021 branches covered (24.6%)

Branch coverage included in aggregate %.

3608 of 12008 relevant lines covered (30.05%)

4.45 hits per line

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

24.24
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 whether the given URI is a well-formed ORCID IRI (e.g.
49
     * {@code https://orcid.org/0000-0002-1825-0097}). Such IRIs identify
50
     * individual agents even when they are not (yet) known users, so links to
51
     * them can be routed to the user page (shown as a not-yet-configured profile)
52
     * rather than the generic explore page.
53
     *
54
     * @param uri The URI to check.
55
     * @return True if the URI is a well-formed ORCID IRI, false otherwise.
56
     */
57
    public static boolean isOrcidIri(String uri) {
58
        return uri != null && uri.matches("https://orcid\\.org/[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[0-9X]");
24!
59
    }
60

61
    /**
62
     * Checks if a given IRI represents a software agent.
63
     *
64
     * @param userIri The IRI to check.
65
     * @return True if the IRI represents a software agent, false otherwise.
66
     */
67
    public static boolean isSoftware(IRI userIri) {
68
        return User.getUserData().isSoftware(userIri);
×
69
    }
70

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

77
    @Override
78
    public Nanopub getNanopub() {
79
        // FIXME this will be removed in the future
80
        return null;
×
81
    }
82

83
    @Override
84
    public String getNamespace() {
85
        // FIXME this will be removed in the future
86
        return null;
×
87
    }
88

89
    @Override
90
    protected Set<IRI> getOwnClasses() {
91
        return Set.of(KPXL_TERMS.INDIVIDUAL_AGENT);
×
92
    }
93

94
    /**
95
     * Checks if this user is the currently logged-in user.
96
     *
97
     * @return True if this user is the currently logged-in user, false otherwise.
98
     */
99
    public boolean isCurrentUser() {
100
        IRI userIri = NanodashSession.get().getUserIri();
×
101
        if (userIri == null) {
×
102
            return false;
×
103
        }
104
        return getId().equals(userIri.stringValue());
×
105
    }
106

107
    @Override
108
    public String getLabel() {
109
        try {
110
            return User.getUserData().getShortDisplayName(Utils.vf.createIRI(getId()));
×
111
        } catch (Exception ex) {
×
112
        }
113
        return getId();
×
114
    }
115

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