Skip to content

Commit

Permalink
Work in progress adding APNI cultivar name lookup to implementation of
Browse files Browse the repository at this point in the history
…tdwg/bdq#70 VALIDATION_TAXON_UNAMBIGUOUS
  • Loading branch information
chicoreus committed Jul 24, 2024
1 parent e9005f4 commit dfdf24d
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/org/filteredpush/qc/sciname/DwCSciNameDQ.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.datakurator.ffdq.annotations.*;
import org.datakurator.ffdq.api.DQResponse;
import org.datakurator.ffdq.model.ResultState;
import org.filteredpush.qc.sciname.services.APNIService;
import org.filteredpush.qc.sciname.services.GBIFService;
import org.filteredpush.qc.sciname.services.IRMNGService;
import org.filteredpush.qc.sciname.services.ServiceException;
Expand Down Expand Up @@ -978,6 +979,8 @@ public static DQResponse<ComplianceValue> validationTaxonUnambiguous(
matchList = WoRMSService.lookupTaxon(lookMeUp, taxon.getScientificNameAuthorship());
} else if (sourceAuthority.getAuthority().equals(EnumSciNameSourceAuthority.IRMNG)) {
matchList = IRMNGService.lookupTaxon(lookMeUp, taxon.getScientificNameAuthorship());
} else if (sourceAuthority.getAuthority().equals(EnumSciNameSourceAuthority.ANSL_APNI)) {
matchList = APNIService.lookupTaxon(lookMeUp, taxon.getScientificNameAuthorship());
} else {
throw new UnsupportedSourceAuthorityException("Source Authority Not Implemented");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public enum EnumSciNameSourceAuthority {
GBIF_ARBITRARY,
WORMS,
IRMNG,
ANSL_APNI,
INVALID;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public SciNameSourceAuthority(String authorityString) throws SourceAuthorityExce
this.authority = EnumSciNameSourceAuthority.IRMNG;
} else if (authorityString.toUpperCase().equals("IRMNG")) {
this.authority = EnumSciNameSourceAuthority.IRMNG;
} else if (authorityString.toUpperCase().equals("https://api.biodiversity.org.au/name/check?dataset=APNI".toUpperCase())) {
this.authority = EnumSciNameSourceAuthority.ANSL_APNI;
} else if (authorityString.toUpperCase().equals("APNI")) {
this.authority = EnumSciNameSourceAuthority.ANSL_APNI;
} else if (authorityString.toUpperCase().equals(EnumSciNameSourceAuthority.GBIF_BACKBONE_TAXONOMY.getName())) {
this.authority = EnumSciNameSourceAuthority.GBIF_BACKBONE_TAXONOMY;
} else if (authorityString.toUpperCase().equals(EnumSciNameSourceAuthority.GBIF_COL.getName())) {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/filteredpush/qc/sciname/SciNameUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.commons.cli.ParseException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.filteredpush.qc.sciname.services.APNIService;
import org.filteredpush.qc.sciname.services.GBIFService;
import org.filteredpush.qc.sciname.services.GNIService;
import org.filteredpush.qc.sciname.services.IRMNGService;
Expand Down Expand Up @@ -214,6 +215,14 @@ public static boolean validateTaxonID(String taxonID, SciNameSourceAuthority sou
logger.debug(match.getScientificName());
result=true;
}
} else if (sourceAuthority.getAuthority().equals(EnumSciNameSourceAuthority.ANSL_APNI)) {
// TODO implement
String id = taxonID.replace("https://id.biodiversity.org.au/name/apni/", "");
NameUsage match = APNIService.lookupTaxonByID(id);
if (match!=null) {
logger.debug(match.getScientificName());
result=true;
}
} else {
throw new UnsupportedSourceAuthorityException("Source Authority Not Implemented");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* APNIService.java
*
* Copyright 2024 President and Fellows of Harvard College
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.filteredpush.qc.sciname.services;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.filteredpush.qc.sciname.IDFormatException;
import org.irmng.aphia.v1_0.handler.ApiException;

import edu.harvard.mcz.nametools.NameUsage;

/**
* @author mole
*
*/
public class APNIService {

private static final Log logger = LogFactory.getLog(APNIService.class);

private static String endpoint = "https://api.biodiversity.org.au/name/check?dataset=APNI";

public static NameUsage lookupTaxonByID(String apniID) throws IDFormatException, ApiException {
NameUsage result = new NameUsage();
// TODO: Implement
// https://id.biodiversity.org.au/name/apni/100473

return result;
}

public static List<NameUsage> lookupTaxon(String taxon, String authorship) throws ApiException {
List<NameUsage> result = new ArrayList<NameUsage>();
// TODO: Implement
// https://api.biodiversity.org.au/name/check?dataset=APNI&q=Solanum%20centrale%20%E2%80%98Desert%20tang%E2%80%99

return result;

}
}

0 comments on commit dfdf24d

Please sign in to comment.