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

knowledgepixels / nanodash / 26455055595

26 May 2026 02:38PM UTC coverage: 20.427% (-0.3%) from 20.748%
26455055595

Pull #468

github

web-flow
Merge 0354b3eb9 into 65b0c8452
Pull Request #468: Source space data from nanopub-query spaces repo

1005 of 6260 branches covered (16.05%)

Branch coverage included in aggregate %.

2600 of 11388 relevant lines covered (22.83%)

3.27 hits per line

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

53.57
src/main/java/com/knowledgepixels/nanodash/domain/MaintainedResource.java
1
package com.knowledgepixels.nanodash.domain;
2

3
import com.knowledgepixels.nanodash.Utils;
4
import com.knowledgepixels.nanodash.ViewDisplay;
5
import org.eclipse.rdf4j.model.IRI;
6
import org.nanopub.Nanopub;
7
import org.nanopub.extra.services.ApiResponseEntry;
8
import org.slf4j.Logger;
9
import org.slf4j.LoggerFactory;
10

11
import java.util.Set;
12

13
public class MaintainedResource extends AbstractResourceWithProfile {
14

15
    private static final Logger logger = LoggerFactory.getLogger(MaintainedResource.class);
12✔
16

17
    /**
18
     * Get the namespace from a string or IRI by removing the last segment after a slash or hash.
19
     *
20
     * @param stringOrIri A string or IRI representing the namespace to search for.
21
     * @return The namespace extracted from the input string or IRI, or null if the input is null.
22
     */
23
    public static String getNamespace(Object stringOrIri) {
24
        return stringOrIri.toString().replaceFirst("([#/])[^#/]+$", "$1");
×
25
    }
26

27
    private String label, nanopubId, namespace;
28
    private Nanopub nanopub;
29

30
    /**
31
     * Constructor for MaintainedResource, initializing the object based on the provided API response entry and associated space.
32
     *
33
     * @param resp  the API response entry containing the data for this maintained resource
34
     * @param space the space associated with this maintained resource
35
     */
36
    MaintainedResource(ApiResponseEntry resp, Space space) {
37
        super(resp.get("resource"));
15✔
38
        initialize(resp, space);
12✔
39
    }
3✔
40

41
    private void initialize(ApiResponseEntry resp, Space space) {
42
        initSpace(space);
9✔
43
        this.label = resp.get("label");
15✔
44
        this.nanopubId = resp.get("np");
15✔
45
        this.namespace = resp.get("namespace");
15✔
46
        if (namespace != null && namespace.isBlank()) {
21!
47
            namespace = null;
×
48
        }
49
        this.nanopub = Utils.getAsNanopub(nanopubId);
15✔
50
    }
3✔
51

52
    void updateFromApi(ApiResponseEntry resp, Space space) {
53
        String newNpId = resp.get("np");
×
54
        if (!newNpId.equals(this.nanopubId)) {
×
55
            initialize(resp, space);
×
56
            setDataNeedsUpdate();
×
57
        }
58
    }
×
59

60
    /**
61
     * Get the ID of the nanopub that defines this maintained resource.
62
     *
63
     * @return the nanopub ID
64
     */
65
    public String getNanopubId() {
66
        return nanopubId;
×
67
    }
68

69
    @Override
70
    public Nanopub getNanopub() {
71
        return nanopub;
×
72
    }
73

74
    public String getLabel() {
75
        return label;
×
76
    }
77

78
    @Override
79
    public String getNamespace() {
80
        return namespace;
9✔
81
    }
82

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