Revision b9e54ec8
Added by Andreas Müller over 6 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/parser/NonViralNameParserImpl.java | ||
---|---|---|
296 | 296 |
|
297 | 297 |
//don't parse if name can't be separated |
298 | 298 |
nameToBeFilled.addParsingProblem(ParserProblem.NameReferenceSeparation); |
299 |
nameToBeFilled.setTitleCache(fullReferenceString,true); |
|
300 |
nameToBeFilled.setFullTitleCache(fullReferenceString,true); |
|
299 |
nameToBeFilled.setTitleCache(fullReferenceString, true);
|
|
300 |
nameToBeFilled.setFullTitleCache(fullReferenceString, true);
|
|
301 | 301 |
// FIXME Quick fix, otherwise search would not deliver results for unparsable names |
302 |
nameToBeFilled.setNameCache(fullReferenceString,true); |
|
302 |
nameToBeFilled.setNameCache(fullReferenceString, true);
|
|
303 | 303 |
// END |
304 | 304 |
nameToBeFilled.setProblemStarts(start); |
305 | 305 |
nameToBeFilled.setProblemEnds(fullReferenceString.length()); |
... | ... | |
484 | 484 |
//parse title and author |
485 | 485 |
ref = parseReferenceTitle(strReference, yearPart, isInReference); |
486 | 486 |
if (ref.hasProblem()){ |
487 |
//we need to protect both caches otherwise the titleCache is incorrectly build from atomized parts |
|
487 | 488 |
ref.setTitleCache( (isInReference ? "in ":"") + originalStrReference, true); |
488 | 489 |
ref.setAbbrevTitleCache( (isInReference ? "in ":"") + originalStrReference, true); |
489 | 490 |
} |
... | ... | |
497 | 498 |
* @param strReference |
498 | 499 |
* @return |
499 | 500 |
*/ |
500 |
private INomenclaturalReference makeDetailYearUnparsable(NonViralName<?> nameToBeFilled, String strReference) { |
|
501 |
INomenclaturalReference ref; |
|
502 |
//ref = Generic.NewInstance(); |
|
501 |
private Reference makeDetailYearUnparsable(NonViralName<?> nameToBeFilled, String strReference) { |
|
502 |
Reference ref; |
|
503 | 503 |
|
504 | 504 |
ref = ReferenceFactory.newGeneric(); |
505 |
ref.setTitleCache(strReference,true); |
|
505 |
ref.setTitleCache(strReference, true); |
|
506 |
ref.setAbbrevTitleCache(strReference, true); |
|
506 | 507 |
ref.setProblemEnds(strReference.length()); |
507 | 508 |
ref.addParsingProblem(ParserProblem.CheckDetailOrYear); |
508 | 509 |
nameToBeFilled.addParsingProblem(ParserProblem.CheckDetailOrYear); |
... | ... | |
563 | 564 |
} |
564 | 565 |
|
565 | 566 |
private void makeUnparsableRefTitle(INomenclaturalReference result, String reference){ |
566 |
result.setTitleCache(reference,true); |
|
567 |
result.setAbbrevTitleCache(reference,true); |
|
567 |
//need to set both to protected otherwise titleCache is created from atomized parts |
|
568 |
result.setTitleCache(reference, true); |
|
569 |
result.setAbbrevTitleCache(reference, true); |
|
568 | 570 |
result.addParsingProblem(ParserProblem.UnparsableReferenceTitle); |
569 | 571 |
} |
570 | 572 |
|
... | ... | |
661 | 663 |
IBook result = ReferenceFactory.newBook(); |
662 | 664 |
reference = makeEdition(result, reference); |
663 | 665 |
reference = makeVolume(result, reference); |
664 |
result.setTitle(reference); |
|
666 |
result.setAbbrevTitle(reference);
|
|
665 | 667 |
return result; |
666 | 668 |
} |
667 | 669 |
|
... | ... | |
672 | 674 |
Reference result = ReferenceFactory.newArticle(); |
673 | 675 |
reference = makeVolume(result, reference); |
674 | 676 |
Reference inJournal = ReferenceFactory.newJournal(); |
675 |
inJournal.setTitle(reference); |
|
677 |
inJournal.setAbbrevTitle(reference);
|
|
676 | 678 |
result.setInReference(inJournal); |
677 | 679 |
return result; |
678 | 680 |
} |
... | ... | |
695 | 697 |
}else{ |
696 | 698 |
logger.warn("Unexpected non matching book section author part"); |
697 | 699 |
//TODO do we want to record a 'problem' here? |
698 |
result.setTitleCache(reference,true); |
|
700 |
result.setTitleCache(reference, true); |
|
701 |
result.setAbbrevTitleCache(reference, true); |
|
699 | 702 |
} |
700 | 703 |
|
701 | 704 |
return result; |
... | ... | |
895 | 898 |
authorString = fullNameString.substring(epi[0].length()+ 1 + epi[1].length() +1 + epi[2].length() + 1 + epi[3].length()); |
896 | 899 |
}else{ |
897 | 900 |
nameToBeFilled.addParsingProblem(ParserProblem.OldInfraSpeciesNotSupported); |
898 |
nameToBeFilled.setTitleCache(fullNameString,true); |
|
901 |
nameToBeFilled.setTitleCache(fullNameString, true);
|
|
899 | 902 |
// FIXME Quick fix, otherwise search would not deilver results for unparsable names |
900 | 903 |
nameToBeFilled.setNameCache(fullNameString,true); |
901 | 904 |
// END |
... | ... | |
956 | 959 |
//none |
957 | 960 |
else{ |
958 | 961 |
nameToBeFilled.addParsingProblem(ParserProblem.UnparsableNamePart); |
959 |
nameToBeFilled.setTitleCache(fullNameString,true); |
|
962 |
nameToBeFilled.setTitleCache(fullNameString, true);
|
|
960 | 963 |
// FIXME Quick fix, otherwise search would not deilver results for unparsable names |
961 | 964 |
nameToBeFilled.setNameCache(fullNameString, true); |
962 | 965 |
// END |
... | ... | |
980 | 983 |
return; |
981 | 984 |
} catch (UnknownCdmTypeException e) { |
982 | 985 |
nameToBeFilled.addParsingProblem(ParserProblem.RankNotSupported); |
983 |
nameToBeFilled.setTitleCache(fullNameString,true); |
|
986 |
nameToBeFilled.setTitleCache(fullNameString, true);
|
|
984 | 987 |
// FIXME Quick fix, otherwise search would not deilver results for unparsable names |
985 | 988 |
nameToBeFilled.setNameCache(fullNameString,true); |
986 | 989 |
// END |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/parser/NonViralNameParserImplTest.java | ||
---|---|---|
412 | 412 |
IReference nomRef = multipleAuthorRefName.getNomenclaturalReference(); |
413 | 413 |
Assert.assertNotNull("nomRef must have inRef", ((Reference)nomRef).getInReference()); |
414 | 414 |
Reference inRef = ((Reference)nomRef).getInReference(); |
415 |
String title = inRef.getTitle();
|
|
416 |
assertEquals("InRef title should be Sp. Pl.", "Sp. Pl.", title);
|
|
415 |
String abbrevTitle = inRef.getAbbrevTitle();
|
|
416 |
assertEquals("InRef title should be Sp. Pl.", "Sp. Pl.", abbrevTitle);
|
|
417 | 417 |
assertTrue(inRef.getAuthorship() instanceof Team); |
418 | 418 |
Team team = (Team)inRef.getAuthorship(); |
419 | 419 |
assertEquals(3, team.getTeamMembers().size()); |
... | ... | |
438 | 438 |
nomRef = multipleAuthorName.getNomenclaturalReference(); |
439 | 439 |
Assert.assertNotNull("nomRef must have inRef", ((Reference)nomRef).getInReference()); |
440 | 440 |
inRef = ((Reference)nomRef).getInReference(); |
441 |
title = inRef.getTitle();
|
|
442 |
assertEquals("InRef title should be Sp. Pl.", "Sp. Pl.", title);
|
|
441 |
abbrevTitle = inRef.getAbbrevTitle();
|
|
442 |
assertEquals("InRef title should be Sp. Pl.", "Sp. Pl.", abbrevTitle);
|
|
443 | 443 |
assertTrue(inRef.getAuthorship() instanceof Person); |
444 | 444 |
Person person = (Person)inRef.getAuthorship(); |
445 | 445 |
assertEquals("Book author should be L.", "L.", person.getNomenclaturalTitle()); |
... | ... | |
454 | 454 |
assertEquals("Second team member should be Aber", "Aber", team.getTeamMembers().get(1).getTitleCache()); |
455 | 455 |
nomRef = multipleAuthorName.getNomenclaturalReference(); |
456 | 456 |
Assert.assertNull("nomRef must not have inRef as it is a book itself", ((Reference)nomRef).getInReference()); |
457 |
title = nomRef.getTitle();
|
|
458 |
assertEquals("InRef title should be Sp. Pl.", "Sp. Pl.", title);
|
|
457 |
abbrevTitle = nomRef.getAbbrevTitle();
|
|
458 |
assertEquals("InRef title should be Sp. Pl.", "Sp. Pl.", abbrevTitle);
|
|
459 | 459 |
assertTrue(nomRef.getAuthorship() instanceof Team); |
460 | 460 |
team = (Team)nomRef.getAuthorship(); |
461 | 461 |
assertEquals(3, team.getTeamMembers().size()); |
... | ... | |
997 | 997 |
assertNotNull(inBook.getAuthorship()); |
998 | 998 |
assertEquals("Otto", inBook.getAuthorship().getTitleCache()); |
999 | 999 |
assertEquals("Otto, Sp. Pl. 4(6)", inBook.getTitleCache()); |
1000 |
assertEquals("Sp. Pl.", inBook.getTitle()); |
|
1000 |
assertEquals("Sp. Pl.", inBook.getAbbrevTitle());
|
|
1001 | 1001 |
assertEquals("4(6)", inBook.getVolume()); |
1002 | 1002 |
assertTrue("Name author and reference author should be the same", name2.getCombinationAuthorship() == ((Reference)name2.getNomenclaturalReference()).getAuthorship()); |
1003 | 1003 |
|
... | ... | |
1015 | 1015 |
assertNotNull(journal); |
1016 | 1016 |
//assertEquals("Sp. Pl. 4(6)", inBook.getTitleCache()); |
1017 | 1017 |
assertEquals("Sp. Pl.",((Reference) journal).getTitleCache()); |
1018 |
assertEquals("Sp. Pl.", journal.getTitle()); |
|
1018 |
assertEquals("Sp. Pl.", journal.getAbbrevTitle());
|
|
1019 | 1019 |
assertEquals("4(6)",((IArticle)ref).getVolume()); |
1020 | 1020 |
assertTrue("Name author and reference author should be the same", name3.getCombinationAuthorship() == name3.getNomenclaturalReference().getAuthorship()); |
1021 | 1021 |
|
... | ... | |
1047 | 1047 |
journal = ((IArticle)ref).getInJournal(); |
1048 | 1048 |
assertNotNull(journal); |
1049 | 1049 |
assertEquals(journalTitle, ((Reference) journal).getTitleCache()); |
1050 |
assertEquals(journalTitle, journal.getTitle()); |
|
1050 |
assertEquals(journalTitle, journal.getAbbrevTitle());
|
|
1051 | 1051 |
assertEquals("4(6)", ((IArticle)ref).getVolume()); |
1052 | 1052 |
|
1053 | 1053 |
//Zoo name |
... | ... | |
1460 | 1460 |
assertNotNull(name.getNomenclaturalReference()); |
1461 | 1461 |
INomenclaturalReference ref = name.getNomenclaturalReference(); |
1462 | 1462 |
assertEquals("1987", ref.getYear()); |
1463 |
assertEquals("Sp. Pl.", ref.getTitle()); |
|
1463 |
assertEquals("Sp. Pl.", ref.getAbbrevTitle());
|
|
1464 | 1464 |
} |
1465 | 1465 |
|
1466 | 1466 |
|
... | ... | |
1930 | 1930 |
assertEquals( "Nees & Mart.", combinationAuthor.getNomenclaturalTitle()); |
1931 | 1931 |
nomRef = (Reference)name.getNomenclaturalReference(); |
1932 | 1932 |
assertEquals(ReferenceType.Article, nomRef.getType()); |
1933 |
assertEquals("Nova Acta Phys.-Med. Acad. Caes.\u2013Leop. Nat. Cur.", nomRef.getInReference().getTitle()); |
|
1933 |
assertEquals("Nova Acta Phys.-Med. Acad. Caes.\u2013Leop. Nat. Cur.", nomRef.getInReference().getAbbrevTitle());
|
|
1934 | 1934 |
assertEquals("12", nomRef.getVolume()); |
1935 | 1935 |
assertEquals("14", name.getNomenclaturalMicroReference()); |
1936 | 1936 |
assertEquals("1824", nomRef.getYear()); |
Also available in: Unified diff
#5960 Use abbrevTitle for reference parsing