-// $Id$
/**
* Copyright (C) 2013 EDIT
* European Distributed Institute of Taxonomy
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
import eu.etaxonomy.cdm.api.service.pager.Pager;
+import eu.etaxonomy.cdm.common.URI;
import eu.etaxonomy.cdm.model.agent.AgentBase;
import eu.etaxonomy.cdm.model.agent.Person;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
import eu.etaxonomy.cdm.model.common.LSID;
import eu.etaxonomy.cdm.model.common.Language;
-import eu.etaxonomy.cdm.model.common.OriginalSourceType;
import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.FeatureNode;
-import eu.etaxonomy.cdm.model.description.FeatureTree;
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
import eu.etaxonomy.cdm.model.description.TaxonDescription;
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
import eu.etaxonomy.cdm.model.description.TextData;
-import eu.etaxonomy.cdm.model.name.BacterialName;
-import eu.etaxonomy.cdm.model.name.BotanicalName;
+import eu.etaxonomy.cdm.model.name.INonViralName;
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
-import eu.etaxonomy.cdm.model.name.NonViralName;
import eu.etaxonomy.cdm.model.name.Rank;
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;
-import eu.etaxonomy.cdm.model.name.ZoologicalName;
+import eu.etaxonomy.cdm.model.name.TaxonName;
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
+import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.model.term.TermNode;
+import eu.etaxonomy.cdm.model.term.TermTree;
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
import eu.etaxonomy.cdm.persistence.query.MatchMode;
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
/**
* @author pkelbert
- * @date 2 avr. 2013
+ * @since 2 avr. 2013
*
*/
public class TaxonXTreatmentExtractor extends TaxonXExtractor{
private String treatmentMainName,originalTreatmentName;
- private final HashMap<String,Map<String,String>> namesMap = new HashMap<String, Map<String,String>>();
+ private final HashMap<String,Map<String,String>> namesMap = new HashMap<>();
private final Pattern keypattern = Pattern.compile("^(\\d+.*|-\\d+.*)");
@SuppressWarnings({ "rawtypes", "unused" })
protected void extractTreatment(Node treatmentnode, Reference refMods, URI sourceName) { logger.info("extractTreatment");
- List<TaxonNameBase> namesToSave = new ArrayList<TaxonNameBase>();
+ List<TaxonName> namesToSave = new ArrayList<>();
NodeList children = treatmentnode.getChildNodes();
Taxon acceptedTaxon =null;
boolean hasRefgroup=false;
}
private Taxon handleSingleNode(Reference refMods, URI sourceName,
- List<TaxonNameBase> namesToSave, Node child, Taxon acceptedTaxon) {
+ List<TaxonName> namesToSave, Node child, Taxon acceptedTaxon) {
Taxon defaultTaxon =null;
String nodeName = child.getNodeName();
*/
private void buildFeatureTree() {
logger.info("buildFeatureTree");
- FeatureTree proibiospheretree = importer.getFeatureTreeService().find(proIbioTreeUUID);
+ TermTree proibiospheretree = importer.getFeatureTreeService().find(proIbioTreeUUID);
if (proibiospheretree == null){
- List<FeatureTree> trees = importer.getFeatureTreeService().list(FeatureTree.class, null, null, null, null);
+ List<TermTree> trees = importer.getFeatureTreeService().list(TermTree.class, null, null, null, null);
if (trees.size()==1) {
- FeatureTree ft = trees.get(0);
+ TermTree<Feature> ft = trees.get(0);
if (featuresMap==null) {
- featuresMap=new HashMap<String, Feature>();
+ featuresMap=new HashMap<>();
}
- for (Feature feature: ft.getDistinctFeatures()){
+ for (Feature feature: ft.getDistinctTerms()){
if(feature!=null) {
featuresMap.put(feature.getTitleCache(), feature);
}
}
}
- proibiospheretree = FeatureTree.NewInstance();
+ proibiospheretree = TermTree.NewFeatureInstance();
proibiospheretree.setUuid(proIbioTreeUUID);
}
- // FeatureNode root = proibiospheretree.getRoot();
- FeatureNode root2 = proibiospheretree.getRoot();
+
+ TermNode root2 = proibiospheretree.getRoot();
if (root2 != null){
int nbChildren = root2.getChildCount()-1;
while (nbChildren>-1){
}
for (Feature feature:featuresMap.values()) {
- root2.addChild(FeatureNode.NewInstance(feature));
+ root2.addChild(feature);
}
importer.getFeatureTreeService().saveOrUpdate(proibiospheretree);
* @param refMods: the current reference extracted from the MODS
*/
/* @SuppressWarnings("rawtypes")
- private void extractKey(Node keys, Taxon acceptedTaxon,List<TaxonNameBase> nametosave, Reference refMods) {
+ private void extractKey(Node keys, Taxon acceptedTaxon,List<TaxonName> nametosave, Reference refMods) {
acceptedTaxon = CdmBase.deproxy(acceptedTaxon, Taxon.class);
NodeList children = keys.getChildNodes();
* @return Taxon object built
*/
@SuppressWarnings({ "rawtypes", "unused" })
- private TaxonNameBase getTaxonNameBaseFromXML(Node taxons, List<TaxonNameBase> nametosave, Reference refMods, boolean isSynonym) {
+ private TaxonName getTaxonNameFromXML(Node taxons, List<TaxonName> nametosave, Reference refMods, boolean isSynonym) {
// logger.info("getTaxonFromXML");
// logger.info("acceptedTaxon: "+acceptedTaxon);
- logger.info("getTaxonNameBaseFromXML");
- TaxonNameBase nameToBeFilled = null;
+ logger.info("getTaxonNameFromXML");
+ TaxonName nameToBeFilled = null;
currentMyName=new MyName(isSynonym);
nameToBeFilled=solveNameProblem(currentMyName.getOriginalName(), currentMyName.getName(),parser,currentMyName.getAuthor(), currentMyName.getRank());
}
- nameToBeFilled = getTaxonNameBase(nameToBeFilled,nametosave,statusType);
+ nameToBeFilled = getTaxonName(nameToBeFilled,nametosave,statusType);
*/
- nameToBeFilled = currentMyName.getTaxonNameBase();
+ nameToBeFilled = currentMyName.getTaxonName();
return nameToBeFilled;
}
// /**
// * Create a Taxon for the current NameBase, based on the current reference
- // * @param taxonNameBase
+ // * @param taxonName
// * @param refMods: the current reference extracted from the MODS
// * @return Taxon
// */
// @SuppressWarnings({ "unused", "rawtypes" })
- // private Taxon getTaxon(TaxonNameBase taxonNameBase, Reference refMods) {
- // Taxon t = new Taxon(taxonNameBase,null );
+ // private Taxon getTaxon(TaxonName taxonName, Reference refMods) {
+ // Taxon t = new Taxon(taxonName,null );
// if (!configState.getConfig().doKeepOriginalSecundum() || (t.getSec() == null)) {
// t.setSec(configState.getConfig().getSecundum());
// logger.info("SET SECUNDUM "+configState.getConfig().getSecundum());
* @param refMods: the current reference extracted from the MODS
*/
@SuppressWarnings("rawtypes")
- private void extractDistribution(Node distribution, Taxon acceptedTaxon, Taxon defaultTaxon, List<TaxonNameBase> nametosave, Reference refMods) {
+ private void extractDistribution(Node distribution, Taxon acceptedTaxon, Taxon defaultTaxon, List<TaxonName> nametosave, Reference refMods) {
logger.info("extractDistribution");
// logger.info("acceptedTaxon: "+acceptedTaxon);
NodeList children = distribution.getChildNodes();
- Map<Integer,List<MySpecimenOrObservation>> specimenOrObservations = new HashMap<Integer, List<MySpecimenOrObservation>>();
- Map<Integer,String> descriptionsFulltext = new HashMap<Integer,String>();
+ Map<Integer,List<MySpecimenOrObservation>> specimenOrObservations = new HashMap<>();
+ Map<Integer,String> descriptionsFulltext = new HashMap<>();
for (int i=0;i<children.getLength();i++){
if (children.item(i).getNodeName().equalsIgnoreCase("tax:p")){
* @param paragraph
*/
@SuppressWarnings("rawtypes")
- private void extractInLine(List<TaxonNameBase> nametosave, Reference refMods, Map<Integer, String> descriptionsFulltext,
+ private void extractInLine(List<TaxonName> nametosave, Reference refMods, Map<Integer, String> descriptionsFulltext,
int i, Node paragraph) {
//logger.info("extractInLine");
String inLine=getInlineTextForName(nametosave, refMods, paragraph);
* @param refMods: the current reference extracted from the MODS
*/
@SuppressWarnings("rawtypes")
- private void extractMaterials(Node materials, Taxon acceptedTaxon, Reference refMods,List<TaxonNameBase> nametosave) {
+ private void extractMaterials(Node materials, Taxon acceptedTaxon, Reference refMods,List<TaxonName> nametosave) {
logger.info("EXTRACTMATERIALS");
// logger.info("acceptedTaxon: "+acceptedTaxon);
NodeList children = materials.getChildNodes();
sourceHandler.addAndSaveSource(refMods, derivedUnitBase);
//TODO this may not always be correct, ask user
- TaxonNameBase<?,?> typifiableName = acceptedTaxon != null ? acceptedTaxon.getName() : null;
+ TaxonName typifiableName = acceptedTaxon != null ? acceptedTaxon.getName() : null;
myspecimenOrObservation = extractSpecimenOrObservation(event,derivedUnitBase,SpecimenOrObservationType.DerivedUnit, typifiableName);
derivedUnitBase = myspecimenOrObservation.getDerivedUnitBase();
descr=myspecimenOrObservation.getDescr();
* @param acceptedTaxon: the current accepted Taxon
* @param refMods: the current reference extracted from the MODS
*/
- private String extractMaterialsDirect(Node materials, Taxon acceptedTaxon, Reference refMods, String event, NonViralName<?> currentName) {
+ private String extractMaterialsDirect(Node materials, Taxon acceptedTaxon, Reference refMods, String event, TaxonName currentName) {
logger.info("extractMaterialsDirect");
// logger.info("acceptedTaxon: "+acceptedTaxon);
String descr="";
*/
@SuppressWarnings({ "rawtypes"})
private String extractSpecificFeature(Node description, Taxon acceptedTaxon, Taxon defaultTaxon,
- List<TaxonNameBase> nametosave, Reference refMods, String featureName ) {
+ List<TaxonName> nametosave, Reference refMods, String featureName ) {
logger.info("extractSpecificFeature "+featureName);
// System.out.println("GRUUUUuu");
NodeList children = description.getChildNodes();
* @param refMods: the current reference extracted from the MODS
* @param featureName: the feature name
*/
- @SuppressWarnings({ "unused", "rawtypes" })
+ @SuppressWarnings({ "unused"})
private String extractSpecificFeatureNotStructured(Node description, Taxon acceptedTaxon, Taxon defaultTaxon,
- List<TaxonNameBase> nameToSave, Reference refMods, String featureName ) {
+ List<TaxonName> nameToSave, Reference refMods, String featureName ) {
logger.info("extractSpecificFeatureNotStructured " + featureName);
NodeList children = description.getChildNodes();
NodeList insideNodes ;
* @param nametosave
* @param refMods
* @param insideNodes
- * @param blabla
- * @param j
*/
- @SuppressWarnings({ "rawtypes" })
- private String getInlineTextForName(List<TaxonNameBase> nametosave, Reference refMods, Node insideNode) {
+ private String getInlineTextForName(List<TaxonName> nametosave, Reference refMods, Node insideNode) {
if (true){
NodeList children = insideNode.getChildNodes();
String result = "";
}
return result.replace("\n", "").trim();
}else{
- TaxonNameBase tnb = getTaxonNameBaseFromXML(insideNode, nametosave,refMods,false);
+ TaxonName tnb = getTaxonNameFromXML(insideNode, nametosave,refMods,false);
// Taxon tax = getTaxonFromTxonNameBase(tnb, refMods);
Taxon tax = currentMyName.getTaxon();
if(tnb !=null && tax != null){
* @return a list of description (text)
*/
@SuppressWarnings({ "unused", "rawtypes" })
- private List<String> parseParagraph(List<TaxonNameBase> namesToSave, Taxon acceptedTaxon, Reference refMods, Node paragraph, Feature feature){
+ private List<String> parseParagraph(List<TaxonName> namesToSave, Taxon acceptedTaxon, Reference refMods, Node paragraph, Feature feature){
logger.info("parseParagraph "+feature.toString());
List<String> fullDescription= new ArrayList<String>();
// String localdescr;
* @param feature: the feature to link the data with
*/
@SuppressWarnings("rawtypes")
- private void extractFeature(Node description, Taxon acceptedTaxon, Taxon defaultTaxon, List<TaxonNameBase> namesToSave, Reference refMods, Feature feature){
+ private void extractFeature(Node description, Taxon acceptedTaxon, Taxon defaultTaxon, List<TaxonName> namesToSave, Reference refMods, Feature feature){
logger.info("EXTRACT FEATURE "+feature.toString());
acceptedTaxon = CdmBase.deproxy(acceptedTaxon, Taxon.class);
List<String> fullDescription= parseParagraph( namesToSave, acceptedTaxon, refMods, description,feature);
}
for(MyName name:names){
- TaxonNameBase nameToBeFilled = name.getTaxonNameBase();
+ TaxonName nameToBeFilled = name.getTaxonName();
Synonym synonym = name.getSyno();
addFollowingTextToName(nameToBeFilled, followingText);
addProblemNameToFile(name.getName(),"",nomenclaturalCode,name.getRank());
nameToBeFilled = solveNameProblem(name.getOriginalName(), name.getName(), parser,name.getAuthor(), name.getRank());
}
- nameToBeFilled = getTaxonNameBase(nameToBeFilled,nametosave,statusType);
+ nameToBeFilled = getTaxonName(nameToBeFilled,nametosave,statusType);
*/
if (!name.getIdentifier().isEmpty() && (name.getIdentifier().length()>2)){
setLSID(name.getIdentifier(), synonym);
}
- private boolean addFollowingTextToName(TaxonNameBase nameToBeFilled, String followingText) {
+ private boolean addFollowingTextToName(TaxonName nameToBeFilled, String followingText) {
if (nameToBeFilled != null && StringUtils.isNotBlank(followingText)){
if (! followingText.matches("\\d\\.?")){
* handle cases where the bibref are inside <p> and outside
*/
@SuppressWarnings({ "rawtypes" })
- private Taxon extractReferences(Node refgroup, List<TaxonNameBase> nametosave, Taxon acceptedTaxon, Reference refMods) {
+ private Taxon extractReferences(Node refgroup, List<TaxonName> nametosave, Taxon acceptedTaxon, Reference refMods) {
logger.info("extractReferences");
acceptedTaxon = CdmBase.deproxy(acceptedTaxon, Taxon.class);
NodeList children = refgroup.getChildNodes();
- NonViralName<?> nameToBeFilled = getNonViralNameAccNomenclature();
+ INonViralName nameToBeFilled = getNonViralNameAccNomenclature();
ReferenceBuilder refBuild = new ReferenceBuilder(sourceHandler);
for (int i=0;i<children.getLength();i++){
* @return
*/
- private NonViralName<?> getNonViralNameAccNomenclature() {
- return (NonViralName<?>)nomenclaturalCode.getNewTaxonNameInstance(null);
+ private INonViralName getNonViralNameAccNomenclature() {
+ return nomenclaturalCode.getNewTaxonNameInstance(null);
}
/**
* handle cases where the bibref are inside <p> and outside
*/
@SuppressWarnings("rawtypes")
- private void extractReferenceRawText(NodeList references, NonViralName<?> nameToBeFilled, Reference refMods,
+ private void extractReferenceRawText(NodeList references, INonViralName nameToBeFilled, Reference refMods,
Taxon acceptedTaxon) {
logger.info("extractReferenceRawText");
String refString="";
int nameOrRefOrOther=2;
nameOrRefOrOther=askIfNameContained(fullLineRefName);
if (nameOrRefOrOther==0){
- TaxonNameBase nameTBF = currentMyName.getTaxonNameBase();
+ TaxonName nameTBF = currentMyName.getTaxonName();
Synonym synonym = Synonym.NewInstance(nameTBF, refMods);
Set<Synonym> synonymsSet= acceptedTaxon.getSynonyms();
Reference re = ReferenceFactory.newGeneric();
re.setTitleCache(fullLineRefName, true);
- /* TaxonNameBase nameTBF = parser.parseFullName(currentMyName.getName(), nomenclaturalCode, currentMyName.getRank());
+ /* TaxonName nameTBF = parser.parseFullName(currentMyName.getName(), nomenclaturalCode, currentMyName.getRank());
if (nameTBF.hasProblem() &&
!((nameTBF.getParsingProblems().size()==1) && nameTBF.getParsingProblems().contains(ParserProblem.CheckRank)) ) {
addProblemNameToFile(currentMyName.getName(),"",nomenclaturalCode,currentMyName.getRank());
nameTBF=solveNameProblem(currentMyName.getName(), currentMyName.getName(),parser,currentMyName.getAuthor(), currentMyName.getRank());
}
- nameTBF = getTaxonNameBase(nameTBF,nametosave,statusType);
+ nameTBF = getTaxonName(nameTBF,nametosave,statusType);
*/
- TaxonNameBase nameTBF = currentMyName.getTaxonNameBase();
+ TaxonName nameTBF = currentMyName.getTaxonName();
Synonym synonym = Synonym.NewInstance(nameTBF, re);
Set<Synonym> synonymsSet= acceptedTaxon.getSynonyms();
acceptedTaxon.getName().setNomenclaturalReference(refS);
}else{
- TaxonNameBase nameTBF = currentMyName.getTaxonNameBase();
+ TaxonName nameTBF = currentMyName.getTaxonName();
Synonym synonym = null;
if (! currentMyName.getStatus().isEmpty()){
String nomNovStatus = this.newNameStatus(currentMyName.getStatus());
// if ((id.indexOf("lsid")<0) || !lsidok){
//ADD ORIGINAL SOURCE ID EVEN IF LSID
Reference re = null;
- Pager<Reference> references = importer.getReferenceService().findByTitle(Reference.class, source, MatchMode.EXACT, null, 1, null, null, null);
+ Pager<Reference> references = importer.getReferenceService().findByTitleWithRestrictions(Reference.class, source, MatchMode.EXACT, null, 1, null, null, null);
if( references !=null && references.getCount()>0){
re=references.getRecords().get(0);
}
* @param original : the name from the OCR document
* @param name : the tagged version
* @param parser
- * @return the corrected TaxonNameBase
+ * @return the corrected TaxonName
*/
/* @SuppressWarnings({ "unchecked", "rawtypes" })
- private TaxonNameBase<?,?> solveNameProblem(String original, String name, INonViralNameParser parser, String author, Rank rank) {
+ private TaxonName solveNameProblem(String original, String name, INonViralNameParser parser, String author, Rank rank) {
Map<String,String> ato = namesMap.get(original);
if (ato == null) {
ato = namesMap.get(original+" "+author);
if (ato != null && rank.equals(Rank.UNKNOWN_RANK())){
rank = getRank(ato);
}
- // TaxonNameBase<?,?> nameTBF = parser.parseFullName(name, nomenclaturalCode, rank);
- TaxonNameBase<?,?> nameTBF = parser.parseSimpleName(name, nomenclaturalCode, rank);
+ // TaxonName nameTBF = parser.parseFullName(name, nomenclaturalCode, rank);
+ TaxonName nameTBF = parser.parseSimpleName(name, nomenclaturalCode, rank);
// logger.info("RANK: "+rank);
int retry=0;
List<ParserProblem> problems = nameTBF.getParsingProblems();
fullname = getFullReference(name,nameTBF.getParsingProblems());
}
if (nomenclaturalCode.equals(NomenclaturalCode.ICNAFP)){
- nameTBF = BotanicalName.NewInstance(null);
+ nameTBF = TaxonNameFactory.NewBotanicalInstance(null);
}
if (nomenclaturalCode.equals(NomenclaturalCode.ICZN)){
- nameTBF = ZoologicalName.NewInstance(null);
+ nameTBF = TaxonNameFactory.NewZoologicalInstance(null);
}
- if (nomenclaturalCode.equals(NomenclaturalCode.ICNB)){
- nameTBF= BacterialName.NewInstance(null);
+ if (nomenclaturalCode.equals(NomenclaturalCode.ICNP)){
+ nameTBF= TaxonNameFactory.NewBacterialInstance(null);
}
parser.parseReferencedName(nameTBF, fullname, rank, false);
retry++;
if (nomenclaturalCode.equals(NomenclaturalCode.ICZN)) {
((ZoologicalName) nameTBF).setAuthorshipCache(currentMyName.getAuthor());
}
- if (nomenclaturalCode.equals(NomenclaturalCode.ICNB)) {
+ if (nomenclaturalCode.equals(NomenclaturalCode.ICNP)) {
((BacterialName) nameTBF).setAuthorshipCache(currentMyName.getAuthor());
}
}
* @return
*/
@SuppressWarnings({ "rawtypes" })
- private Taxon extractNomenclature(Node nomenclatureNode, List<TaxonNameBase> nametosave, Reference refMods) throws ClassCastException{
+ private Taxon extractNomenclature(Node nomenclatureNode, List<TaxonName> nametosave, Reference refMods) throws ClassCastException{
refMods=CdmBase.deproxy(refMods, Reference.class);
logger.info("extractNomenclature");
usedFollowingTextPrefix = null; //reset
}else if (childName.equalsIgnoreCase("tax:collection_event")) {
// System.out.println("COLLECTION EVENT INSIDE NOMENCLATURE");
- extractMaterialsDirect(childNode, acceptedTaxon, refMods, "collection", currentMyName.getTaxonNameBase());
+ extractMaterialsDirect(childNode, acceptedTaxon, refMods, "collection", currentMyName.getTaxonName());
}else if(childName.equalsIgnoreCase("tax:name")){
- NonViralName<?> nameToBeFilled;
+ INonViralName nameToBeFilled;
//System.out.println("HANDLE FIRST NAME OF THE LIST");
if(!containsSynonyms){
wasSynonym = false;
if (currentMyName.getRank().equals(Rank.UNKNOWN_RANK()) || currentMyName.getRank().isLower(state2.getConfig().getMaxRank()) || currentMyName.getRank().equals(state2.getConfig().getMaxRank())){
maxRankRespected=true;
- nameToBeFilled=currentMyName.getTaxonNameBase();
+ nameToBeFilled=currentMyName.getTaxonName();
// acceptedTaxon = importer.getTaxonService().findBestMatchingTaxon(treatmentMainName);
acceptedTaxon=currentMyName.getTaxon();
}
if (acceptedTaxon ==null || (acceptedTaxon != null && !statusMatch)){
- nameToBeFilled=currentMyName.getTaxonNameBase();
+ nameToBeFilled=currentMyName.getTaxonName();
if (nameToBeFilled != null){
if (!originalTreatmentName.isEmpty()) {
TaxonNameDescription td = TaxonNameDescription.NewInstance();
if(newNameStatus != null){
nameToBeFilled.setAppendedPhrase(newNameStatus);
}
- sourceHandler.addSource(refMods, nameToBeFilled);
+ sourceHandler.addSource(refMods, TaxonName.castAndDeproxy(nameToBeFilled));
if (nameToBeFilled.getNomenclaturalReference() == null) {
acceptedTaxon= Taxon.NewInstance(nameToBeFilled,refMods);
//System.out.println("NEW ACCEPTED HERE "+nameToBeFilled);
}
else {
- acceptedTaxon= Taxon.NewInstance(nameToBeFilled,(Reference) nameToBeFilled.getNomenclaturalReference() );//TODO TOFIX reference
+ acceptedTaxon= Taxon.NewInstance(nameToBeFilled,nameToBeFilled.getNomenclaturalReference() );//TODO TOFIX reference
//System.out.println("NEW ACCEPTED HERE2 "+nameToBeFilled);
}
}else if (childName.equalsIgnoreCase("tax:bibref")){
logger.warn(childName + " still preliminary");
- NonViralName<?> currentName = currentMyName == null ? null : currentMyName.getTaxonNameBase();
+ TaxonName currentName = currentMyName == null ? null : currentMyName.getTaxonName();
boolean handled = addFollowingTextToName (currentName, childNode.getTextContent() );
if (! handled){
setParticularDescription(freetext.trim(), acceptedTaxon,acceptedTaxon, refMods, getNotMarkedUpFeatureObject());
}
if(!stringIsEmpty(freetext.trim())) {;
if (! freetext.matches("\\d\\.?")){
- NonViralName<?> currentName = currentMyName == null ? null : currentMyName.getTaxonNameBase();
+ TaxonName currentName = currentMyName == null ? null : currentMyName.getTaxonName();
boolean handled = false;
if (currentName != null && !wasSynonym){
handled = addFollowingTextToName (currentName, childNode.getTextContent() );
s = askSetParent(s);
r = askRank(s,rankListStr);
- NonViralName<?> nameToBeFilled = null;
+ TaxonName nameToBeFilled = null;
if (nomenclaturalCode.equals(NomenclaturalCode.ICNAFP)){
- nameToBeFilled = BotanicalName.NewInstance(null);
+ nameToBeFilled = TaxonNameFactory.NewBotanicalInstance(null);
}
if (nomenclaturalCode.equals(NomenclaturalCode.ICZN)){
- nameToBeFilled = ZoologicalName.NewInstance(null);
+ nameToBeFilled = TaxonNameFactory.NewZoologicalInstance(null);
}
- if (nomenclaturalCode.equals(NomenclaturalCode.ICNB)){
- nameToBeFilled = BacterialName.NewInstance(null);
+ if (nomenclaturalCode.equals(NomenclaturalCode.ICNP)){
+ nameToBeFilled = TaxonNameFactory.NewBacterialInstance(null);
}
nameToBeFilled.setTitleCache(s, true);
nameToBeFilled.setRank(getRank(r), true);
String fullName = "";
String newName="";
String identifier="";
- HashMap<String, String> atomisedMap = new HashMap<String, String>();
+ HashMap<String, String> atomisedMap = new HashMap<>();
List<String> atomisedName= new ArrayList<String>();
String rankStr = "";
boolean parseNameManually=false;
INonViralNameParser<?> parser = NonViralNameParserImpl.NewInstance();
- TaxonNameBase<?,?> nameToBeFilledTest ;
+ TaxonName nameToBeFilledTest ;
//if selected the atomised version
if(newName==atomisedNameStr){
nameToBeFilledTest = parseWithExtension(parser, atomisedNameStr, rank, followingText, atomisedMap);
if (nameToBeFilledTest.hasProblem()){
addProblemNameToFile("ato",atomisedNameStr,nomenclaturalCode,rank, nameToBeFilledTest.getParsingProblems().toString());
- nameToBeFilledTest = parser.parseFullName(fullName, nomenclaturalCode,rank);
+ nameToBeFilledTest = (TaxonName)parser.parseFullName(fullName, nomenclaturalCode, rank);
if (nameToBeFilledTest.hasProblem()){
addProblemNameToFile("full",fullName,nomenclaturalCode,rank, nameToBeFilledTest.getParsingProblems().toString());
parseNameManually=true;
}else{
nameToBeFilledTest = parseWithExtension(parser, atomisedNameStr, rank, followingText, atomisedMap);
if (nameToBeFilledTest.hasProblem()){
- addProblemNameToFile("fullversion",fullName,nomenclaturalCode,rank, nameToBeFilledTest.getParsingProblems().toString());
- nameToBeFilledTest = parser.parseFullName(fullName, nomenclaturalCode,rank);
+ addProblemNameToFile("fullversion",fullName, nomenclaturalCode,rank, nameToBeFilledTest.getParsingProblems().toString());
+ nameToBeFilledTest = (TaxonName)parser.parseFullName(fullName, nomenclaturalCode,rank);
parseNameManually=true;
if(!originalName.equalsIgnoreCase(atomisedNameStr)) {
addNameDifferenceToFile(originalName,atomisedNameStr);
String fullName = "";
String newName = "";
String identifier = "";
- HashMap<String, String> atomisedMap = new HashMap<String, String>();
- List<String> atomisedNameList= new ArrayList<String>();
+ HashMap<String, String> atomisedMap = new HashMap<>();
+ List<String> atomisedNameList= new ArrayList<>();
String status= extractStatus(children);
boolean parseNameManually=false;
INonViralNameParser parser = NonViralNameParserImpl.NewInstance();
- TaxonNameBase nameToBeFilledTest = null;
+ TaxonName nameToBeFilledTest = null;
//if selected the atomised version
if(newName==atomisedNameStr){
nameToBeFilledTest = parseWithExtension(parser, atomisedNameStr, rank, followingText, atomisedMap);
if (nameToBeFilledTest.hasProblem()){
addProblemNameToFile("ato",atomisedNameStr,nomenclaturalCode,rank, nameToBeFilledTest.getParsingProblems().toString());
- nameToBeFilledTest = parser.parseFullName(fullName, nomenclaturalCode,rank);
+ nameToBeFilledTest = (TaxonName)parser.parseFullName(fullName, nomenclaturalCode,rank);
if (nameToBeFilledTest.hasProblem()){
addProblemNameToFile("full",fullName,nomenclaturalCode,rank, nameToBeFilledTest.getParsingProblems().toString());
parseNameManually=true;
nameToBeFilledTest = parseWithExtension(parser, fullName , rank, followingText, atomisedMap);
if (nameToBeFilledTest.hasProblem()){
addProblemNameToFile("fullversion",fullName,nomenclaturalCode,rank, nameToBeFilledTest.getParsingProblems().toString());
- nameToBeFilledTest = parser.parseFullName(fullName, nomenclaturalCode,rank);
+ nameToBeFilledTest = (TaxonName)parser.parseFullName(fullName, nomenclaturalCode,rank);
parseNameManually=true;
if(!originalName.equalsIgnoreCase(atomisedNameStr)) {
addNameDifferenceToFile(originalName,atomisedNameStr);
}
- private TaxonNameBase<?,?> parseWithExtension(INonViralNameParser parser, String atomisedNameStr, Rank rank, String followingText, HashMap<String, String> atomisedMap) {
+ private TaxonName parseWithExtension(INonViralNameParser parser, String atomisedNameStr, Rank rank, String followingText, HashMap<String, String> atomisedMap) {
Object[] nameExtensionResult = getPossibleExtension(followingText, atomisedMap, nomenclaturalCode);
- TaxonNameBase<?,?> name = parser.parseFullName(atomisedNameStr, nomenclaturalCode, rank);
+ TaxonName name = (TaxonName)parser.parseFullName(atomisedNameStr, nomenclaturalCode, rank);
if (nameExtensionResult != null && nameExtensionResult[0] != null){
String ext = (String)nameExtensionResult[0];
- TaxonNameBase<?,?> extName =parser.parseFullName(atomisedNameStr + " " + ext, nomenclaturalCode, rank);
+ TaxonName extName = (TaxonName)parser.parseFullName(atomisedNameStr + " " + ext, nomenclaturalCode, rank);
if (! extName.hasProblem()){
name = extName;
this.usedFollowingTextPrefix = ext;
}
if ((Boolean)(nameExtensionResult[2])){
//TODO BasionymYear etc.
- Integer origYear = ((ZoologicalName)name).getPublicationYear();
+ Integer origYear = name.getPublicationYear();
if (origYear != null){
atomisedMap.put(PUBLICATION_YEAR, origYear.toString());
}
private void createUnparsedSynonymNew(Rank rank, String newName, HashMap<String, String> atomisedMap, MyName myname, Reference refMods) {
logger.info("createSynonym");
- NonViralName<?> nameToBeFilled = this.getNonViralNameAccNomenclature();
+ INonViralName nameToBeFilled = this.getNonViralNameAccNomenclature();
//System.out.println("createsynonym");
if(rank.equals(Rank.UNKNOWN_RANK())){
//TODO
classification = classification2;
}
- /**
- * @param tnb
- * cast the current taxonnamebase into a botanical name or zoological or bacterial name
- * if errors, cast into a classis nonviralname
- * @param taxonnamebase2
- */
- @SuppressWarnings("rawtypes")
- public NonViralName<?> castTaxonNameBase(TaxonNameBase tnb, NonViralName<?> nvn) {
- //logger.info("castTaxonNameBase");
- NonViralName<?> taxonnamebase2 = nvn;
- if (nomenclaturalCode.equals(NomenclaturalCode.ICNAFP)) {
- try{
- taxonnamebase2=(BotanicalName) tnb;
- }catch(Exception e){
- taxonnamebase2= (NonViralName<?>) tnb;
- }
- }
- if (nomenclaturalCode.equals(NomenclaturalCode.ICZN)) {
- try{
- taxonnamebase2=(ZoologicalName) tnb;
- }catch(Exception e){
- taxonnamebase2= (NonViralName<?>) tnb;
- }
- }
- if (nomenclaturalCode.equals(NomenclaturalCode.ICNB)) {
- try{
- taxonnamebase2=(BacterialName) tnb;
- }catch(Exception e){
- taxonnamebase2= (NonViralName<?>) tnb;
- }
- }
- return taxonnamebase2;
- }
-
- /**
- * @param tnb
- * cast the current taxonnamebase into a botanical name or zoological or bacterial name
- * if errors, cast into a classis nonviralname
- * @param taxonnamebase2
- */
- @SuppressWarnings("rawtypes")
- public NonViralName<?> castTaxonNameBase(TaxonNameBase tnb) {
- //logger.info("castTaxonNameBase2");
- NonViralName<?> taxonnamebase2 = null;
- tnb=CdmBase.deproxy(tnb, TaxonNameBase.class);
- if (nomenclaturalCode.equals(NomenclaturalCode.ICNAFP)) {
- try{
- taxonnamebase2=(BotanicalName) tnb;
- }catch(Exception e){
- taxonnamebase2= (NonViralName<?>) tnb;
- }
- }
- if (nomenclaturalCode.equals(NomenclaturalCode.ICZN)) {
- try{
- taxonnamebase2=(ZoologicalName) tnb;
- }catch(Exception e){
- taxonnamebase2= (NonViralName<?>) tnb;
- }
- }
- if (nomenclaturalCode.equals(NomenclaturalCode.ICNB)) {
- try{
- taxonnamebase2=(BacterialName) tnb;
- }catch(Exception e){
- taxonnamebase2= (NonViralName<?>) tnb;
- }
- }
- return taxonnamebase2;
- }
public class MyName {
/**
String status="";
String author=null;
- NonViralName<?> taxonNameBase;
+ TaxonName taxonName;
Reference refMods ;
Taxon family,subfamily,tribe,subtribe,genus,subgenus,species,subspecies, variety,form;
- NonViralName<?> familyName, subfamilyName, tribeName,subtribeName,genusName,subgenusName,speciesName,subspeciesName;
+ INonViralName familyName, subfamilyName, tribeName,subtribeName,genusName,subgenusName,speciesName,subspeciesName;
String familyStr, subfamilyStr, tribeStr,subtribeStr,genusStr,subgenusStr,speciesStr,subspeciesStr,formStr,varietyStr;
Integer publicationYear;
logger.warn("Problem with status");
}
}
- List<TaxonBase> tmpList = new ArrayList<TaxonBase>();
+ List<TaxonBase> tmpList = new ArrayList<>();
- Pager<TaxonBase> taxontest = importer.getTaxonService().findByTitle(TaxonBase.class, newName2, MatchMode.BEGINNING, null, null, null, null, null);
+ Pager<TaxonBase> taxontest = importer.getTaxonService().findByTitleWithRestrictions(TaxonBase.class, newName2, MatchMode.BEGINNING, null, null, null, null, null);
tmpList.addAll(taxontest.getRecords());
//logger.info("tmpList returned: "+tmpList.size());
- NonViralName<?> identicName = null;
+ INonViralName identicName = null;
boolean foundIdentic=false;
TaxonBase<?> tmpTaxonBase=null;
// Taxon tmpPartial=null;
for (TaxonBase<?> tmpb:tmpList){
if(tmpb !=null){
- TaxonNameBase<?,?> tnb = tmpb.getName();
+ TaxonName tnb = tmpb.getName();
Rank crank=null;
if (tnb != null){
if (tnb.getTitleCache().split("sec.")[0].trim().equalsIgnoreCase(newName2) ){
crank =tnb.getRank();
if (crank !=null && rank !=null){
if (crank.equals(rank)){
- identicName = CdmBase.deproxy(tnb, NonViralName.class);
+ identicName = tnb;
if (isSynonym && tmpb.isInstanceOf(Synonym.class) || !isSynonym && tmpb.isInstanceOf(Taxon.class)){
foundIdentic=true;
tmpTaxonBase=tmpb;
}
if ((tmpTaxonBase == null || !foundIdentic) || (tmpTaxonBase != null && !statusMatch) || (tmpTaxonBase != null && !appendedMatch && !statusMatch)){
- NonViralName<?> tnb;
+ INonViralName tnb;
if (identicName == null){
tnb = getNonViralNameAccNomenclature();
tnb.setRank(rank);
tmpTaxonBase = CdmBase.deproxy(tmpTaxonBase, TaxonBase.class);
}
}
- TaxonNameBase<?,?> tnb = CdmBase.deproxy(tmpTaxonBase.getName(), TaxonNameBase.class);
+ TaxonName tnb = CdmBase.deproxy(tmpTaxonBase.getName(), TaxonName.class);
if(!isSynonym) {
this.taxon=(Taxon)tmpTaxonBase;
this.syno=(Synonym)tmpTaxonBase;
}
- taxonNameBase = castTaxonNameBase(tnb, taxonNameBase);
+ taxonName = tnb;
}
status = getStatus();
String newNameStatus = newNameStatus(status);
if (newNameStatus != null){
- taxonNameBase.setAppendedPhrase(newNameStatus);
+ taxonName.setAppendedPhrase(newNameStatus);
}else{
try {
statusType = nomStatusString2NomStatus(getStatus());
- taxonNameBase.addStatus(NomenclaturalStatus.NewInstance(statusType));
+ taxonName.addStatus(NomenclaturalStatus.NewInstance(statusType));
} catch (UnknownCdmTypeException e) {
addProblematicStatusToFile(getStatus());
logger.warn("Problem with status");
}
}
}
- importer.getNameService().save(taxonNameBase);
+ importer.getNameService().save(taxonName);
TaxonBase<?> tmpTaxonBase;
if (!isSynonym) {
- tmpTaxonBase =Taxon.NewInstance(taxonNameBase, refMods); //sec set null
+ tmpTaxonBase =Taxon.NewInstance(taxonName, refMods); //sec set null
}
else {
- tmpTaxonBase =Synonym.NewInstance(taxonNameBase, refMods); //sec set null
+ tmpTaxonBase =Synonym.NewInstance(taxonName, refMods); //sec set null
}
boolean exist = false;
if (!isSynonym){
exist =true;
} else {
logger.info("Found the same name but from another type (taxon/synonym)");
- TaxonNameBase<?,?> existingTnb = getTaxon().getName();
+ TaxonName existingTnb = getTaxon().getName();
tmpTaxonBase = Synonym.NewInstance(existingTnb, refMods);
importer.getTaxonService().saveOrUpdate(tmpTaxonBase);
exist =true;
boolean insertAsExisting =false;
List<Taxon> existingTaxons=new ArrayList<Taxon>();
try {
- existingTaxons = getMatchingTaxa(taxonNameBase);
+ existingTaxons = getMatchingTaxa(taxonName);
} catch (Exception e1) {
e1.printStackTrace();
}
String t1="";
String t2="";
for (Taxon bestMatchingTaxon : existingTaxons){
- //System.out.println("tnbase "+taxonnamebase.getTitleCache());
+ //System.out.println("tnbase "+taxonname.getTitleCache());
//System.out.println("bestex "+bestMatchingTaxon.getTitleCache());
- if(taxonNameBase.getAuthorshipCache()!=null) {
- author1=taxonNameBase.getAuthorshipCache();
+ if(taxonName.getAuthorshipCache()!=null) {
+ author1=taxonName.getAuthorshipCache();
}
try {
- if(castTaxonNameBase(bestMatchingTaxon.getName()).getAuthorshipCache()!=null) {
- author2=castTaxonNameBase(bestMatchingTaxon.getName()).getAuthorshipCache();
+ if(bestMatchingTaxon.getName().getAuthorshipCache()!=null) {
+ author2=bestMatchingTaxon.getName().getAuthorshipCache();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
- t1=taxonNameBase.getTitleCache();
+ t1=taxonName.getTitleCache();
if (author1!=null && !StringUtils.isEmpty(author1)) {
t1=t1.split(Pattern.quote(author1))[0];
}
//System.out.println("taxonscore "+similarityScore);
similarityAuthor=similarity(author1.trim(), author2.trim());
//System.out.println("authorscore "+similarityAuthor);
- insertAsExisting = compareAndCheckTaxon(taxonNameBase, refMods, similarityScore, bestMatchingTaxon, similarityAuthor);
+ insertAsExisting = compareAndCheckTaxon(taxonName, refMods, similarityScore, bestMatchingTaxon, similarityAuthor);
if(insertAsExisting) {
tmpTaxonBase=bestMatchingTaxon;
break;
}
// tmptaxonbase.setSec(refMods);
- if (taxonNameBase.getRank().equals(state2.getConfig().getMaxRank())) {
+ if (taxonName.getRank().equals(state2.getConfig().getMaxRank())) {
//System.out.println("****************************"+tmptaxonbase);
if (!isSynonym) {
classification.addChildTaxon((Taxon)tmpTaxonBase, refMods, null);
}
} else{
- hierarchy = new HashMap<Rank, Taxon>();
- //System.out.println("LOOK FOR PARENT "+taxonnamebase.toString()+", "+tmptaxonbase.toString());
+ hierarchy = new HashMap<>();
+ //System.out.println("LOOK FOR PARENT "+taxonname.toString()+", "+tmptaxonbase.toString());
if (!isSynonym){
- lookForParentNode(taxonNameBase,(Taxon)tmpTaxonBase, refMods,this);
+ lookForParentNode(taxonName,(Taxon)tmpTaxonBase, refMods,this);
//System.out.println("HIERARCHY "+hierarchy);
Taxon parent = buildHierarchy();
if(!taxonExistsInClassification(parent,(Taxon)tmpTaxonBase)){
try{
Synonym castTest=CdmBase.deproxy(tmpTaxonBase, Synonym.class);
}catch(Exception e){
- TaxonNameBase<?,?> existingTnb = tmpTaxonBase.getName();
+ TaxonName existingTnb = tmpTaxonBase.getName();
Synonym castTest = Synonym.NewInstance(existingTnb, refMods);
importer.getTaxonService().saveOrUpdate(castTest);
tmpTaxonBase=CdmBase.deproxy(castTest, Synonym.class);
if (newTaxon.isInstanceOf(Synonym.class)){
return false;
}
- NonViralName<?> nodeName = CdmBase.deproxy(nodeTaxon.getName(), NonViralName.class);
- NonViralName<?> newName = CdmBase.deproxy(newTaxon.getName(), NonViralName.class);
+ INonViralName nodeName = nodeTaxon.getName();
+ INonViralName newName = newTaxon.getName();
if (nodeTaxon.getName() == null || newName == null){
return false;
}
/**
* @param nameToBeFilledTest
*/
- @SuppressWarnings("rawtypes")
- public void setParsedName(TaxonNameBase nameToBeFilledTest) {
- this.taxonNameBase = (NonViralName<?>) nameToBeFilledTest;
+ public void setParsedName(TaxonName nameToBeFilledTest) {
+ this.taxonName = TaxonName.castAndDeproxy(nameToBeFilledTest);
}
//variety dwcranks:varietyEpithet
/**
* @return
*/
- public NonViralName<?> getTaxonNameBase() {
- return taxonNameBase;
+ public TaxonName getTaxonName() {
+ return taxonName;
}
/**
List<TaxonBase> tmpListFiltered = new ArrayList<TaxonBase>();
- Pager<TaxonBase> taxontest = importer.getTaxonService().findByTitle(TaxonBase.class, fullname, MatchMode.BEGINNING, null, null, null, null, null);
+ Pager<TaxonBase> taxontest = importer.getTaxonService().findByTitleWithRestrictions(TaxonBase.class, fullname, MatchMode.BEGINNING, null, null, null, null, null);
tmpListFiltered.addAll(taxontest.getRecords());
- taxontest = importer.getTaxonService().findByTitle(TaxonBase.class, partialname, MatchMode.BEGINNING, null, null, null, null, null);
+ taxontest = importer.getTaxonService().findByTitleWithRestrictions(TaxonBase.class, partialname, MatchMode.BEGINNING, null, null, null, null, null);
tmpListFiltered.addAll(taxontest.getRecords());
//logger.info("tmpListFiltered returned: "+tmpListFiltered.size());
Taxon tmp=null;
for (TaxonBase tmpb:tmpListFiltered){
if(tmpb !=null){
- TaxonNameBase tnb = tmpb.getName();
+ TaxonName tnb = tmpb.getName();
Rank crank=null;
if (tnb != null){
if(globalrank.equals(rank) || (globalrank.isLower(Rank.SPECIES()) && rank.equals(Rank.SPECIES()))){
}
if ((tmp == null || !foundIdentic) || (tmp != null && !statusMatch) || (tmp != null && !appendedMatch && !statusMatch)){
- NonViralName<?> tnb = getNonViralNameAccNomenclature();
+ INonViralName tnb = getNonViralNameAccNomenclature();
tnb.setRank(rank);
if(statusType != null) {
* @param tnb
* @return
*/
- private Taxon buildSubfamily(NonViralName<?> tnb) {
+ private Taxon buildSubfamily(INonViralName tnb) {
Taxon tmp;
// tnb.generateTitle();
tmp = findMatchingTaxon(tnb,refMods);
* @param tnb
* @return
*/
- private Taxon buildFamily(NonViralName<?> tnb) {
+ private Taxon buildFamily(INonViralName tnb) {
Taxon tmp;
// tnb.generateTitle();
tmp = findMatchingTaxon(tnb,refMods);
* @param tnb
* @return
*/
- private Taxon buildForm(String fullname, String partialname, NonViralName<?> tnb) {
+ private Taxon buildForm(String fullname, String partialname, INonViralName tnb) {
if (genusName !=null) {
tnb.setGenusOrUninomial(genusName.getGenusOrUninomial());
}
* @param tnb
* @return
*/
- private Taxon buildVariety(String fullname, String partialname, NonViralName<?> tnb) {
+ private Taxon buildVariety(String fullname, String partialname, INonViralName tnb) {
Taxon tmp;
if (genusName !=null) {
tnb.setGenusOrUninomial(genusName.getGenusOrUninomial());
* @param tnb
* @return
*/
- private Taxon buildSubspecies(String partialname, NonViralName<?> tnb) {
+ private Taxon buildSubspecies(String partialname, INonViralName tnb) {
if (genusName !=null) {
tnb.setGenusOrUninomial(genusName.getGenusOrUninomial());
}
* @param tnb
* @return
*/
- private Taxon buildSpecies(String partialname, NonViralName<?> tnb) {
+ private Taxon buildSpecies(String partialname, INonViralName tnb) {
if (genusName !=null) {
tnb.setGenusOrUninomial(genusName.getGenusOrUninomial());
}
* @param tnb
* @return
*/
- private Taxon buildSubgenus(String partialname, NonViralName<?> tnb) {
+ private Taxon buildSubgenus(String partialname, INonViralName tnb) {
tnb.setInfraGenericEpithet(partialname);
if (genusName !=null) {
tnb.setGenusOrUninomial(genusName.getGenusOrUninomial());
* @param tnb
* @return
*/
- private Taxon buildGenus(String partialname, NonViralName<?> tnb) {
+ private Taxon buildGenus(String partialname, INonViralName tnb) {
Taxon tmp;
tnb.setGenusOrUninomial(partialname);
* @param tnb
* @return
*/
- private Taxon buildSubtribe(NonViralName<?> tnb) {
+ private Taxon buildSubtribe(INonViralName tnb) {
Taxon tmp = findMatchingTaxon(tnb,refMods);
if(tmp==null){
tmp = Taxon.NewInstance(tnb, sourceUrlRef);
* @param tnb
* @return
*/
- private Taxon buildTribe(NonViralName<?> tnb) {
+ private Taxon buildTribe(INonViralName tnb) {
Taxon tmp = findMatchingTaxon(tnb,refMods);
if(tmp==null){
tmp = Taxon.NewInstance(tnb, sourceUrlRef);
@SuppressWarnings("rawtypes")
public void setFamily(Taxon family) {
this.family = family;
- TaxonNameBase taxonNameBase = CdmBase.deproxy(family.getName(), TaxonNameBase.class);
- familyName = castTaxonNameBase(taxonNameBase,familyName);
+ familyName = CdmBase.deproxy(family.getName());
}
/**
* @return the subfamily
@SuppressWarnings("rawtypes")
public void setSubfamily(Taxon subfamily) {
this.subfamily = subfamily;
- TaxonNameBase taxonNameBase = CdmBase.deproxy(subfamily.getName(), TaxonNameBase.class);
- subfamilyName = castTaxonNameBase(taxonNameBase,subfamilyName);
+ subfamilyName = CdmBase.deproxy(subfamily.getName());
}
/**
* @return the tribe
@SuppressWarnings("rawtypes")
public void setTribe(Taxon tribe) {
this.tribe = tribe;
- TaxonNameBase taxonNameBase = CdmBase.deproxy(tribe.getName(), TaxonNameBase.class);
- tribeName = castTaxonNameBase(taxonNameBase,tribeName);
+ tribeName = CdmBase.deproxy(tribe.getName());
}
/**
* @return the subtribe
@SuppressWarnings("rawtypes")
public void setSubtribe(Taxon subtribe) {
this.subtribe = subtribe;
- TaxonNameBase taxonNameBase = CdmBase.deproxy(subtribe.getName(), TaxonNameBase.class);
- subtribeName =castTaxonNameBase(taxonNameBase,subtribeName);
+ subtribeName =CdmBase.deproxy(subtribe.getName());
}
/**
* @return the genus
public void setGenus(Taxon genus) {
if (genus != null){
this.genus = genus;
- TaxonNameBase taxonNameBase = CdmBase.deproxy(genus.getName(), TaxonNameBase.class);
- genusName = castTaxonNameBase(taxonNameBase,genusName);
+ genusName = CdmBase.deproxy(genus.getName());
}
}
/**
@SuppressWarnings("rawtypes")
public void setSubgenus(Taxon subgenus) {
this.subgenus = subgenus;
- TaxonNameBase taxonNameBase = CdmBase.deproxy(subgenus.getName(), TaxonNameBase.class);
- subgenusName = castTaxonNameBase(taxonNameBase,subgenusName);
+ subgenusName = CdmBase.deproxy(subgenus.getName());
}
/**
* @return the species
public void setSpecies(Taxon species) {
if (species != null){
this.species = species;
- @SuppressWarnings("rawtypes")
- TaxonNameBase taxonNameBase = CdmBase.deproxy(species.getName(), TaxonNameBase.class);
- speciesName = castTaxonNameBase(taxonNameBase,speciesName);
+ speciesName = CdmBase.deproxy(species.getName());
}
}
/**
@SuppressWarnings("rawtypes")
public void setSubspecies(Taxon subspecies) {
this.subspecies = subspecies;
- TaxonNameBase taxonNameBase = CdmBase.deproxy(subspecies.getName(), TaxonNameBase.class);
- subspeciesName = castTaxonNameBase(taxonNameBase,subspeciesName);
+ subspeciesName = CdmBase.deproxy(subspecies.getName());
}
* @param tnb
* @return
*/
- private Taxon findMatchingTaxon(NonViralName<?> tnb, Reference refMods) {
+ private Taxon findMatchingTaxon(INonViralName tnb, Reference refMods) {
logger.info("findMatchingTaxon");
Taxon tmp=null;
boolean insertAsExisting =false;
List<Taxon> existingTaxa = new ArrayList<Taxon>();
try {
- existingTaxa = getMatchingTaxa(tnb);
+ existingTaxa = getMatchingTaxa(TaxonName.castAndDeproxy(tnb));
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
e.printStackTrace();
}
try {
- if(castTaxonNameBase(bestMatchingTaxon.getName()).getAuthorshipCache()!=null) {
- author2=castTaxonNameBase(bestMatchingTaxon.getName()).getAuthorshipCache();
+ if(bestMatchingTaxon.getName().getAuthorshipCache()!=null) {
+ author2=bestMatchingTaxon.getName().getAuthorshipCache();
}
} catch (Exception e) {
// TODO Auto-generated catch block
* @param similarityAuthor
* @return
*/
- private boolean compareAndCheckTaxon(NonViralName<?> tnb, Reference refMods, double similarityScore,
+ private boolean compareAndCheckTaxon(INonViralName tnb, Reference refMods, double similarityScore,
Taxon bestMatchingTaxon, double similarityAuthor) {
//logger.info("compareAndCheckTaxon");
boolean insertAsExisting;
}
// }
- logDecision(tnb,bestMatchingTaxon,insertAsExisting, refMods);
+ logDecision(tnb, bestMatchingTaxon, insertAsExisting, refMods);
return insertAsExisting;
}
* @return
*/
@SuppressWarnings("rawtypes")
- private List<Taxon> getMatchingTaxa(TaxonNameBase tnb) {
+ private List<Taxon> getMatchingTaxa(TaxonName tnb) {
//logger.info("getMatchingTaxon");
if (tnb.getTitleCache() == null){
tnb.setTitleCache(tnb.toString(), tnb.isProtectedTitleCache());
}
- Pager<TaxonBase> pager=importer.getTaxonService().findByTitle(TaxonBase.class, tnb.getTitleCache().split("sec.")[0].trim(), MatchMode.BEGINNING, null, null, null, null, null);
+ Pager<TaxonBase> pager=importer.getTaxonService().findByTitleWithRestrictions(TaxonBase.class, tnb.getTitleCache().split("sec.")[0].trim(), MatchMode.BEGINNING, null, null, null, null, null);
List<TaxonBase>records = pager.getRecords();
List<Taxon> existingTaxons = new ArrayList<Taxon>();
return costs[s2.length()];
}
- Map<Rank, Taxon> hierarchy = new HashMap<Rank, Taxon>();
+ Map<Rank, Taxon> hierarchy = new HashMap<>();
/**
- * @param taxonNameBase
+ * @param taxonName
*/
@SuppressWarnings("rawtypes")
- public void lookForParentNode(NonViralName<?> taxonNameBase, Taxon tax, Reference ref, MyName myName) {
- logger.info("lookForParentNode "+taxonNameBase.getTitleCache()+" for "+myName.toString());
- //System.out.println("LOOK FOR PARENT NODE "+taxonnamebase.toString()+"; "+tax.toString()+"; "+taxonnamebase.getRank());
+ public void lookForParentNode(INonViralName taxonName, Taxon tax, Reference ref, MyName myName) {
+ logger.info("lookForParentNode "+taxonName.getTitleCache()+" for "+myName.toString());
+ //System.out.println("LOOK FOR PARENT NODE "+taxonname.toString()+"; "+tax.toString()+"; "+taxonname.getRank());
INonViralNameParser parser = NonViralNameParserImpl.NewInstance();
- if (taxonNameBase.getRank().equals(Rank.FORM())){
+ if (taxonName.getRank().equals(Rank.FORM())){
handleFormHierarchy(ref, myName, parser);
}
- else if (taxonNameBase.getRank().equals(Rank.VARIETY())){
+ else if (taxonName.getRank().equals(Rank.VARIETY())){
handleVarietyHierarchy(ref, myName, parser);
}
- else if (taxonNameBase.getRank().equals(Rank.SUBSPECIES())){
+ else if (taxonName.getRank().equals(Rank.SUBSPECIES())){
handleSubSpeciesHierarchy(ref, myName, parser);
}
- else if (taxonNameBase.getRank().equals(Rank.SPECIES())){
+ else if (taxonName.getRank().equals(Rank.SPECIES())){
handleSpeciesHierarchy(ref, myName, parser);
}
- else if (taxonNameBase.getRank().equals(Rank.SUBGENUS())){
+ else if (taxonName.getRank().equals(Rank.SUBGENUS())){
handleSubgenusHierarchy(ref, myName, parser);
}
- if (taxonNameBase.getRank().equals(Rank.GENUS())){
+ if (taxonName.getRank().equals(Rank.GENUS())){
handleGenusHierarchy(ref, myName, parser);
}
- if (taxonNameBase.getRank().equals(Rank.SUBTRIBE())){
+ if (taxonName.getRank().equals(Rank.SUBTRIBE())){
handleSubtribeHierarchy(ref, myName, parser);
}
- if (taxonNameBase.getRank().equals(Rank.TRIBE())){
+ if (taxonName.getRank().equals(Rank.TRIBE())){
handleTribeHierarchy(ref, myName, parser);
}
- if (taxonNameBase.getRank().equals(Rank.SUBFAMILY())){
+ if (taxonName.getRank().equals(Rank.SUBFAMILY())){
handleSubfamilyHierarchy(ref, myName, parser);
}
}
if(parentStr!=null){
Taxon parent = null;
- Pager<TaxonBase> taxontest = importer.getTaxonService().findByTitle(TaxonBase.class, parentStr, MatchMode.BEGINNING, null, null, null, null, null);
+ Pager<TaxonBase> taxontest = importer.getTaxonService().findByTitleWithRestrictions(TaxonBase.class, parentStr, MatchMode.BEGINNING, null, null, null, null, null);
for(TaxonBase tb:taxontest.getRecords()){
try {
if (tb.getName().getRank().equals(r)) {
}
}
if(parent == null) {
- NonViralName<?> parentNameName = (NonViralName<?>) parser.parseFullName(parentStr, nomenclaturalCode, r);
+ INonViralName parentNameName = parser.parseFullName(parentStr, nomenclaturalCode, r);
Taxon tmp = findMatchingTaxon(parentNameName,ref);
if(tmp ==null)
{
r = Rank.FAMILY();
}
if(parentStr!=null){
- NonViralName<?> parentNameName = (NonViralName<?>) parser.parseFullName(parentStr, nomenclaturalCode, r);
+ INonViralName parentNameName = parser.parseFullName(parentStr, nomenclaturalCode, r);
Taxon parent = Taxon.NewInstance(parentNameName, ref); //sec set null
// importer.getTaxonService().save(parent);
// parent = CdmBase.deproxy(parent, Taxon.class);
r = Rank.FAMILY();
}
if(parentStr!=null){
- NonViralName<?> parentNameName = (NonViralName<?>) parser.parseFullName(parentStr, nomenclaturalCode, r);
+ INonViralName parentNameName = parser.parseFullName(parentStr, nomenclaturalCode, r);
Taxon parent = Taxon.NewInstance(parentNameName, ref); //sec set null
// importer.getTaxonService().save(parent);
// parent = CdmBase.deproxy(parent, Taxon.class);
r = Rank.FAMILY();
}
if(parentStr!=null){
- NonViralName<?> parentNameName = (NonViralName<?>) parser.parseFullName(parentStr, nomenclaturalCode, r);
+ INonViralName parentNameName = parser.parseFullName(parentStr, nomenclaturalCode, r);
Taxon parent = Taxon.NewInstance(parentNameName, ref); //sec set null
// importer.getTaxonService().save(parent);
// parent = CdmBase.deproxy(parent, Taxon.class);
r = Rank.FAMILY();
}
if(parentStr!=null){
- NonViralName<?> parentNameName = (NonViralName<?>) parser.parseFullName(parentStr, nomenclaturalCode, r);
+ INonViralName parentNameName = parser.parseFullName(parentStr, nomenclaturalCode, r);
Taxon parent = Taxon.NewInstance(parentNameName, ref); //sec set null
// importer.getTaxonService().save(parent);
// parent = CdmBase.deproxy(parent, Taxon.class);
* @return
*/
private Taxon handleParentName(Reference ref, MyName myName, INonViralNameParser<?> parser, String parentStr, Rank r) {
- NonViralName<?> parentNameName = (NonViralName<?>) parser.parseFullName(parentStr, nomenclaturalCode, r);
+ INonViralName parentNameName = parser.parseFullName(parentStr, nomenclaturalCode, r);
Taxon parent = Taxon.NewInstance(parentNameName, ref); //sec set null
// importer.getTaxonService().save(parent);
// parent = CdmBase.deproxy(parent, Taxon.class);
* @param insertAsExisting
* @param refMods
*/
- private void logDecision(NonViralName<?> tnb, Taxon bestMatchingTaxon, boolean insertAsExisting, Reference refMods) {
+ private void logDecision(INonViralName tnb, Taxon bestMatchingTaxon, boolean insertAsExisting, Reference refMods) {
try{
- FileWriter fstream = new FileWriter(TaxonXImport.LOG_FOLDER + "Decisions_"+classification.toString()+".txt",true);
+ FileWriter fstream = new FileWriter(TaxonXImport.LOG_FOLDER + "Decisions_"+classification.toString()+".txt", true);
BufferedWriter out = new BufferedWriter(fstream);
- out.write(tnb.getTitleCache()+" sec. "+refMods+"\t"+bestMatchingTaxon.getTitleCache()+"\t"+insertAsExisting+"\n");
+ out.write(tnb.getTitleCache() + " sec. " + refMods + "\t" + bestMatchingTaxon.getTitleCache() + "\t" + insertAsExisting + "\n");
//Close the output stream
out.close();
}catch (Exception e){//Catch exception if any