1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.io.common.mapping;
|
11
|
|
12
|
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
|
13
|
|
14
|
import eu.etaxonomy.cdm.common.DOI;
|
15
|
import eu.etaxonomy.cdm.io.common.DbImportStateBase;
|
16
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
17
|
|
18
|
/**
|
19
|
* @author a.mueller
|
20
|
* @since 03.09.2019
|
21
|
*/
|
22
|
public class DbImportDoiMapper extends DbSingleAttributeImportMapperBase<DbImportStateBase<?,?>, CdmBase>{
|
23
|
|
24
|
@SuppressWarnings("unused")
|
25
|
private static final Logger logger = LogManager.getLogger(DbImportDoiMapper.class);
|
26
|
|
27
|
public static DbImportDoiMapper NewInstance (String dbAttributeString, String cdmAttributeString) {
|
28
|
boolean obligatory = false;
|
29
|
Object defaultValue = null;
|
30
|
return new DbImportDoiMapper(dbAttributeString, cdmAttributeString, defaultValue, obligatory);
|
31
|
}
|
32
|
|
33
|
public static DbImportDoiMapper NewInstance (String dbAttributeString, String cdmAttributeString, Object defaultValue, boolean obligatory) {
|
34
|
return new DbImportDoiMapper(dbAttributeString, cdmAttributeString, defaultValue, obligatory);
|
35
|
}
|
36
|
|
37
|
protected DbImportDoiMapper(String dbAttributeString, String cdmAttributeString, Object defaultValue, boolean obligatory) {
|
38
|
super(dbAttributeString, cdmAttributeString, defaultValue, obligatory);
|
39
|
}
|
40
|
|
41
|
@Override
|
42
|
protected CdmBase doInvoke(CdmBase cdmBase, Object value) {
|
43
|
if (value != null && ! (value instanceof DOI) ){
|
44
|
value = DOI.fromString(String.valueOf(value));
|
45
|
}
|
46
|
return super.doInvoke(cdmBase, value);
|
47
|
}
|
48
|
|
49
|
@Override
|
50
|
public Class getTypeClass() {
|
51
|
return DOI.class;
|
52
|
}
|
53
|
}
|