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

knowledgepixels / nanopub-query / 16989716008

15 Aug 2025 12:12PM UTC coverage: 25.926% (+0.1%) from 25.779%
16989716008

push

github

ashleycaselli
refactor: update code style and files formatting

122 of 494 branches covered (24.7%)

Branch coverage included in aggregate %.

333 of 1261 relevant lines covered (26.41%)

1.29 hits per line

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

0.0
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

7
import java.io.BufferedReader;
8
import java.io.File;
9
import java.io.FileReader;
10
import java.io.IOException;
11

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

17
    private LocalNanopubLoader() {
18
    }  // no instances allowed
19

20
    /**
21
     * File containing URIs of nanopubs to load.
22
     */
23
    public final static File loadUrisFile = new File("load/nanopub-uris.txt");
×
24

25
    /**
26
     * File containing nanopubs in TRIG format to load.
27
     */
28
    public final static File loadNanopubsFile = new File("load/nanopubs.trig.gz");
×
29

30
    private static final int WAIT_SECONDS = Utils.getEnvInt("INIT_WAIT_SECONDS", 120);
×
31

32
    /**
33
     * Load nanopubs from local files.
34
     *
35
     * @return true if local nanopubs were found and loaded, false otherwise
36
     */
37
    public static boolean init() {
38
        if (!(loadNanopubsFile.exists() || loadNanopubsFile.exists())) {
×
39
            System.err.println("No local nanopub files for loading found. Moving on to loading " +
×
40
                    "via Jelly...");
41
            return false;
×
42
        }
43
        System.err.println("Waiting " + WAIT_SECONDS + " seconds to make sure the triple store is up...");
×
44
        try {
45
            for (int w = 0; w < WAIT_SECONDS; w++) {
×
46
                System.err.println("Waited " + w + " seconds...");
×
47
                Thread.sleep(1000);
×
48
            }
49
        } catch (InterruptedException ex) {
×
50
            ex.printStackTrace();
×
51
        }
×
52

53
        System.err.println("Loading the local list of nanopubs...");
×
54
        load();
×
55
        return true;
×
56
    }
57

58
    private static void load() {
59
        if (!loadUrisFile.exists()) {
×
60
            System.err.println("No local nanopub URI file found.");
×
61
        } else {
62
            try (BufferedReader reader = new BufferedReader(new FileReader(loadUrisFile))) {
×
63
                String line = reader.readLine();
×
64
                while (line != null) {
×
65
                    NanopubLoader.load(line);
×
66
                    line = reader.readLine();
×
67
                }
68
            } catch (IOException ex) {
×
69
                ex.printStackTrace();
×
70
            }
×
71
        }
72
        if (!loadNanopubsFile.exists()) {
×
73
            System.err.println("No local nanopub file found.");
×
74
        } else {
75
            try {
76
                MultiNanopubRdfHandler.process(RDFFormat.TRIG, loadNanopubsFile, np -> NanopubLoader.load(np, -1));
×
77
            } catch (IOException | MalformedNanopubException ex) {
×
78
                ex.printStackTrace();
×
79
            }
×
80
        }
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