Project

General

Profile

« Previous | Next » 

Revision 44f8b525

Added by Andreas Müller almost 7 years ago

ref #6368 , ref #6671, ref #6630 adapt eflora to no taxon name model

View differences:

cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/NepenthaceIpniActivator.java
22 22
import eu.etaxonomy.cdm.ext.ipni.IpniService;
23 23
import eu.etaxonomy.cdm.ext.ipni.IpniServiceNamesConfigurator;
24 24
import eu.etaxonomy.cdm.io.common.utils.ImportDeduplicationHelper;
25
import eu.etaxonomy.cdm.model.name.BotanicalName;
26 25
import eu.etaxonomy.cdm.model.name.IBotanicalName;
27 26
import eu.etaxonomy.cdm.model.name.Rank;
28 27
import eu.etaxonomy.cdm.model.reference.Reference;
......
117 116
    IpniService ipniService = new IpniService();//(IpniService)app.getBean("ipniService");
118 117

  
119 118
    Rank rank = null;
120
      List<BotanicalName> names = ipniService.getNamesAdvanced(null, "Nepenthes", null, null, null, null,
119
      List<IBotanicalName> names = ipniService.getNamesAdvanced(null, "Nepenthes", null, null, null, null,
121 120
              null, null, rank, namesConfig, app);
122 121

  
123 122
      System.out.println(names.size());
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/EfloraTaxonImport.java
65 65
import eu.etaxonomy.cdm.model.name.Rank;
66 66
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
67 67
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
68
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
68
import eu.etaxonomy.cdm.model.name.TaxonName;
69 69
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
70 70
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
71 71
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
......
1026 1026
			}else{
1027 1027
				logger.error("Unhandled type designation class" + typeDesignation.getClass().getName());
1028 1028
			}
1029
			for (TaxonNameBase name : homotypicalGroup.getTypifiedNames()){
1029
			for (TaxonName name : homotypicalGroup.getTypifiedNames()){
1030 1030
				name.addTypeDesignation(typeDesignation, true);
1031 1031
			}
1032 1032
		}
......
1064 1064
		//clean
1065 1065
		typeText = cleanNameType(typeText);
1066 1066
		//create name
1067
		TaxonNameBase<?,?> nameType = (TaxonNameBase<?,?>)parser.parseFullName(typeText, NomenclaturalCode.ICNAFP, Rank.SPECIES());
1067
		TaxonName nameType = (TaxonName)parser.parseFullName(typeText, NomenclaturalCode.ICNAFP, Rank.SPECIES());
1068 1068
		((NameTypeDesignation) typeDesignation).setTypeName(nameType);
1069 1069
		//TODO wie können NameTypes den Namen zugeordnet werden? -  wird aber vom Portal via NameCache matching gemacht
1070 1070
	}
......
1154 1154
	//body/taxon/
1155 1155
	private HomotypicalGroup handleNomTaxon(EfloraImportState state, Element elNom, Taxon taxon, HomotypicalGroup homotypicalGroup, boolean isSynonym) {
1156 1156
	    INonViralName nvn = makeName(taxon, homotypicalGroup, isSynonym);
1157
	    TaxonNameBase<?,?> name = TaxonNameBase.castAndDeproxy(nvn);
1157
	    TaxonName name = TaxonName.castAndDeproxy(nvn);
1158 1158
	    String num = null;
1159 1159

  
1160 1160
		boolean hasGenusInfo = false;
......
1276 1276

  
1277 1277

  
1278 1278
	//merge with handleNomTaxon
1279
	private void handleHomonym(EfloraImportState state, Element elHomonym, TaxonNameBase upperName) {
1279
	private void handleHomonym(EfloraImportState state, Element elHomonym, TaxonName upperName) {
1280 1280
		verifyNoAttribute(elHomonym);
1281 1281

  
1282 1282
		//hommonym name
1283
		TaxonNameBase<?,?> homonymName = TaxonNameFactory.NewBotanicalInstance(upperName.getRank());
1283
		TaxonName homonymName = TaxonNameFactory.NewBotanicalInstance(upperName.getRank());
1284 1284
		homonymName.setGenusOrUninomial(upperName.getGenusOrUninomial());
1285 1285
		homonymName.setInfraGenericEpithet(upperName.getInfraGenericEpithet());
1286 1286
		homonymName.setSpecificEpithet(upperName.getSpecificEpithet());
......
1360 1360
	 * @param name
1361 1361
	 * @param value
1362 1362
	 */
1363
	protected TeamOrPersonBase handleNameUsage(Taxon taxon, INonViralName name, String referenceTitle, TeamOrPersonBase lastTeam) {
1363
	protected TeamOrPersonBase handleNameUsage(Taxon taxon, TaxonName name, String referenceTitle, TeamOrPersonBase lastTeam) {
1364 1364
		Reference ref = ReferenceFactory.newGeneric();
1365 1365
		referenceTitle = removeStartingSymbols(referenceTitle, ref);
1366 1366

  
......
1375 1375

  
1376 1376
		TaxonDescription description = getDescription(taxon);
1377 1377
		TextData textData = TextData.NewInstance(Feature.CITATION());
1378
		textData.addSource(OriginalSourceType.PrimaryTaxonomicSource, null, null, ref, microReference, (TaxonNameBase)name, null);
1378
		textData.addSource(OriginalSourceType.PrimaryTaxonomicSource, null, null, ref, microReference,
1379
		        name, null);
1379 1380
		description.addElement(textData);
1380 1381
		return team;
1381 1382
	}
......
1490 1491
	 * @param name
1491 1492
	 * @return
1492 1493
	 */
1493
	protected String parseHomonym(String detail, TaxonNameBase name) {
1494
	protected String parseHomonym(String detail, TaxonName name) {
1494 1495
		String result;
1495 1496
		if (detail == null){
1496 1497
			return detail;
......
1516 1517
			String homonymString = detail.substring(end);
1517 1518

  
1518 1519
			//hommonym name
1519
			TaxonNameBase<?,?> homonymName = TaxonNameFactory.NewBotanicalInstance(name.getRank());
1520
			TaxonName homonymName = TaxonNameFactory.NewBotanicalInstance(name.getRank());
1520 1521
			homonymName.setGenusOrUninomial(name.getGenusOrUninomial());
1521 1522
			homonymName.setInfraGenericEpithet(name.getInfraGenericEpithet());
1522 1523
			homonymName.setSpecificEpithet(name.getSpecificEpithet());
......
1559 1560
	 * @param name
1560 1561
	 * @param value
1561 1562
	 */
1562
	protected TeamOrPersonBase handleNomenclaturalReference(TaxonNameBase<?,?> name, String value) {
1563
	protected TeamOrPersonBase handleNomenclaturalReference(TaxonName name, String value) {
1563 1564
		Reference nomRef = ReferenceFactory.newGeneric();
1564 1565
		nomRef.setTitleCache(value, true);
1565 1566
		parseNomStatus(nomRef, name);
......
1648 1649
	 * @param isSynonym
1649 1650
	 * @return
1650 1651
	 */
1651
	private TaxonNameBase makeName(Taxon taxon,HomotypicalGroup homotypicalGroup, boolean isSynonym) {
1652
		TaxonNameBase<?,?> name;
1652
	private TaxonName makeName(Taxon taxon,HomotypicalGroup homotypicalGroup, boolean isSynonym) {
1653

  
1654
	    TaxonName name;
1653 1655
		if (isSynonym){
1654 1656
			name = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES(), homotypicalGroup);
1655 1657
			SynonymType synonymType = SynonymType.HETEROTYPIC_SYNONYM_OF();
......
1974 1976
	 * @param value
1975 1977
	 * @param taxonNameBase
1976 1978
	 */
1977
	private void handleSpecies(String value, TaxonNameBase taxonNameBase) {
1979
	private void handleSpecies(String value, TaxonName taxonNameBase) {
1978 1980
		//do nothing
1979 1981
	}
1980 1982

  
......
1982 1984
	 * @param value
1983 1985
	 * @param taxonNameBase
1984 1986
	 */
1985
	private void handleVariety(String value, TaxonNameBase taxonNameBase) {
1987
	private void handleVariety(String value, TaxonName taxonNameBase) {
1986 1988
		//do nothing
1987 1989
	}
1988 1990

  
......
1990 1992
	 * @param value
1991 1993
	 * @param taxonNameBase
1992 1994
	 */
1993
	private void handleSubSpecies(String value, TaxonNameBase taxonNameBase) {
1995
	private void handleSubSpecies(String value, TaxonName taxonNameBase) {
1994 1996
		//do nothing
1995 1997
	}
1996 1998

  
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/centralAfrica/ericaceae/CentralAfricaEricaceaeTaxonImport.java
33 33
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
34 34
import eu.etaxonomy.cdm.model.name.INonViralName;
35 35
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
36
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
36
import eu.etaxonomy.cdm.model.name.TaxonName;
37 37
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
38 38
import eu.etaxonomy.cdm.model.reference.Reference;
39 39
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
......
52 52

  
53 53

  
54 54
	@Override
55
	protected TeamOrPersonBase handleNomenclaturalReference(TaxonNameBase<?,?> name, String value) {
55
	protected TeamOrPersonBase handleNomenclaturalReference(TaxonName name, String value) {
56 56
		Reference nomRef = ReferenceFactory.newGeneric();
57 57
		nomRef.setTitleCache(value, true);
58 58
		parseNomStatus(nomRef, name);
......
163 163
	 * @param value
164 164
	 */
165 165
	@Override
166
	protected TeamOrPersonBase<?> handleNameUsage(Taxon taxon, INonViralName name,
166
	protected TeamOrPersonBase<?> handleNameUsage(Taxon taxon, TaxonName name,
167 167
	        String referenceTitle, TeamOrPersonBase lastTeam) {
168 168

  
169 169
		Reference ref = ReferenceFactory.newGeneric();
......
188 188
	//		parseReferenceType(ref);
189 189

  
190 190
			TextData textData = TextData.NewInstance(Feature.CITATION());
191
			textData.addSource(OriginalSourceType.PrimaryTaxonomicSource, null, null, singleRef, microReference, (TaxonNameBase) name, null);
191
			textData.addSource(OriginalSourceType.PrimaryTaxonomicSource, null, null, singleRef, microReference,
192
			        name, null);
192 193
			description.addElement(textData);
193 194
		}
194 195
		return team;
......
354 355
		typeRef = removeTypePrefix(typeRef);
355 356
		TypeDesignationBase typeDesignation = SpecimenTypeDesignation.NewInstance();
356 357
		makeSpecimenTypeDesignation(new StringBuffer("Type"), typeRef, typeDesignation);
357
		for (TaxonNameBase name : homotypicalGroup.getTypifiedNames()){
358
		for (TaxonName name : homotypicalGroup.getTypifiedNames()){
358 359
			name.addTypeDesignation(typeDesignation, true);
359 360
		}
360 361
	}
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/centralAfrica/ferns/CentralAfricaFernsTaxonImport.java
44 44
import eu.etaxonomy.cdm.model.common.CdmBase;
45 45
import eu.etaxonomy.cdm.model.common.ExtensionType;
46 46
import eu.etaxonomy.cdm.model.common.TimePeriod;
47
import eu.etaxonomy.cdm.model.name.BotanicalName;
48 47
import eu.etaxonomy.cdm.model.name.IBotanicalName;
49 48
import eu.etaxonomy.cdm.model.name.INonViralName;
50 49
import eu.etaxonomy.cdm.model.name.ITaxonNameBase;
......
56 55
import eu.etaxonomy.cdm.model.name.Rank;
57 56
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
58 57
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
59
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
58
import eu.etaxonomy.cdm.model.name.TaxonName;
60 59
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
61 60
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
62 61
import eu.etaxonomy.cdm.model.occurrence.Collection;
......
191 190

  
192 191
	private TaxonBase mapTypes(ResultSet rs, CentralAfricaFernsImportState state) throws SQLException{
193 192
		TaxonBase<?> taxonBase = state.getRelatedObject(state.CURRENT_OBJECT_NAMESPACE, state.CURRENT_OBJECT_ID, TaxonBase.class);
194
		TaxonNameBase name = taxonBase.getName();
193
		TaxonName name = taxonBase.getName();
195 194
		for (int i = 1; i <= 5; i++){
196 195
			String[] typeInfo = new String[3];
197 196
			typeInfo = getTypeInfo(rs, i);
......
221 220

  
222 221

  
223 222

  
224
	private void makeSingleType(CentralAfricaFernsImportState state, TaxonNameBase name, String typeString, String typeCollectorString, String typeLocationString) {
223
	private void makeSingleType(CentralAfricaFernsImportState state, TaxonName name, String typeString, String typeCollectorString, String typeLocationString) {
225 224
		if (name.getRank().isHigher(Rank.SPECIES())){
226 225
			//TODO move to TaxonRelationImport
227 226
			handleNameType(state, name, typeString, typeCollectorString, typeLocationString);
......
232 231

  
233 232

  
234 233

  
235
	private void handleSpecimenType(CentralAfricaFernsImportState state, TaxonNameBase name, String typeString, String typeCollectorString, String typeLocationString) {
234
	private void handleSpecimenType(CentralAfricaFernsImportState state, TaxonName name, String typeString, String typeCollectorString, String typeLocationString) {
236 235
		List<SpecimenTypeDesignation> designations = new ArrayList<SpecimenTypeDesignation>();
237 236
		typeLocationString = CdmUtils.Nz(typeLocationString);
238 237
		if (typeLocationString.equalsIgnoreCase("not located")){
......
431 430

  
432 431

  
433 432

  
434
	private void handleNameType(CentralAfricaFernsImportState state, TaxonNameBase name, String typeString, String typeCollectorString, String typeLocation) {
433
	private void handleNameType(CentralAfricaFernsImportState state, TaxonName name, String typeString, String typeCollectorString, String typeLocation) {
435 434
		String originalString = typeString; //just for testing
436 435
		if (StringUtils.isNotBlank(typeCollectorString)){
437 436
			logger.error(state.getTaxonNumber() + " - Type collector string for name type is not empty: " + typeCollectorString);
......
475 474
			IBotanicalName[] nameTypeNames = getNameTypeName(firstName);
476 475
			IBotanicalName nameTypeName = nameTypeNames[0];
477 476
			IBotanicalName nameTypeAcceptedName = nameTypeNames[1];
478
			nameTypeDesignation.setTypeName(TaxonNameBase.castAndDeproxy(nameTypeName));
477
			nameTypeDesignation.setTypeName(TaxonName.castAndDeproxy(nameTypeName));
479 478
			if (nameTypeName.isProtectedTitleCache()){
480 479
				logger.error(state.getTaxonNumber() + " - Name type could not be parsed: " + nameTypeName.getTitleCache());
481 480
			}
......
506 505
		if (strName.endsWith(",")){
507 506
			strName = strName.substring(0, strName.length() -1);
508 507
		}
509
		IBotanicalName result = (BotanicalName)NonViralNameParserImpl.NewInstance().parseFullName(strName, NomenclaturalCode.ICNAFP, Rank.SPECIES());
508
		IBotanicalName result = (IBotanicalName)NonViralNameParserImpl.NewInstance().parseFullName(strName, NomenclaturalCode.ICNAFP, Rank.SPECIES());
510 509
		return result;
511 510
	}
512 511

  
......
516 515
		//TODO implement get existing names
517 516
		logger.info("Not yet fully implemented");
518 517

  
519
		IBotanicalName[] result = new BotanicalName[2];
518
		IBotanicalName[] result = new IBotanicalName[2];
520 519
		if (strName.endsWith(",")){
521 520
			strName = strName.substring(0, strName.length() -1);
522 521
		}
......
530 529
				acceptedName = acceptedName.substring(0, acceptedName.length()-1);
531 530
			}
532 531
			acceptedName = acceptedName.replaceFirst("=", "").trim();
533
			result[1] = (BotanicalName)NonViralNameParserImpl.NewInstance().parseFullName(acceptedName, NomenclaturalCode.ICNAFP, null);
532
			result[1] = (IBotanicalName)NonViralNameParserImpl.NewInstance().parseFullName(acceptedName, NomenclaturalCode.ICNAFP, null);
534 533
			strName = notAcceptedName;
535 534
		}
536 535

  
537
		result[0] = (BotanicalName)NonViralNameParserImpl.NewInstance().parseFullName(strName, NomenclaturalCode.ICNAFP, Rank.SPECIES());
536
		result[0] = (IBotanicalName)NonViralNameParserImpl.NewInstance().parseFullName(strName, NomenclaturalCode.ICNAFP, Rank.SPECIES());
538 537
		return result;
539 538
	}
540 539

  
......
845 844
			taxon = Synonym.NewInstance(taxonName, sec);
846 845
		}else{
847 846
			logger.warn(taxonNumber + ": Status not given for taxon " );
848
			taxon = Taxon.NewUnknownStatusInstance(TaxonNameBase.castAndDeproxy(taxonName), sec);
847
			taxon = Taxon.NewUnknownStatusInstance(TaxonName.castAndDeproxy(taxonName), sec);
849 848
		}
850 849
		return taxon;
851 850
	}
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/centralAfrica/ferns/CentralAfricaFernsTaxonRelationImport.java
47 47
import eu.etaxonomy.cdm.model.location.NamedArea;
48 48
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
49 49
import eu.etaxonomy.cdm.model.location.NamedAreaType;
50
import eu.etaxonomy.cdm.model.name.BotanicalName;
51 50
import eu.etaxonomy.cdm.model.name.IBotanicalName;
52 51
import eu.etaxonomy.cdm.model.name.INonViralName;
53 52
import eu.etaxonomy.cdm.model.name.Rank;
54
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
53
import eu.etaxonomy.cdm.model.name.TaxonName;
55 54
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
56 55
import eu.etaxonomy.cdm.model.reference.Reference;
57 56
import eu.etaxonomy.cdm.model.taxon.Classification;
......
528 527
	 */
529 528
	private Taxon checkIsGrandParent(Taxon childTaxon, Taxon grandParentTaxon) {
530 529
		IBotanicalName lowerName = childTaxon.getName();
531
		IBotanicalName higherName = CdmBase.deproxy(grandParentTaxon.getName(), BotanicalName.class);
530
		IBotanicalName higherName = CdmBase.deproxy(grandParentTaxon.getName());
532 531

  
533 532
		//TODO was wenn lowerTaxon constructed ist
534 533
		logger.warn("checkIsGrandParent not yet fully implemented");
......
925 924
			String province = rs.getString("Distribution - Province");
926 925
			String distributionDetailed = rs.getString("Distribution - detailed");
927 926
			if (taxonBase != null){
928
				TaxonNameBase<?,?> nameUsedInSource = taxonBase.getName();
927
				TaxonName nameUsedInSource = taxonBase.getName();
929 928
				Taxon taxon = getAcceptedTaxon(taxonBase);
930 929
				if (taxon != null){
931 930

  
......
1000 999
	 * @param taxonBase
1001 1000
	 * @param countriesString
1002 1001
	 */
1003
	private void makeCountries(CentralAfricaFernsImportState state, String taxonNumber, Taxon taxon, TaxonNameBase nameUsedInSource, String countriesString, String province, String distributionDetailed) {
1002
	private void makeCountries(CentralAfricaFernsImportState state, String taxonNumber, Taxon taxon, TaxonName nameUsedInSource, String countriesString, String province, String distributionDetailed) {
1004 1003
		countriesString = countriesString.replaceAll("\\*", "");
1005 1004
		countriesString = countriesString.replace("  ", " ");
1006 1005
		countriesString = countriesString.replace(", endemic", " - endemic");
......
1028 1027
	}
1029 1028

  
1030 1029

  
1031
	private void makeSingleCountry(CentralAfricaFernsImportState state, String taxonNumber, Taxon taxon, TaxonNameBase nameUsedInSource, String country) throws UndefinedTransformerMethodException {
1030
	private void makeSingleCountry(CentralAfricaFernsImportState state, String taxonNumber, Taxon taxon, TaxonName nameUsedInSource, String country) throws UndefinedTransformerMethodException {
1032 1031
		boolean areaDoubtful = false;
1033 1032
		Distribution distribution = Distribution.NewInstance(null, PresenceAbsenceTerm.PRESENT());
1034 1033
		Reference sourceReference = this.sourceReference;
......
1118 1117
	}
1119 1118

  
1120 1119

  
1121
	private String makeCountryBrackets(CentralAfricaFernsImportState state, String taxonNumber, Taxon taxon, TaxonNameBase<?,?> nameUsedInSource, String country) {
1120
	private String makeCountryBrackets(CentralAfricaFernsImportState state, String taxonNumber, Taxon taxon,
1121
	        TaxonName nameUsedInSource, String country) {
1122 1122
		String[] split = (country + " ").split("\\(.*\\)");
1123 1123
		if (split.length == 2){
1124 1124
			String bracket = country.substring(split[0].length()+1, country.indexOf(")"));

Also available in: Unified diff