Revision d457f5b7
Added by Andreas Müller over 2 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/reference/ris/in/RisReferenceImport.java | ||
---|---|---|
31 | 31 |
import eu.etaxonomy.cdm.model.common.Annotation; |
32 | 32 |
import eu.etaxonomy.cdm.model.common.AnnotationType; |
33 | 33 |
import eu.etaxonomy.cdm.model.common.Language; |
34 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
|
35 | 34 |
import eu.etaxonomy.cdm.model.common.VerbatimTimePeriod; |
36 | 35 |
import eu.etaxonomy.cdm.model.reference.Reference; |
37 | 36 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
38 | 37 |
import eu.etaxonomy.cdm.model.reference.ReferenceType; |
38 |
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser; |
|
39 | 39 |
|
40 | 40 |
/** |
41 | 41 |
* @author a.mueller |
... | ... | |
157 | 157 |
RisValue da = getSingleValue(state, record, RisReferenceTag.DA); |
158 | 158 |
Integer year = makeYear(state, py); |
159 | 159 |
VerbatimTimePeriod date = makeDate(state, da); |
160 |
assertDateYear(state, year, date, py); |
|
160 |
date = assertDateYear(state, year, date, py);
|
|
161 | 161 |
ref.setDatePublished(date); |
162 | 162 |
//TODO y1 not yet handled |
163 | 163 |
|
... | ... | |
217 | 217 |
higherRef.setPublisher(pb.value); |
218 | 218 |
} |
219 | 219 |
|
220 |
//CY - Place published |
|
221 |
RisValue cy = getSingleValue(state, record, RisReferenceTag.CY); |
|
222 |
if (cy != null){ |
|
223 |
higherRef.setPlacePublished(cy.value); |
|
224 |
} |
|
225 |
|
|
220 | 226 |
//Abstract |
221 | 227 |
RisValue ab = getSingleValue(state, record, RisReferenceTag.AB); |
222 | 228 |
RisValue n2 = getSingleValue(state, record, RisReferenceTag.N2); |
... | ... | |
241 | 247 |
String recLoc = recordLocation(state, record); |
242 | 248 |
ref.addImportSource(idStr, null, state.getConfig().getSourceReference(), recLoc); |
243 | 249 |
if (inRef != null){ |
244 |
ref.addImportSource(idStr, null, state.getConfig().getSourceReference(), recLoc); |
|
245 |
|
|
250 |
inRef.addImportSource(idStr, null, state.getConfig().getSourceReference(), recLoc); |
|
246 | 251 |
} |
247 | 252 |
|
248 | 253 |
//remove |
... | ... | |
277 | 282 |
return result; |
278 | 283 |
} |
279 | 284 |
|
280 |
private void assertDateYear(RisReferenceImportState state, Integer year, TimePeriod date, RisValue py) { |
|
281 |
if (year != null && date != null && !year.equals(date.getStartYear())){ |
|
282 |
String message = "Year 'PY' and date 'DA' are not consistent. PY is neglected."; |
|
283 |
state.getResult().addWarning(message, null, py.location); |
|
285 |
private VerbatimTimePeriod assertDateYear(RisReferenceImportState state, Integer year, VerbatimTimePeriod date, RisValue py) { |
|
286 |
if (year == null && date == null){ |
|
287 |
return null; |
|
288 |
}else if (year == null){ |
|
289 |
return date; |
|
290 |
}else if (date == null){ |
|
291 |
return TimePeriodParser.parseStringVerbatim(String.valueOf(year)); |
|
292 |
}else{ |
|
293 |
if (!year.equals(date.getStartYear())){ |
|
294 |
if (date.getStartYear() == null){ |
|
295 |
date.setStartYear(year); |
|
296 |
}else if (isNotBlank(date.getFreeText())){ |
|
297 |
date.setStartYear(year); //does this happen at all? |
|
298 |
String message = "Year 'PY' and date 'DA' are not consistent. PY is neglected."; |
|
299 |
state.getResult().addWarning(message, null, py.location); |
|
300 |
return date; |
|
301 |
}else{ |
|
302 |
String message = "Year 'PY' and date 'DA' are not consistent. DA is used for freetext and PY is used for (start) year."; |
|
303 |
state.getResult().addWarning(message, null, py.location); |
|
304 |
return date; |
|
305 |
} |
|
306 |
} |
|
307 |
return date; |
|
284 | 308 |
} |
285 | 309 |
} |
286 | 310 |
|
Also available in: Unified diff
fix #9786 implement CY and fix PY for RIS import (and fix Source handling for in-references)