-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #142: calculating PICA completeness
- Loading branch information
Showing
7 changed files
with
20,861 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/de/gwdg/metadataqa/marc/cli/plugin/CompletenessFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.gwdg.metadataqa.marc.cli.plugin; | ||
|
||
import de.gwdg.metadataqa.marc.cli.parameters.CompletenessParameters; | ||
|
||
public class CompletenessFactory { | ||
|
||
public static CompletenessPlugin create(CompletenessParameters parameters) { | ||
if (parameters.isMarc21()) { | ||
return new Marc21CompletenessPlugin(parameters); | ||
} else if (parameters.isPica()) { | ||
return new PicaCompletenessPlugin(parameters); | ||
} | ||
return null; | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/de/gwdg/metadataqa/marc/cli/plugin/CompletenessPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package de.gwdg.metadataqa.marc.cli.plugin; | ||
|
||
import de.gwdg.metadataqa.marc.dao.MarcRecord; | ||
|
||
public interface CompletenessPlugin { | ||
String getDocumentType(MarcRecord marcRecord); | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/de/gwdg/metadataqa/marc/cli/plugin/Marc21CompletenessPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package de.gwdg.metadataqa.marc.cli.plugin; | ||
|
||
import de.gwdg.metadataqa.marc.cli.parameters.CompletenessParameters; | ||
import de.gwdg.metadataqa.marc.dao.MarcRecord; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class Marc21CompletenessPlugin implements CompletenessPlugin { | ||
private final CompletenessParameters parameters; | ||
|
||
public Marc21CompletenessPlugin(CompletenessParameters parameters) { | ||
this.parameters = parameters; | ||
} | ||
|
||
@Override | ||
public String getDocumentType(MarcRecord marcRecord) { | ||
return marcRecord.getType().getValue(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/de/gwdg/metadataqa/marc/cli/plugin/PicaCompletenessPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package de.gwdg.metadataqa.marc.cli.plugin; | ||
|
||
import de.gwdg.metadataqa.marc.cli.parameters.CompletenessParameters; | ||
import de.gwdg.metadataqa.marc.dao.MarcRecord; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class PicaCompletenessPlugin implements CompletenessPlugin { | ||
private final CompletenessParameters parameters; | ||
private final String field; | ||
private final String subfield; | ||
|
||
public PicaCompletenessPlugin(CompletenessParameters parameters) { | ||
this.parameters = parameters; | ||
String[] parts = parameters.getPicaRecordTypeField().split(Pattern.quote(parameters.getPicaSubfieldSeparator())); | ||
field = parts[0]; | ||
subfield = parts[1]; | ||
} | ||
|
||
@Override | ||
public String getDocumentType(MarcRecord marcRecord) { | ||
return marcRecord.getDatafield(field).get(0).getSubfield(subfield).get(0).getValue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.