Project

General

Profile

Download (1.85 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.demo;
10

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

    
14
import org.apache.log4j.Logger;
15

    
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
 * @date 29.04.2011
23
 *
24
 */
25
public class CsvDemoId {
26
	@SuppressWarnings("unused")
27
	private static final Logger logger = Logger.getLogger(CsvDemoId.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 CsvDemoExportConfigurator config;
36
	
37
	public CsvDemoId(CsvDemoExportConfigurator config){
38
		this.config = config;
39
	}
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
}
(6-6/10)