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

pkiraly / metadata-qa-marc / #1597

22 Nov 2025 11:44AM UTC coverage: 90.275% (+0.02%) from 90.258%
#1597

push

pkiraly
Add JavaDoc to quarto based documentation #713

36734 of 40691 relevant lines covered (90.28%)

0.9 hits per line

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

0.0
/src/main/java/de/gwdg/metadataqa/marc/cli/utils/MarcJsonToSolr.java
1
package de.gwdg.metadataqa.marc.cli.utils;
2

3
import de.gwdg.metadataqa.api.model.selector.JsonSelector;
4
import de.gwdg.metadataqa.api.model.XmlFieldInstance;
5
import de.gwdg.metadataqa.marc.MarcFactory;
6
import de.gwdg.metadataqa.marc.dao.record.BibliographicRecord;
7
import de.gwdg.metadataqa.marc.datastore.MarcSolrClient;
8

9
import java.io.IOException;
10
import java.nio.charset.Charset;
11
import java.nio.file.Files;
12
import java.nio.file.Paths;
13
import java.util.List;
14
import java.util.logging.Level;
15
import java.util.logging.Logger;
16

17
/**
18
 * usage:
19
 * java -cp target/qa-catalogue-0.1-SNAPSHOT-jar-with-dependencies.jar de.gwdg.metadataqa.marc.cli.SolrKeyGenerator http://localhost:8983/solr/tardit 0001.0000000.formatted.json
20
 */
21
public class MarcJsonToSolr {
×
22

23
  private static final Logger logger = Logger.getLogger(MarcJsonToSolr.class.getCanonicalName());
×
24

25
  public static void main(String[] args) {
26
    if (args.length < 2) {
×
27
      System.err.println("Please provide a Solr URL and file name!");
×
28
      System.exit(1);
×
29
    }
30
    long start = System.currentTimeMillis();
×
31

32
    String url = args[0];
×
33

34
    String relativeFileName = args[1];
×
35
    var path = Paths.get(relativeFileName);
×
36
    String fileName = path.getFileName().toString();
×
37

38
    boolean doCommits = true;
×
39
    if (args.length > 2) {
×
40
      if (args[2].equals("doCommit=true"))
×
41
        doCommits = true;
×
42
      else if (args[2].equals("doCommit=false"))
×
43
        doCommits = false;
×
44
    }
45

46
    logger.log(Level.INFO, "Solr URL: {0}, file: {1} (do commits: {2})", new Object[]{url, fileName, doCommits});
×
47

48
    MarcSolrClient client = new MarcSolrClient(url);
×
49
    JsonSelector<? extends XmlFieldInstance> cache;
50
    List<String> records;
51
    try {
52
      records = Files.readAllLines(path, Charset.defaultCharset());
×
53
      var i = 0;
×
54
      for (String marcRecordLine : records) {
×
55
        i++;
×
56
        cache = new JsonSelector(marcRecordLine);
×
57
        BibliographicRecord marcRecord = MarcFactory.create(cache);
×
58
        client.indexMap(marcRecord.getId(), marcRecord.getKeyValuePairs());
×
59

60
        if (i % 1000 == 0) {
×
61
          if (doCommits)
×
62
            client.commit();
×
63
          logger.log(Level.INFO, "{0}/{1}) {2}", new Object[]{fileName, i, marcRecord.getId()});
×
64
        }
65
      }
×
66
      if (doCommits)
×
67
        client.commit();
×
68
      logger.info("end of cycle");
×
69
    } catch (IOException ex) {
×
70
      logger.severe(ex.toString());
×
71
      System.exit(1);
×
72
    }
×
73
    long end = System.currentTimeMillis();
×
74

75
    logger.log(Level.INFO, "Bye! It took: {0} s", new Object[]{String.format("%.1f", (float) (end - start) / 1000)});
×
76
  }
×
77
}
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