Revision f2e74d5a
Added by Andreas Müller over 5 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelReferenceImport.java | ||
---|---|---|
254 | 254 |
// } |
255 | 255 |
// logger.info("end make references with no 1 in-reference ... " + getSuccessString(success)); |
256 | 256 |
state.setReferenceSecondPath(false); |
257 |
|
|
257 |
logger.warn("Parsed book volumes: " + parsedBookVolumes); |
|
258 | 258 |
} catch (SQLException e) { |
259 | 259 |
logger.error("SQLException:" + e); |
260 | 260 |
state.setUnsuccessfull(); |
... | ... | |
526 | 526 |
String refYear = (String)valueMap.get("refYear".toLowerCase()); |
527 | 527 |
reference.setDatePublished(ImportHelper.getDatePublished(refYear)); |
528 | 528 |
|
529 |
handleEdition(reference); |
|
530 |
|
|
529 | 531 |
//created, updated, notes |
530 | 532 |
doCreatedUpdatedNotes(state, reference, rs); |
531 | 533 |
|
... | ... | |
648 | 650 |
TeamOrPersonBase<?> author = getAuthorship(state, refAuthorString, nomAuthor, refId); |
649 | 651 |
ref.setAuthorship(author); |
650 | 652 |
|
653 |
if (ref.getType().equals(ReferenceType.Book)){ |
|
654 |
extraktBookVolume(ref); |
|
655 |
} |
|
656 |
|
|
651 | 657 |
//inRef |
652 | 658 |
Reference inRef = null; |
653 | 659 |
if (inRefFk != null){ |
... | ... | |
863 | 869 |
|
864 | 870 |
if (logger.isDebugEnabled()){logger.debug("RefType 'Book'");} |
865 | 871 |
Reference book = ReferenceFactory.newBook(); |
866 |
Integer refId = (Integer)valueMap.get("refId".toLowerCase()); |
|
872 |
// Integer refId = (Integer)valueMap.get("refId".toLowerCase());
|
|
867 | 873 |
|
868 | 874 |
//Set bookAttributes = new String[]{"edition", "isbn", "pages","publicationTown","publisher","volume"}; |
869 | 875 |
|
... | ... | |
891 | 897 |
book.setInSeries(printSeries); |
892 | 898 |
} |
893 | 899 |
book.setEditor(null); |
900 |
|
|
894 | 901 |
return book; |
895 | 902 |
|
896 | 903 |
} |
897 | 904 |
|
898 |
/** |
|
905 |
|
|
906 |
int parsedBookVolumes = 0; |
|
907 |
private void extraktBookVolume(Reference book) { |
|
908 |
if (isExtractBookVolumeCandidate(book)){ |
|
909 |
String patternStr = "(.{2,})\\s(\\d{1,2})"; |
|
910 |
int groupIndex = 2; |
|
911 |
Pattern pattern = Pattern.compile(patternStr); |
|
912 |
|
|
913 |
String abbrevCache = book.getAbbrevTitleCache(); |
|
914 |
String titleCache = book.getTitleCache(); |
|
915 |
String vol = null; |
|
916 |
String volFull = null; |
|
917 |
String abbrev = book.getAbbrevTitle(); |
|
918 |
if (isNotBlank(abbrev)){ |
|
919 |
Matcher matcher = pattern.matcher(abbrev); |
|
920 |
if (matcher.matches()){ |
|
921 |
vol = matcher.group(groupIndex); |
|
922 |
abbrev = matcher.group(1); |
|
923 |
} |
|
924 |
} |
|
925 |
|
|
926 |
String full = book.getTitle(); |
|
927 |
if (isNotBlank(full)){ |
|
928 |
Matcher matcher = pattern.matcher(full); |
|
929 |
if (matcher.matches()){ |
|
930 |
volFull = matcher.group(groupIndex); |
|
931 |
full = matcher.group(1); |
|
932 |
} |
|
933 |
} |
|
934 |
if (vol != null && volFull != null){ |
|
935 |
if (!vol.equals(volFull)){ |
|
936 |
return; |
|
937 |
} |
|
938 |
}else if (vol == null && volFull == null){ |
|
939 |
return; |
|
940 |
}else if (vol == null){ |
|
941 |
if (isNotBlank(abbrev)){ |
|
942 |
return; |
|
943 |
}else{ |
|
944 |
vol = volFull; |
|
945 |
} |
|
946 |
}else if (volFull == null){ |
|
947 |
if (isNotBlank(full)){ |
|
948 |
return; |
|
949 |
} |
|
950 |
}else{ |
|
951 |
logger.warn("Should not happen"); |
|
952 |
} |
|
953 |
book.setVolume(vol); |
|
954 |
book.setAbbrevTitle(abbrev); |
|
955 |
book.setTitle(full); |
|
956 |
if (!book.getAbbrevTitleCache().equals(abbrevCache)){ |
|
957 |
logger.warn("Abbrev title cache for parsed book volume does not match: " + book.getAbbrevTitleCache() + " <-> "+abbrevCache); |
|
958 |
}else if (!book.getTitleCache().equals(titleCache)){ |
|
959 |
logger.warn("Title cache for parsed book volume does not match: " + book.getTitleCache() + " <-> "+titleCache); |
|
960 |
}else{ |
|
961 |
// System.out.println(titleCache); |
|
962 |
// System.out.println(abbrevCache); |
|
963 |
parsedBookVolumes++; |
|
964 |
} |
|
965 |
}else{ |
|
966 |
return; |
|
967 |
} |
|
968 |
} |
|
969 |
|
|
970 |
/** |
|
971 |
* @param book |
|
972 |
* @return |
|
973 |
*/ |
|
974 |
private boolean isExtractBookVolumeCandidate(Reference book) { |
|
975 |
if (isNotBlank(book.getVolume()) || isNotBlank(book.getEdition()) || isNotBlank(book.getSeriesPart())){ |
|
976 |
return false; |
|
977 |
} |
|
978 |
if (!checkExtractBookVolumeTitle(book.getAbbrevTitle())){ |
|
979 |
return false; |
|
980 |
} |
|
981 |
if (!checkExtractBookVolumeTitle(book.getTitle())){ |
|
982 |
return false; |
|
983 |
} |
|
984 |
return true; |
|
985 |
} |
|
986 |
|
|
987 |
/** |
|
988 |
* @param abbrevTitle |
|
989 |
* @return |
|
990 |
*/ |
|
991 |
private boolean checkExtractBookVolumeTitle(String title) { |
|
992 |
if (title == null){ |
|
993 |
return true; |
|
994 |
} |
|
995 |
if (title.contains(",") || title.contains("ed.") || title.contains("Ed.")|| title.contains("Suppl") |
|
996 |
|| title.contains("Ser.")|| title.contains("ser.")) { |
|
997 |
return false; |
|
998 |
} |
|
999 |
return true; |
|
1000 |
} |
|
1001 |
|
|
1002 |
/** |
|
899 | 1003 |
* Returns the requested object if it exists in one of both maps. Prefers the refToSaveMap in ambigious cases. |
900 | 1004 |
* @param inRefFkInt |
901 | 1005 |
* @param nomRefToSave |
Also available in: Unified diff
improve reference import for E+M (edition and volume handling)