2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.io
.mexico
;
11 import org
.apache
.log4j
.Logger
;
12 import org
.springframework
.stereotype
.Component
;
14 import eu
.etaxonomy
.cdm
.common
.DOI
;
15 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
16 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
17 import eu
.etaxonomy
.cdm
.model
.common
.VerbatimTimePeriod
;
18 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
19 import eu
.etaxonomy
.cdm
.strategy
.parser
.TimePeriodParser
;
26 public abstract class MexicoEfloraReferenceImportBase
extends MexicoEfloraImportBase
{
28 public static final String NAMESPACE
= "References";
30 private static final long serialVersionUID
= -5161951752826380728L;
31 private static final Logger logger
= Logger
.getLogger(MexicoEfloraReferenceImportBase
.class);
33 public MexicoEfloraReferenceImportBase(String dbTableName
, String pluralString
){
34 super(dbTableName
, pluralString
);
38 protected String
getIdQuery(MexicoEfloraImportState state
) {
39 String sql
= " SELECT 'CONABIO-BIB-ID' "
40 + " FROM " + getTableName()
41 + " ORDER BY 'CONABIO-BIB-ID' ";
46 protected String
getRecordQuery(MexicoEfloraImportConfigurator config
) {
47 String sqlSelect
= " SELECT * ";
48 String sqlFrom
= " FROM " + getTableName();
49 String sqlWhere
= " WHERE ( 'CONABIO-BIB-ID' IN (" + ID_LIST_TOKEN
+ ") )";
51 String strRecordQuery
=sqlSelect
+ " " + sqlFrom
+ " " + sqlWhere
;
52 return strRecordQuery
;
56 protected boolean doCheck(MexicoEfloraImportState state
){
60 protected void handleAuthorStr(MexicoEfloraImportState state
, String authorStr
, Reference ref
, int refId
) {
63 if (isNotBlank(authorStr
)) {
64 TeamOrPersonBase
<?
> author
= Team
.NewInstance();
66 author
.setTitleCache(authorStr
, true);
67 //TODO is parsed really ok?
68 state
.getDeduplicationHelper().getExistingAgent(author
, true);
69 ref
.setAuthorship(author
);
71 logger
.warn(refId
+ ": No author");
75 protected void handleYearStr(MexicoEfloraImportState state
, String yearStr
, Reference ref
, int refId
) {
77 if (isNotBlank(yearStr
)) {
78 VerbatimTimePeriod tp
= TimePeriodParser
.parseStringVerbatim(yearStr
);
79 ref
.setDatePublished(tp
);
81 logger
.warn(refId
+ ": No year");
85 protected void handleTitleStr(MexicoEfloraImportState state
, String titleStr
, Reference ref
, int refId
) {
88 if (isNotBlank(titleStr
)) {
89 ref
.setTitle(titleStr
);
91 logger
.warn(refId
+ ": No title");
95 protected void handleUrlStr(MexicoEfloraImportState state
, String urlStr
, Reference ref
, int refId
) {
98 if (isNotBlank(urlStr
)) {
101 // IJournal journal = ReferenceFactory.newJournal();
102 // journal.setTitle(journalTitleStr);
103 // ref.setInJournal(journal);
105 // logger.warn(refId + ": No url");
109 protected void handleDoiStr(MexicoEfloraImportState state
, String doiStr
, Reference ref
, int refId
) {
112 if (isNotBlank(doiStr
)) {
115 doi
= DOI
.fromString(doiStr
);
117 } catch (Exception e
) {
118 logger
.warn(refId
+ ": Doi could not be parsed: " + doiStr
);
123 protected void handleId(MexicoEfloraImportState state
, int refId
, Reference ref
, String detail
) {
124 state
.getReferenceUuidMap().put(refId
, ref
.getUuid());
125 state
.getRefDetailMap().put(refId
, detail
);
127 ref
.addImportSource(String
.valueOf(refId
), MexicoEfloraReferenceImportBase
.NAMESPACE
,
132 protected boolean isIgnore(MexicoEfloraImportState state
){
133 return ! state
.getConfig().isDoReferences();