Skip to content

Commit

Permalink
Merge pull request #310 from pkiraly/issue-309
Browse files Browse the repository at this point in the history
Fix #309
  • Loading branch information
pkiraly authored Sep 18, 2023
2 parents 2acad8d + f94586b commit 564581d
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void main(String[] args) {
processor = new AuthorityAnalysis(args);
} catch (ParseException e) {
System.err.println(createRow("ERROR. ", e.getLocalizedMessage()));
System.exit(0);
System.exit(1);
}
if (processor.getParameters().getArgs().length < 1) {
System.err.println("Please provide a MARC file name!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ public BLClassificationAnalysis(String[] args) throws ParseException {
readyToProcess = true;
}

public static void main(String[] args) throws ParseException {
public static void main(String[] args) {
BibliographicInputProcessor processor = null;
try {
processor = new BLClassificationAnalysis(args);
} catch (ParseException e) {
System.err.println("ERROR. " + e.getLocalizedMessage());
System.exit(0);
System.exit(1);
}

if (processor.getParameters().getArgs().length < 1) {
System.err.println("Please provide a MARC file name!");
System.exit(0);
System.exit(1);
}
if (processor.getParameters().doHelp()) {
processor.printHelp(processor.getParameters().getOptions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public static void main(String[] args) {
processor = new ClassificationAnalysis(args);
} catch (ParseException e) {
System.err.println(createRow("ERROR. ", e.getLocalizedMessage()));
// processor.printHelp(processor.getParameters().getOptions());
System.exit(0);
System.exit(1);
}
if (processor.getParameters().getArgs().length < 1) {
System.err.println("Please provide a MARC file name!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static void main(String[] args) {
processor = new Completeness(args);
} catch (ParseException e) {
System.err.println("ERROR. " + e.getLocalizedMessage());
System.exit(0);
System.exit(1);
}
if (processor.getParameters().getArgs().length < 1) {
System.err.println("Please provide a MARC file name!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void main(String[] args) {
processor = new DataElements(args);
} catch (ParseException e) {
System.err.println("ERROR. " + e.getLocalizedMessage());
System.exit(0);
System.exit(1);
}
if (processor.getParameters().getArgs().length < 1) {
System.err.println("Please provide a MARC file name!");
Expand Down
31 changes: 18 additions & 13 deletions src/main/java/de/gwdg/metadataqa/marc/cli/Formatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,25 @@ public Formatter(String[] args) throws ParseException {
readyToProcess = true;
}

public static void main(String[] args) throws ParseException {
public static void main(String[] args) {
System.err.println("'" + StringUtils.join(args, "', '") + "'");
BibliographicInputProcessor processor = new Formatter(args);
if (processor.getParameters().getArgs().length < 1) {
System.err.println("Please provide a MARC file name!");
System.exit(0);
}
if (processor.getParameters().doHelp()) {
processor.printHelp(processor.getParameters().getOptions());
System.exit(0);
try {
BibliographicInputProcessor processor = new Formatter(args);
if (processor.getParameters().getArgs().length < 1) {
System.err.println("Please provide a MARC file name!");
System.exit(1);
}
if (processor.getParameters().doHelp()) {
processor.printHelp(processor.getParameters().getOptions());
System.exit(0);
}
RecordIterator iterator = new RecordIterator(processor);
logger.info(processor.getParameters().formatParameters());
iterator.start();
} catch(Exception e) {
System.err.println("ERROR. " + e.getLocalizedMessage());
System.exit(1);
}
RecordIterator iterator = new RecordIterator(processor);
logger.info(processor.getParameters().formatParameters());
iterator.start();
}

@Override
Expand Down Expand Up @@ -193,4 +198,4 @@ public static String extractPicaDate(String dateInString) {
// LocalDate dateTime = LocalDate.parse(dateInString, formatter);
// return dateTime;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void main(String[] args) {
processor = new FunctionalAnalysis(args);
} catch (ParseException e) {
logger.log(Level.SEVERE, "FunctionalAnalysis", e);
System.exit(0);
System.exit(1);
}
if (processor.getParameters().getArgs().length < 1) {
logger.severe("Please provide a MARC file name!");
Expand Down
25 changes: 15 additions & 10 deletions src/main/java/de/gwdg/metadataqa/marc/cli/MarcToSolr.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,21 @@ private void initialize() {
}
}

public static void main(String[] args) throws ParseException {
MarcToSolr processor = new MarcToSolr(args);
processor.options.toString();
if (StringUtils.isBlank(((MarcToSolrParameters) processor.getParameters()).getSolrUrl())) {
System.err.println("Please provide a Solr URL and file name!");
System.exit(0);
public static void main(String[] args) {
try {
MarcToSolr processor = new MarcToSolr(args);
processor.options.toString();
if (StringUtils.isBlank(((MarcToSolrParameters) processor.getParameters()).getSolrUrl())) {
System.err.println("Please provide a Solr URL and file name!");
System.exit(1);
}

RecordIterator iterator = new RecordIterator(processor);
iterator.start();
} catch(Exception e) {
System.err.println("ERROR. " + e.getLocalizedMessage());
System.exit(1);
}

RecordIterator iterator = new RecordIterator(processor);
iterator.start();
}

@Override
Expand Down Expand Up @@ -172,4 +177,4 @@ public void printHelp(Options options) {
public boolean readyToProcess() {
return readyToProcess;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void main(String[] args) {
processor = new NetworkAnalysis(args);
} catch (ParseException e) {
System.err.println(createRow("ERROR. ", e.getLocalizedMessage()));
System.exit(0);
System.exit(1);
}
NetworkParameters params = (NetworkParameters)processor.getParameters();
NetworkAction action = params.getAction();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/de/gwdg/metadataqa/marc/cli/SerialScore.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public SerialScore(String[] args) throws ParseException {
readyToProcess = true;
}

public static void main(String[] args) throws ParseException {
public static void main(String[] args) {
BibliographicInputProcessor processor = null;
try {
processor = new SerialScore(args);
} catch (ParseException e) {
System.err.println("ERROR. " + e.getLocalizedMessage());
System.exit(0);
System.exit(1);
}

if (processor.getParameters().getArgs().length < 1) {
Expand Down Expand Up @@ -187,4 +187,4 @@ private void printFields() {
logger.log(Level.SEVERE, "printFields", e);
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/de/gwdg/metadataqa/marc/cli/Shacl4bib.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static void main(String[] args) {
processor = new Shacl4bib(args);
} catch (ParseException e) {
System.err.println("ERROR. " + e.getLocalizedMessage());
System.exit(0);
System.exit(1);
}
if (processor.getParameters().getArgs().length < 1) {
System.err.println("Please provide a MARC file name!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ public ShelfReadyCompleteness(String[] args) throws ParseException {
readyToProcess = true;
}

public static void main(String[] args) throws ParseException {
public static void main(String[] args) {
BibliographicInputProcessor processor = null;
try {
processor = new ShelfReadyCompleteness(args);
} catch (ParseException e) {
System.err.println("ERROR. " + e.getLocalizedMessage());
System.exit(0);
System.exit(1);
}

if (processor.getParameters().getArgs().length < 1) {
System.err.println("Please provide a MARC file name!");
System.exit(0);
System.exit(1);
}
if (processor.getParameters().doHelp()) {
processor.printHelp(processor.getParameters().getOptions());
Expand Down Expand Up @@ -199,4 +199,4 @@ private String transformPaths(Map<String, List<String>> value) {
}
return StringUtils.join(paths, ",");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ public ThompsonTraillCompleteness(String[] args) throws ParseException {
readyToProcess = true;
}

public static void main(String[] args) throws ParseException {
public static void main(String[] args) {
BibliographicInputProcessor processor = null;
try {
processor = new ThompsonTraillCompleteness(args);
} catch (ParseException e) {
System.err.println("ERROR. " + e.getLocalizedMessage());
System.exit(0);
System.exit(1);
}

if (processor.getParameters().getArgs().length < 1) {
System.err.println("Please provide a MARC file name!");
System.exit(0);
System.exit(1);
}
if (processor.getParameters().doHelp()) {
processor.printHelp(processor.getParameters().getOptions());
Expand Down Expand Up @@ -167,4 +167,4 @@ private void printFields() {
logger.log(Level.SEVERE, "printFields", e);
}
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/de/gwdg/metadataqa/marc/cli/ValidatorCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static void main(String[] args) {
processor = new ValidatorCli(args);
} catch (ParseException e) {
System.err.println("ERROR. " + e.getLocalizedMessage());
System.exit(0);
System.exit(1);
}
if (processor.getParameters().getArgs().length < 1) {
System.err.println("Please provide a MARC file name!");
Expand Down Expand Up @@ -657,4 +657,4 @@ public Counter(int count, int id) {
this.id = id;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ public class ParallelValidator {
ParallelValidator.class.getCanonicalName());
private static Options options = new Options();

public static void main(String[] args) throws ParseException {
public static void main(String[] args) {

final ValidatorCli validatorCli = new ValidatorCli(args);
ValidatorParameters params = validatorCli.getParameters();
final ValidatorConfiguration validatorConfiguration = validatorCli.getValidityConfiguration();
validatorCli.setDoPrintInProcessRecord(false);
try {
final ValidatorCli validatorCli = new ValidatorCli(args);
ValidatorParameters params = validatorCli.getParameters();
final ValidatorConfiguration validatorConfiguration = validatorCli.getValidityConfiguration();
validatorCli.setDoPrintInProcessRecord(false);

logger.info("Input file is " + params.getDetailsFileName());
SparkConf conf = new SparkConf().setAppName("MarcCompletenessCount");
try (JavaSparkContext context = new JavaSparkContext(conf)) {
logger.info("Input file is " + params.getDetailsFileName());
SparkConf conf = new SparkConf().setAppName("MarcCompletenessCount");

JavaSparkContext context = new JavaSparkContext(conf);
System.err.println(validatorCli.getParameters().formatParameters());

JavaRDD<String> inputFile = context.textFile(validatorCli.getParameters().getArgs()[0]);
Expand All @@ -54,6 +56,9 @@ public static void main(String[] args) throws ParseException {
}
);
baseCountsRDD.saveAsTextFile(validatorCli.getParameters().getDetailsFileName());
} catch(Exception e) {
e.printStackTrace();
System.exit(1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,14 @@ private boolean resolveCardinality(Cardinality cardinality) {
return cardinality.getCode().equals("R");
}

public static void main(String[] args) throws ParseException {
MappingToJson mapping = new MappingToJson(args);
mapping.build();
System.out.println(mapping.toJson());
public static void main(String[] args) {
try {
MappingToJson mapping = new MappingToJson(args);
mapping.build();
System.out.println(mapping.toJson());
} catch (ParseException e) {
System.err.println("ERROR. " + e.getLocalizedMessage());
System.exit(1);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class MarcJsonToSolr {
public static void main(String[] args) {
if (args.length < 2) {
System.err.println("Please provide a Solr URL and file name!");
System.exit(0);
System.exit(1);
}
long start = System.currentTimeMillis();

Expand Down Expand Up @@ -71,12 +71,10 @@ else if (args[2].equals("doCommit=false"))
logger.info("end of cycle");
} catch (IOException ex) {
logger.severe(ex.toString());
System.exit(0);
System.exit(1);
}
long end = System.currentTimeMillis();

logger.log(Level.INFO, "Bye! It took: {0} s", new Object[]{String.format("%.1f", (float) (end - start) / 1000)});

System.exit(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void processFile(String inputFileName) {
} catch (SolrServerException ex) {
if (processor.getParameters().doLog())
logger.severe(ex.toString());
System.exit(0);
System.exit(1);
} catch (Exception ex) {
if (processor.getParameters().doLog()) {
logger.severe("Other exception: " + ex.toString());
Expand All @@ -135,7 +135,7 @@ private void processFile(String inputFileName) {
}
}
logger.log(Level.SEVERE, "start", ex);
System.exit(0);
System.exit(1);
}
}

Expand Down Expand Up @@ -258,4 +258,4 @@ private static void printHelp(Options opions) {
public String getStatus() {
return status;
}
}
}

0 comments on commit 564581d

Please sign in to comment.