Skip to content

Commit

Permalink
fix source vs sources
Browse files Browse the repository at this point in the history
  • Loading branch information
pasqLisena committed Jun 22, 2018
1 parent c552ed8 commit c12f911
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'org.doremus'
version '1.1.2'
version '1.2.0'

sourceCompatibility = 1.8

Expand Down
23 changes: 20 additions & 3 deletions src/main/java/org/doremus/isnimatcher/ISNIRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,23 @@ public class ISNIRecord {
public List<ExternalInformation> externalInformations;

@XmlElement(name = "source")
public List<Source> sources;
private List<Source> sources1;

@XmlElement(name = "sources")
private List<Source> sources2;

private List<Source> source = null;

private String body;

public List<Source> getSources(){
if (source == null) {
source = sources1;
if(sources1 ==null) source = sources2;
else source.addAll(sources2);
}
return source;
}

private void setBody(String body) {
this.body = body;
Expand Down Expand Up @@ -84,6 +97,10 @@ record = record.replaceAll("</?personOrFiction>", "");
public String getViafURI() {
for (ExternalInformation ex : externalInformations)
if (ex.isType("viaf")) return ex.URI;

for (Source s : getSources())
if ("VIAF".equals(s.codeOfSource)) return s.asViafURI();

return null;
}

Expand Down Expand Up @@ -130,15 +147,15 @@ public String getDBpediaUri() {
}

public String getMusicBrainzUri() {
for (Source s : sources) {
for (Source s : getSources()) {
if ("MUBZ".equals(s.codeOfSource))
return s.asMusicBrainzURI();
}
return null;
}

public String getBNFUri() {
for (Source s : sources) {
for (Source s : getSources()) {
if ("BNF".equals(s.codeOfSource))
return s.asBNFUri();
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/doremus/isnimatcher/Source.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class Source {
private static final String MUSICBRAINZ_BASE = "https://musicbrainz.org/artist/";
private static final String BNF_BASE = "http://catalogue.bnf.fr/ark:/12148/cb";
private static final String VIAF_BASE = "https://viaf.org/viaf/";

@XmlElement(name = "codeOfSource")
public String codeOfSource;
Expand All @@ -24,4 +25,8 @@ public String asMusicBrainzURI() {
public String asBNFUri() {
return BNF_BASE + sourceIdentifier + "b";
}

public String asViafURI() {
return VIAF_BASE + sourceIdentifier;
}
}
6 changes: 6 additions & 0 deletions src/test/java/ISNITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public void getByISNICode() throws IOException {
assertEquals("Beethoven", r.personalNames.get(0).surname);
}

@Test
public void getViaf() throws IOException {
ISNIRecord r = ISNI.get("000000007368351X");
assertEquals("https://viaf.org/viaf/19620875", r.getViafURI());
}

@Test
public void searchWithNameAndDate() throws IOException {
String str = "Beethoven, Ludwig van";
Expand Down

0 comments on commit c12f911

Please sign in to comment.