Skip to content

Commit

Permalink
WIP - Checkpoint commit for Index generation for IUCN and ID lookups …
Browse files Browse the repository at this point in the history
…for WoRMS #5

Switch to using opencsv
#1321
  • Loading branch information
djtfmartin committed Jun 6, 2024
1 parent 08a8c4b commit f0eb2c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class DatasetIndex {
final static NameUsageMatch NO_MATCH = NameUsageMatch.builder()
.diagnostics(
Diagnostics.builder()
.confidence(100)
.matchType(MatchType.NONE)
.build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
import java.util.Optional;
import io.swagger.v3.oas.annotations.media.Schema;

import life.catalogue.api.vocab.TaxonomicStatus;

import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import org.gbif.nameparser.api.Rank;

/**
Expand Down Expand Up @@ -41,6 +37,8 @@ public class NameUsageMatch implements LinneanClassification {
List<Status> additionalStatus = new ArrayList<>();

private String nameFor(Rank rank) {
if (classification == null)
return null;
return getClassification().stream()
.filter(c -> c.getRank().equals(rank))
.findFirst()
Expand All @@ -49,6 +47,8 @@ private String nameFor(Rank rank) {
}

private String keyFor(Rank rank) {
if (classification == null)
return null;
return getClassification().stream()
.filter(c -> c.getRank().equals(rank))
.findFirst()
Expand All @@ -57,8 +57,11 @@ private String keyFor(Rank rank) {
}

private void setNameFor(String value, Rank rank) {
if (classification == null) {
this.classification = new ArrayList<>();
}
Optional<RankedName> name =
this.getClassification().stream().filter(c -> c.getRank().equals(rank)).findFirst();
this.classification.stream().filter(c -> c.getRank().equals(rank)).findFirst();
if (name.isPresent()) {
name.get().setName(value);
name.get().setCanonicalName(value);
Expand All @@ -67,7 +70,7 @@ private void setNameFor(String value, Rank rank) {
newRank.setRank(rank);
newRank.setName(value);
newRank.setCanonicalName(value);
this.getClassification().add(newRank);
this.classification.add(newRank);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static NameUsageMatch newNameUsageMatch(
String subgenusKey,
String speciesKey) {

NameUsageMatch m = NameUsageMatch.builder().build();
NameUsageMatch m = NameUsageMatch.builder().diagnostics(Diagnostics.builder().build()).build();
m.setUsage(new RankedName());
m.getUsage().setKey(usageKey);
m.getUsage().setName(scientificName);
Expand Down

0 comments on commit f0eb2c7

Please sign in to comment.