Project

General

Profile

Download (1.74 KB) Statistics
| Branch: | Tag: | Revision:
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;
13
import org.apache.logging.log4j.Logger;
14

    
15
import eu.etaxonomy.cdm.common.DOI;
16
import eu.etaxonomy.cdm.io.common.DbImportStateBase;
17
import eu.etaxonomy.cdm.model.common.CdmBase;
18

    
19
/**
20
 * @author a.mueller
21
 * @since 03.09.2019
22
 */
23
public class DbImportDoiMapper extends DbSingleAttributeImportMapperBase<DbImportStateBase<?,?>, CdmBase>{
24

    
25
	@SuppressWarnings("unused")
26
	private static final Logger logger = LogManager.getLogger();
27

    
28
	public static DbImportDoiMapper NewInstance (String dbAttributeString, String cdmAttributeString) {
29
		boolean obligatory = false;
30
		Object defaultValue = null;
31
		return new DbImportDoiMapper(dbAttributeString, cdmAttributeString, defaultValue, obligatory);
32
	}
33

    
34
	public static DbImportDoiMapper NewInstance (String dbAttributeString, String cdmAttributeString, Object defaultValue, boolean obligatory) {
35
		return new  DbImportDoiMapper(dbAttributeString, cdmAttributeString, defaultValue, obligatory);
36
	}
37

    
38
	protected DbImportDoiMapper(String dbAttributeString, String cdmAttributeString, Object defaultValue, boolean obligatory) {
39
		super(dbAttributeString, cdmAttributeString, defaultValue, obligatory);
40
	}
41

    
42
	@Override
43
	protected CdmBase doInvoke(CdmBase cdmBase, Object value) {
44
		if (value != null && ! (value instanceof DOI) ){
45
		    value = DOI.fromString(String.valueOf(value));
46
		}
47
		return super.doInvoke(cdmBase, value);
48
	}
49

    
50
	@Override
51
	public Class getTypeClass() {
52
		return DOI.class;
53
	}
54
}
(13-13/53)