Skip to content

Commit

Permalink
Update to newest GBIF API, and GBIF common for bugfix with CSV sorting.
Browse files Browse the repository at this point in the history
  • Loading branch information
MattBlissett committed Apr 9, 2018
1 parent a67797b commit 401c9da
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
<dwc-api.version>1.17</dwc-api.version>
<dwca-io.version>1.31</dwca-io.version>
<freemarker.version>2.3.26-incubating</freemarker.version>
<gbif-api.version>0.56</gbif-api.version>
<gbif-api.version>0.61</gbif-api.version>
<gbif-common-ws.version>0.41</gbif-common-ws.version>
<gbif-common.version>0.36</gbif-common.version>
<gbif-common.version>0.38</gbif-common.version>
<gbif-doi.version>1.5</gbif-doi.version>
<gbif-metadata-profile.version>1.1.1</gbif-metadata-profile.version>
<gbif-parsers.version>0.31</gbif-parsers.version>
Expand Down Expand Up @@ -102,7 +102,7 @@
<post>[email protected]</post>
<subscribe>[email protected]</subscribe>
<unsubscribe>[email protected]</unsubscribe>
<archive>http://lists.gbif.org/pipermail/ipt/</archive>
<archive>https://lists.gbif.org/pipermail/ipt/</archive>
</mailingList>
</mailingLists>

Expand Down Expand Up @@ -522,7 +522,7 @@
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation-api.version}</version>
</dependency>
</dependency>

<!-- Simple XML Parsing -->
<dependency>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/gbif/ipt/model/Resource.java
Original file line number Diff line number Diff line change
Expand Up @@ -1215,8 +1215,8 @@ public synchronized void updateAlternateIdentifierForDOI() {
if (doi != null) {
// retrieve a list of the resource's alternate identifiers
List<String> ids = eml.getAlternateIdentifiers();
if (identifierStatus.equals(IdentifierStatus.PUBLIC_PENDING_PUBLICATION) || identifierStatus
.equals(IdentifierStatus.PUBLIC)) {
if (identifierStatus.equals(IdentifierStatus.PUBLIC_PENDING_PUBLICATION) ||
identifierStatus.equals(IdentifierStatus.PUBLIC)) {
// make sure the DOI always appears first
List<String> reorderedList = Lists.newArrayList();
reorderedList.add(doi.toString());
Expand All @@ -1232,8 +1232,8 @@ public synchronized void updateAlternateIdentifierForDOI() {
}
ids.addAll(reorderedList);
log.debug("DOI=" + doi.toString() + " added to resource's list of alt ids as first element");
} else if (identifierStatus.equals(IdentifierStatus.UNAVAILABLE) || identifierStatus
.equals(IdentifierStatus.UNRESERVED)) {
} else if (identifierStatus.equals(IdentifierStatus.UNAVAILABLE) ||
identifierStatus.equals(IdentifierStatus.UNRESERVED)) {
for (Iterator<String> iterator = ids.iterator(); iterator.hasNext(); ) {
String id = iterator.next();
// make sure a DOI that has been made unavailable, or that has been deleted, no longer appears in the list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.gbif.ipt.service.manage.SourceManager;
import org.gbif.utils.file.ClosableIterator;
import org.gbif.utils.file.ClosableReportingIterator;
import org.gbif.utils.file.csv.UnkownDelimitersException;
import org.gbif.utils.file.csv.UnknownDelimitersException;

import java.io.BufferedWriter;
import java.io.File;
Expand Down Expand Up @@ -96,7 +96,7 @@ public SqlColumnIterator(SqlSource source, int column, int limit) throws SQLExce

/**
* SqlColumnIterator constructor
*
*
* @param source of the sql data
* @param column to inspect, zero based numbering as used in the dwc archives
* @param sql statement to query in the sql source
Expand Down Expand Up @@ -306,16 +306,16 @@ private TextFileSource addTextFile(File file) throws ImportException {
// anaylze individual files using the dwca reader
Archive arch = ArchiveFactory.openArchive(file);
copyArchiveFileProperties(arch.getCore(), src);
} catch (UnknownDelimitersException e) {
// this file is invalid
log.warn(e.getMessage());
throw new ImportException(e);
} catch (IOException e) {
log.warn(e.getMessage());
throw new ImportException(e);
} catch (UnsupportedArchiveException e) {
// fine, cant read it with dwca library, but might still be a valid file for manual setup
log.warn(e.getMessage());
} catch (UnkownDelimitersException e) {
// this file is invalid
log.warn(e.getMessage());
throw new ImportException(e);
}
return src;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/gbif/ipt/task/GenerateDwca.java
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ private void applyTranslations(PropertyMapping[] inCols, String[] in, String[] r
// use DOI for datasetID property?
if (pm.getTerm().qualifiedName().equalsIgnoreCase(Constants.DWC_DATASET_ID) && doiUsedForDatasetId
&& doi != null) {
val = doi.toString();
val = "doi:" + doi.getDoiName();
}
}
// add value to data file record
Expand Down
18 changes: 10 additions & 8 deletions src/test/java/org/gbif/ipt/model/ResourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ public void testUpdateAlternateIdentifierForDOICase1() {
r.updateAlternateIdentifierForDOI();

assertEquals(1, r.getEml().getAlternateIdentifiers().size());
assertEquals("doi:10.5072/case1", r.getEml().getAlternateIdentifiers().get(0));
assertEquals("10.5072/case1", r.getEml().getAlternateIdentifiers().get(0));
}

/**
Expand All @@ -707,7 +707,7 @@ public void testUpdateAlternateIdentifierForDOICase2() {
r.updateAlternateIdentifierForDOI();

assertEquals(3, r.getEml().getAlternateIdentifiers().size());
assertEquals("doi:10.5072/case2", r.getEml().getAlternateIdentifiers().get(0));
assertEquals("10.5072/case2", r.getEml().getAlternateIdentifiers().get(0));
assertEquals("alt-id-1", r.getEml().getAlternateIdentifiers().get(1));
assertEquals("alt-id-2", r.getEml().getAlternateIdentifiers().get(2));
}
Expand All @@ -732,7 +732,7 @@ public void testUpdateAlternateIdentifierForDOICase3() {
r.updateAlternateIdentifierForDOI();

assertEquals(3, r.getEml().getAlternateIdentifiers().size());
assertEquals("doi:10.5072/case3", r.getEml().getAlternateIdentifiers().get(0));
assertEquals("10.5072/case3", r.getEml().getAlternateIdentifiers().get(0));
assertEquals("alt-id-1", r.getEml().getAlternateIdentifiers().get(1));
assertEquals("doi:10.5077/other", r.getEml().getAlternateIdentifiers().get(2));
}
Expand All @@ -747,16 +747,18 @@ public void testUpdateAlternateIdentifierForDOICase4() {
r.setDoi(new DOI("10.5072/case4"));
r.setIdentifierStatus(IdentifierStatus.UNAVAILABLE);

r.getEml().getAlternateIdentifiers().add("doi:10.5072/case4");
r.getEml().getAlternateIdentifiers().add("doi:10.5077/other");
r.getEml().getAlternateIdentifiers().add("10.5072/case4");
r.getEml().getAlternateIdentifiers().add("10.5077/other");
assertEquals(2, r.getEml().getAlternateIdentifiers().size());
assertEquals("doi:10.5072/case4", r.getEml().getAlternateIdentifiers().get(0));
assertEquals("doi:10.5077/other", r.getEml().getAlternateIdentifiers().get(1));
assertEquals("10.5072/case4", r.getEml().getAlternateIdentifiers().get(0));
assertEquals("10.5077/other", r.getEml().getAlternateIdentifiers().get(1));

r.updateAlternateIdentifierForDOI();

System.out.println(r.getEml().getAlternateIdentifiers());

assertEquals(1, r.getEml().getAlternateIdentifiers().size());
assertEquals("doi:10.5077/other", r.getEml().getAlternateIdentifiers().get(0));
assertEquals("10.5077/other", r.getEml().getAlternateIdentifiers().get(0));
}

/**
Expand Down

0 comments on commit 401c9da

Please sign in to comment.