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

knowledgepixels / nanodash / 23337744284

20 Mar 2026 09:55AM UTC coverage: 16.351% (+0.02%) from 16.327%
23337744284

Pull #410

github

web-flow
Merge 2e8bc3131 into 3faec6ac7
Pull Request #410: fix: update Space and MaintainedResource data when root nanopub changes

729 of 5525 branches covered (13.19%)

Branch coverage included in aggregate %.

1871 of 10376 relevant lines covered (18.03%)

2.47 hits per line

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

78.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;
9✔
48
        }
49
        this.nanopub = Utils.getAsNanopub(nanopubId);
15✔
50
    }
3✔
51

52
    void updateFromApi(ApiResponseEntry resp, Space space) {
53
        String newNpId = resp.get("np");
12✔
54
        if (!newNpId.equals(this.nanopubId)) {
15!
55
            initialize(resp, space);
12✔
56
            setDataNeedsUpdate();
6✔
57
        }
58
    }
3✔
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