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

knowledgepixels / nanopub-query / 17767759901

16 Sep 2025 01:40PM UTC coverage: 71.59% (-0.2%) from 71.741%
17767759901

push

github

Ziroli Plutschow
Replacing newest System.err with slf4j logging

- Note: Also upgraded mockito, since it's transient dependency byte-buddy could not handle a jvm > 21

233 of 350 branches covered (66.57%)

Branch coverage included in aggregate %.

591 of 801 relevant lines covered (73.78%)

3.72 hits per line

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

86.67
src/main/java/com/knowledgepixels/query/LocalNanopubLoader.java
1
package com.knowledgepixels.query;
2

3
import org.eclipse.rdf4j.rio.RDFFormat;
4
import org.nanopub.MalformedNanopubException;
5
import org.nanopub.MultiNanopubRdfHandler;
6
import org.slf4j.Logger;
7
import org.slf4j.LoggerFactory;
8

9
import java.io.BufferedReader;
10
import java.io.File;
11
import java.io.FileReader;
12
import java.io.IOException;
13

14
/**
15
 * Local loader left here in case it's needed for testing or when the Jelly loader breaks.
16
 */
17
public class LocalNanopubLoader {
18

19
    private static final Logger log = LoggerFactory.getLogger(LocalNanopubLoader.class);
3✔
20

21
    private LocalNanopubLoader() {
22
    }  // no instances allowed
23

24
    /**
25
     * File containing URIs of nanopubs to load.
26
     */
27
    public final static File loadUrisFile = new File("load/nanopub-uris.txt");
5✔
28

29
    /**
30
     * File containing nanopubs in TRIG format to load.
31
     */
32
    public final static File loadNanopubsFile = new File("load/nanopubs.trig.gz");
5✔
33

34
    private static final int WAIT_SECONDS = Utils.getEnvInt("INIT_WAIT_SECONDS", 120);
5✔
35

36
    /**
37
     * Load nanopubs from local files.
38
     *
39
     * @return true if local nanopubs were found and loaded, false otherwise
40
     */
41
    public static boolean init() {
42
        // FIXME should this be loadNanopubsFile.exists() || loadUrisFile.exists()?
43
        if (!(loadNanopubsFile.exists() || loadNanopubsFile.exists())) {
6!
44
            log.info("No local nanopub files for loading found. Moving on to loading via Jelly...");
3✔
45
            return false;
2✔
46
        }
47
        log.info("Waiting {} seconds to make sure the triple store is up...", WAIT_SECONDS);
5✔
48
        try {
49
            for (int w = 0; w < WAIT_SECONDS; w++) {
7✔
50
                log.info("Waited {} seconds...", w);
5✔
51
                Thread.sleep(1000);
2✔
52
            }
53
        } catch (InterruptedException ex) {
×
54
            // ignore
55
        }
1✔
56

57
        log.info("Loading the local list of nanopubs...");
3✔
58
        load();
1✔
59
        return true;
2✔
60
    }
61

62
    static void load() {
63
        if (!loadUrisFile.exists()) {
3✔
64
            log.info("No local nanopub URI file found.");
4✔
65
        } else {
66
            try (BufferedReader reader = new BufferedReader(new FileReader(loadUrisFile))) {
8✔
67
                String line = reader.readLine();
3✔
68
                while (line != null) {
2✔
69
                    NanopubLoader.load(line);
2✔
70
                    line = reader.readLine();
4✔
71
                }
72
            } catch (IOException ex) {
×
73
                log.info("Loading nanopubs failed.", ex);
×
74
            }
1✔
75
        }
76
        if (!loadNanopubsFile.exists()) {
3✔
77
            log.info("No local nanopub file found.");
4✔
78
        } else {
79
            try {
80
                MultiNanopubRdfHandler.process(RDFFormat.TRIG, loadNanopubsFile, np -> NanopubLoader.load(np, -1));
×
81
            } catch (IOException | MalformedNanopubException ex) {
1✔
82
                log.info("Loading nanopubs failed.", ex);
4✔
83
            }
×
84
        }
85
    }
1✔
86

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