-
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 #163: PICA: add crosswalnk between MARC and PICA
- Loading branch information
Showing
5 changed files
with
2,311 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/main/java/de/gwdg/metadataqa/marc/utils/pica/crosswalk/Crosswalk.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,45 @@ | ||
package de.gwdg.metadataqa.marc.utils.pica.crosswalk; | ||
|
||
import com.opencsv.bean.CsvBindByPosition; | ||
|
||
public class Crosswalk { | ||
@CsvBindByPosition(position = 0) | ||
private String pica; | ||
@CsvBindByPosition(position = 1) | ||
private String picaUf; | ||
@CsvBindByPosition(position = 2) | ||
private String marc21; | ||
|
||
public String getPica() { | ||
return pica; | ||
} | ||
|
||
public void setPica(String pica) { | ||
this.pica = pica; | ||
} | ||
|
||
public String getPicaUf() { | ||
return picaUf; | ||
} | ||
|
||
public void setPicaUf(String picaUf) { | ||
this.picaUf = picaUf; | ||
} | ||
|
||
public String getMarc21() { | ||
return marc21; | ||
} | ||
|
||
public void setMarc21(String marc21) { | ||
this.marc21 = marc21; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Crosswalk{" + | ||
"pica='" + pica + '\'' + | ||
", picaUf='" + picaUf + '\'' + | ||
", marc21='" + marc21 + '\'' + | ||
'}'; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/de/gwdg/metadataqa/marc/utils/pica/crosswalk/PicaMarcCrosswalkReader.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,32 @@ | ||
package de.gwdg.metadataqa.marc.utils.pica.crosswalk; | ||
|
||
import com.opencsv.CSVParserBuilder; | ||
import com.opencsv.CSVReader; | ||
import com.opencsv.CSVReaderBuilder; | ||
import com.opencsv.bean.CsvToBean; | ||
import com.opencsv.bean.CsvToBeanBuilder; | ||
|
||
import java.io.InputStreamReader; | ||
import java.util.List; | ||
|
||
public class PicaMarcCrosswalkReader { | ||
private static List<Crosswalk> mapping; | ||
|
||
public static List<Crosswalk> read() { | ||
if (mapping == null) | ||
initialize(); | ||
|
||
return mapping; | ||
} | ||
|
||
private static void initialize() { | ||
InputStreamReader streamReader = new InputStreamReader(PicaMarcCrosswalkReader.class.getResourceAsStream("/pica/pica-marc.tsv")); | ||
CSVReader reader = new CSVReaderBuilder(streamReader) | ||
.withCSVParser(new CSVParserBuilder().withSeparator('\t').build()) | ||
.withSkipLines(1) | ||
.build(); | ||
CsvToBean<Crosswalk> csvToBean = new CsvToBeanBuilder<Crosswalk>(reader).withType(Crosswalk.class).build(); | ||
|
||
mapping = csvToBean.parse(); | ||
} | ||
} |
Oops, something went wrong.