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

knowledgepixels / nanodash / 26434124740

26 May 2026 05:28AM UTC coverage: 20.526% (-0.2%) from 20.748%
26434124740

Pull #468

github

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

1003 of 6244 branches covered (16.06%)

Branch coverage included in aggregate %.

2625 of 11431 relevant lines covered (22.96%)

3.27 hits per line

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

73.33
src/main/java/com/knowledgepixels/nanodash/domain/MaintainedResourceFactory.java
1
package com.knowledgepixels.nanodash.domain;
2

3
import org.nanopub.extra.services.ApiResponseEntry;
4

5
import java.util.HashSet;
6
import java.util.Set;
7

8
/**
9
 * Factory class for creating or retrieving MaintainedResource instances based on API response entries and associated spaces.
10
 */
11
public class MaintainedResourceFactory {
12

13
    private MaintainedResourceFactory() {
14
    }
15

16
    /**
17
     * Retrieves an existing MaintainedResource instance based on the API response entry and associated space, or creates a new one if it doesn't exist.
18
     *
19
     * @param apiResponseEntry The API response entry containing maintained resource data.
20
     * @param space            The associated Space instance for the maintained resource.
21
     * @return A MaintainedResource instance initialized with the data from the API response entry and associated space.
22
     */
23
    public static MaintainedResource getOrCreate(ApiResponseEntry apiResponseEntry, Space space) {
24
        String id = apiResponseEntry.get("resource");
12✔
25
        AbstractResourceWithProfile existing = AbstractResourceWithProfile.get(id);
9✔
26
        if (existing instanceof MaintainedResource resource) {
9!
27
            resource.updateFromApi(apiResponseEntry, space);
×
28
            return resource;
×
29
        }
30
        return new MaintainedResource(apiResponseEntry, space);
18✔
31
    }
32

33
    /**
34
     * Removes MaintainedResource instances that are no longer active based on the provided set of active IDs.
35
     *
36
     * @param activeIds A set of active maintained resource IDs that should be retained. Any MaintainedResource instance with an ID not in this set will be removed.
37
     */
38
    public static void removeStale(Set<String> activeIds) {
39
        new HashSet<>(AbstractResourceWithProfile.getInstances(MaintainedResource.class).keySet())
18✔
40
                .stream()
9✔
41
                .filter(id -> !activeIds.contains(id))
24!
42
                .forEach(id -> AbstractResourceWithProfile.removeInstance(MaintainedResource.class, id));
3✔
43
    }
3✔
44

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