Project

General

Profile

Download (1.85 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2009 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.io.csv.redlist.out;
11

    
12
import java.net.URI;
13
import java.util.UUID;
14

    
15
import org.apache.log4j.Logger;
16

    
17
import eu.etaxonomy.cdm.model.common.CdmBase;
18
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
19
import eu.etaxonomy.cdm.model.common.LSID;
20

    
21
/**
22
 * @author a.mueller
23
 * @date 29.04.2011
24
 *
25
 */
26
public class CsvId {
27
	@SuppressWarnings("unused")
28
	private static final Logger logger = Logger.getLogger(CsvId.class);
29

    
30
	private Integer intId;
31
	private String strId;
32
	private UUID uuidId;
33
	private URI uriId;
34
	private LSID lsidId;
35
	
36
	private CsvTaxExportConfiguratorRedlist config;
37
	
38
	public CsvId(CsvTaxExportConfiguratorRedlist config){
39
		this.config = config;
40
	}
41
	
42
	public void setId(Integer id){
43
		this.intId = id;
44
	}
45
	public void setId(UUID uuid){
46
		this.uuidId = uuid;
47
	}
48
	public void setId(LSID lsid){
49
		this.lsidId = lsid;
50
	}
51
	
52

    
53
	public void setId(CdmBase cdmBase) {
54
		this.setId(cdmBase.getId());
55
		this.setId(cdmBase.getUuid());
56
		if (cdmBase.isInstanceOf(IdentifiableEntity.class)){
57
			this.setId(CdmBase.deproxy(cdmBase,IdentifiableEntity.class).getLsid());
58
		}
59
	}
60
	
61
	public String getId(){
62
		Object object;
63
		if (config.isUseIdWherePossible()){
64
			object = intId;
65
		}else if (lsidId != null){
66
			object = lsidId;
67
		}else if (uriId != null){
68
			object = uriId;
69
		}else if(uuidId != null){
70
			object = uuidId;
71
		}else if(intId != null){
72
			object = intId;
73
		}else{
74
			object = strId;
75
		}
76
		return nullSafe(object);
77
	}
78
	
79
	private String nullSafe(Object o){
80
		return o == null ? null : o.toString();
81
	}
82

    
83
	
84
}
(2-2/10)