Skip to content

Commit

Permalink
issue #187: add parameter to exclude issue types
Browse files Browse the repository at this point in the history
  • Loading branch information
pkiraly committed Nov 6, 2022
1 parent 2cce0a0 commit 6224d50
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package de.gwdg.metadataqa.marc.cli.parameters;

import de.gwdg.metadataqa.marc.model.validation.ValidationErrorFormat;
import de.gwdg.metadataqa.marc.model.validation.ValidationErrorType;
import org.apache.commons.cli.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class ValidatorParameters extends CommonParameters implements Serializable {
public static final String DEFAULT_FILE_NAME = "validation-report.txt";
Expand All @@ -17,6 +20,7 @@ public class ValidatorParameters extends CommonParameters implements Serializabl
private boolean isOptionSet;
private boolean emptyLargeCollectors = false;
private boolean collectAllErrors = false;
private List<ValidationErrorType> ignorableIssueTypes;

protected void setOptions() {
if (!isOptionSet) {
Expand All @@ -29,6 +33,7 @@ protected void setOptions() {
options.addOption("r", "format", true, "specify a format");
options.addOption("w", "emptyLargeCollectors", false, "empty large collectors");
options.addOption("t", "collectAllErrors", false, "collect all errors (useful only for validating small number of records)");
options.addOption("i", "ignorableIssueTypes", true, "comma separated list of issue types not to collect");
isOptionSet = true;
}
}
Expand Down Expand Up @@ -67,6 +72,20 @@ public ValidatorParameters(String[] arguments) throws ParseException {
emptyLargeCollectors = true;

setCollectAllErrors(cmd.hasOption("collectAllErrors"));

if (cmd.hasOption("ignorableIssueTypes")) {
setIgnorableIssueTypes(cmd.getOptionValue("ignorableIssueTypes"));
}
}

private void setIgnorableIssueTypes(String inputParameter) {
ignorableIssueTypes = new ArrayList<>();
String[] issueTypes = inputParameter.split(",");
for (String code : issueTypes) {
ValidationErrorType type = ValidationErrorType.byCode(code);
if (type != null)
ignorableIssueTypes.add(type);
}
}

public String getDetailsFileName() {
Expand Down Expand Up @@ -135,6 +154,10 @@ public void setCollectAllErrors(boolean collectAllErrors) {
this.collectAllErrors = collectAllErrors;
}

public List<ValidationErrorType> getIgnorableIssueTypes() {
return ignorableIssueTypes;
}

@Override
public String formatParameters() {
String text = super.formatParameters();
Expand Down

0 comments on commit 6224d50

Please sign in to comment.