Skip to content

Commit

Permalink
Remove DarwinCoreRecord and DarwinCoreTaxon.
Browse files Browse the repository at this point in the history
These have not been kept up to date with changes in the standard.

Resolves #44.
  • Loading branch information
MattBlissett committed Mar 19, 2018
1 parent c1341f1 commit 58564c3
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 2,387 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>

<artifactId>dwca-io</artifactId>
<version>1.33-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Darwin Core Archive IO Library</name>
Expand Down
89 changes: 0 additions & 89 deletions src/main/java/org/gbif/dwca/io/Archive.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@
import org.gbif.api.model.registry.Dataset;
import org.gbif.dwc.DwcFiles;
import org.gbif.dwc.DwcLayout;
import org.gbif.dwc.terms.DcTerm;
import org.gbif.dwc.terms.DwcTerm;
import org.gbif.dwc.terms.Term;
import org.gbif.dwca.record.DarwinCoreRecord;
import org.gbif.dwca.record.Record;
import org.gbif.dwca.record.RecordImpl;
import org.gbif.dwca.record.RecordIterator;
import org.gbif.dwca.record.StarRecord;
import org.gbif.dwca.record.StarRecordImpl;
import org.gbif.registry.metadata.parse.DatasetParser;
import org.gbif.utils.file.ClosableIterator;
import org.gbif.utils.file.FileUtils;
import org.gbif.utils.file.csv.CSVReader;

import java.io.File;
import java.io.FilenameFilter;
Expand Down Expand Up @@ -48,81 +43,6 @@ public class Archive implements Iterable<StarRecord> {
public static final String CONSTITUENT_DIR = "dataset";
public static final String META_FN = "meta.xml";

/**
* An iterator of fixed DarwinCoreRecords over the core file only. This iterator doesn't need any sorted data files
* as it doesn't deal with extensions.
*/
@Deprecated
static class ArchiveDwcIterator implements ClosableIterator<DarwinCoreRecord> {

private CSVReader coreReader;
private ArchiveFile core;
private int lineCount = 0;
private final RecordImpl record;
private boolean hasNext = true;
private final Set<Term> mappedTerms = new HashSet<Term>();

ArchiveDwcIterator(Archive archive) {
record = new RecordImpl(archive.getCore(), true, true);
core = archive.getCore();
// remember used DwC and DC terms
for (DwcTerm term : DwcTerm.values()) {
if (core.hasTerm(term)) {
mappedTerms.add(term);
}
}
for (DcTerm term : DcTerm.values()) {
if (core.hasTerm(term)) {
mappedTerms.add(term);
}
}
try {
coreReader = archive.getCore().getCSVReader();
// read first core row
record.setRow(coreReader.next());
if (!record.hasRow()) {
hasNext = false;
}
} catch (Exception e) {
hasNext = false;
LOG.warn("Exception caught", e);
}
}

public void close() {
coreReader.close();
}

public boolean hasNext() {
return hasNext;
}

public DarwinCoreRecord next() {
DarwinCoreRecord dwc = new DarwinCoreRecord();
lineCount++;
try {
for (Term term : mappedTerms) {
dwc.setProperty(term, record.value(term));
}
dwc.setId(record.id());
// read next line to see if it exists at all
record.setRow(coreReader.next());
if (!record.hasRow()) {
hasNext = false;
}

} catch (Exception e) {
LOG.warn("Bad row somewhere around core line: {}", lineCount, e);
}
return dwc;
}

public void remove() {
throw new UnsupportedOperationException("Cannot remove a row from archive files");
}

}

/**
* This class is kept for legacy reason, See {@link DwcFiles} for new usage.
*
Expand Down Expand Up @@ -377,15 +297,6 @@ public ClosableIterator<StarRecord> iteratorRaw() {
return new ArchiveIterator(this, false, false);
}

/**
* @return an iterator over simple darwin core records based on the core data file(s). The DarwinCoreRecord instance
* is reused to give better performance, so create a clone before referencing it.
*/
@Deprecated
public ClosableIterator<DarwinCoreRecord> iteratorDwc() {
return new ArchiveDwcIterator(this);
}

public void setCore(ArchiveFile core) {
core.setArchive(this);
this.core = core;
Expand Down
Loading

0 comments on commit 58564c3

Please sign in to comment.