Project

General

Profile

Download (2.44 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 java.util.UUID;
13

    
14
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
15

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

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

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

    
28
	/**
29
	 * @param dbAttributString
30
	 * @param cdmAttributeString
31
	 * @return
32
	 */
33
	public static DbImportUuidMapper NewInstance (String dbAttributeString, String cdmAttributeString) {
34
		boolean obligatory = false;
35
		Object defaultValue = null;
36
		return DbImportUuidMapper.NewInstance(dbAttributeString, cdmAttributeString, defaultValue, obligatory);
37
	}
38

    
39

    
40
	/**
41
	 * @param cdmAttributeString
42
	 * @param dbAttributString
43
	 * @param defaultValue
44
	 */
45
	public static DbImportUuidMapper NewInstance (String dbAttributString, String cdmAttributeString, Object defaultValue) {
46
		boolean obligatory = false;
47
		return new  DbImportUuidMapper(dbAttributString, cdmAttributeString, defaultValue, obligatory);
48
	}
49

    
50
	/**
51
	 * @param cdmAttributeString
52
	 * @param dbAttributString
53
	 * @param defaultValue
54
	 */
55
	public static DbImportUuidMapper NewInstance (String dbAttributeString, String cdmAttributeString, Object defaultValue, boolean obligatory) {
56
		return new  DbImportUuidMapper(dbAttributeString, cdmAttributeString, defaultValue, obligatory);
57
	}
58

    
59

    
60
	/**
61
	 * @param cdmAttributeString
62
	 * @param dbAttributString
63
	 * @param defaultValue
64
	 */
65
	protected DbImportUuidMapper(String dbAttributeString, String cdmAttributeString, Object defaultValue, boolean obligatory) {
66
		super(dbAttributeString, cdmAttributeString, defaultValue, obligatory);
67
	}
68

    
69
	@Override
70
	protected CdmBase doInvoke(CdmBase cdmBase, Object value){
71
		if (value != null && ! (value instanceof UUID) ){
72
			value = UUID.fromString(String.valueOf(value));
73
		}
74
		return super.doInvoke(cdmBase, value);
75
	}
76

    
77
	@Override
78
	public Class getTypeClass() {
79
		return UUID.class;
80
	}
81
}
(40-40/53)