• 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

51.72
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 com.knowledgepixels.nanodash.vocabulary.KPXL_TERMS;
6
import org.eclipse.rdf4j.model.IRI;
7
import org.nanopub.Nanopub;
8
import org.nanopub.extra.services.ApiResponseEntry;
9
import org.slf4j.Logger;
10
import org.slf4j.LoggerFactory;
11

12
import java.util.Set;
13

14
public class MaintainedResource extends AbstractResourceWithProfile {
15

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

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

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

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

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

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

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

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

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

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

84
    @Override
85
    protected Set<IRI> getOwnClasses() {
86
        return Set.of(KPXL_TERMS.MAINTAINED_RESOURCE);
×
87
    }
88

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