Project

General

Profile

Download (1.84 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 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
package eu.etaxonomy.cdm.io.csv.redlist.out;
10

    
11
import java.util.UUID;
12

    
13
import org.apache.log4j.Logger;
14

    
15
import eu.etaxonomy.cdm.common.URI;
16
import eu.etaxonomy.cdm.model.common.CdmBase;
17
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
18
import eu.etaxonomy.cdm.model.common.LSID;
19

    
20
/**
21
 * @author a.mueller
22
 * @since 29.04.2011
23
 */
24
public class CsvId {
25

    
26
	@SuppressWarnings("unused")
27
	private static final Logger logger = Logger.getLogger(CsvId.class);
28

    
29
	private Integer intId;
30
	private String strId;
31
	private UUID uuidId;
32
	private URI uriId;
33
	private LSID lsidId;
34

    
35
	private CsvTaxExportConfiguratorRedlist config;
36

    
37
	public CsvId(CsvTaxExportConfiguratorRedlist config){
38
		this.config = config;
39
	}
40

    
41
	public void setId(Integer id){
42
		this.intId = id;
43
	}
44
	public void setId(UUID uuid){
45
		this.uuidId = uuid;
46
	}
47
	public void setId(LSID lsid){
48
		this.lsidId = lsid;
49
	}
50

    
51
	public void setId(CdmBase cdmBase) {
52
		this.setId(cdmBase.getId());
53
		this.setId(cdmBase.getUuid());
54
		if (cdmBase.isInstanceOf(IdentifiableEntity.class)){
55
			this.setId(CdmBase.deproxy(cdmBase,IdentifiableEntity.class).getLsid());
56
		}
57
	}
58

    
59
	public String getId(){
60
		Object object;
61
		if (config.isUseIdWherePossible()){
62
			object = intId;
63
		}else if (lsidId != null){
64
			object = lsidId;
65
		}else if (uriId != null){
66
			object = uriId;
67
		}else if(uuidId != null){
68
			object = uuidId;
69
		}else if(intId != null){
70
			object = intId;
71
		}else{
72
			object = strId;
73
		}
74
		return nullSafe(object);
75
	}
76

    
77
	private String nullSafe(Object o){
78
		return o == null ? null : o.toString();
79
	}
80
}
(2-2/10)