Revision bbeda5af
Added by Katja Luther about 7 years ago
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaAuthorImport.java | ||
---|---|---|
13 | 13 |
import java.util.Collection; |
14 | 14 |
import java.util.Map; |
15 | 15 |
|
16 |
import org.apache.commons.lang.StringUtils; |
|
16 | 17 |
import org.apache.log4j.Logger; |
17 | 18 |
import org.springframework.stereotype.Component; |
18 | 19 |
import org.springframework.transaction.TransactionStatus; |
... | ... | |
25 | 26 |
import eu.etaxonomy.cdm.model.agent.Team; |
26 | 27 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
27 | 28 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
29 |
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl; |
|
28 | 30 |
|
29 | 31 |
|
30 | 32 |
/** |
... | ... | |
34 | 36 |
*/ |
35 | 37 |
@Component |
36 | 38 |
public class FaunaEuropaeaAuthorImport extends FaunaEuropaeaImportBase { |
37 |
private static final Logger logger = Logger.getLogger(FaunaEuropaeaAuthorImport.class); |
|
39 |
|
|
40 |
/** |
|
41 |
* |
|
42 |
*/ |
|
43 |
private static final long serialVersionUID = 1L; |
|
44 |
|
|
45 |
private static final Logger logger = Logger.getLogger(FaunaEuropaeaAuthorImport.class); |
|
38 | 46 |
|
39 | 47 |
private static int modCount = 1000; |
40 | 48 |
private final static String authorSeparator = ", "; |
... | ... | |
118 | 126 |
TeamOrPersonBase<?> author = null; |
119 | 127 |
|
120 | 128 |
try { |
121 |
author = parseAuthorString(authorName); |
|
122 |
ImportHelper.setOriginalSource(author, fauEuConfig.getSourceReference(), authorId, namespace); |
|
123 |
|
|
124 |
if (!authorStore.containsId(authorId)) { |
|
125 |
authorStore.put(authorId, author); |
|
126 |
if (logger.isDebugEnabled()) { logger.debug("Stored author (" + authorId + ") " + authorName); } |
|
127 |
} else { |
|
128 |
logger.warn("Not imported author with duplicated aut_id (" + authorId + ") " + authorName); |
|
129 |
} |
|
129 |
NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance(); |
|
130 |
|
|
131 |
if (StringUtils.isNotBlank(authorName)){ |
|
132 |
//author = parser.author(authorName); |
|
133 |
author = this.parseNomAuthorString(authorName); |
|
134 |
ImportHelper.setOriginalSource(author, fauEuConfig.getSourceReference(), authorId, namespace); |
|
135 |
|
|
136 |
if (!authorStore.containsId(authorId)) { |
|
137 |
authorStore.put(authorId, author); |
|
138 |
if (logger.isDebugEnabled()) { logger.debug("Stored author (" + authorId + ") " + authorName); } |
|
139 |
} else { |
|
140 |
logger.warn("Not imported author with duplicated aut_id (" + authorId + ") " + authorName); |
|
141 |
} |
|
142 |
} |
|
130 | 143 |
} catch (Exception e) { |
131 |
logger.warn("An exception occurred when creating author with id " + authorId + ". Author could not be saved."); |
|
144 |
logger.warn("An exception occurred when creating author with id " + authorId + ". Author could not be saved." + e.getMessage());
|
|
132 | 145 |
} |
133 | 146 |
} |
134 | 147 |
|
... | ... | |
159 | 172 |
return ! state.getConfig().isDoAuthors(); |
160 | 173 |
} |
161 | 174 |
|
162 |
public static TeamOrPersonBase<?> parseAuthorString(String authorName){ |
|
175 |
public static TeamOrPersonBase<?> parseAuthorStringOld(String authorName){
|
|
163 | 176 |
TeamOrPersonBase<?> author = null; |
164 | 177 |
String[] teamMembers = authorName.split(authorSeparator); |
165 | 178 |
String lastMember; |
... | ... | |
213 | 226 |
//possible strings: Lastname, A., Lastname B. & Lastname C. |
214 | 227 |
//Lastname A, Lastname B & Lastname |
215 | 228 |
//Lastname A Lastname B & Lastname C |
229 |
//Lastname, J & Lastname, L |
|
216 | 230 |
String[] teamMembers = refAuthor.split(test); |
217 | 231 |
|
218 | 232 |
String lastMember; |
Also available in: Unified diff
changes in pesi im and exports