Project

General

Profile

Download (1.83 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
 * @since 29.04.2011
23
 */
24
public class CsvDemoId {
25
	@SuppressWarnings("unused")
26
	private static final Logger logger = Logger.getLogger(CsvDemoId.class);
27

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

    
34
	private CsvDemoExportConfigurator config;
35

    
36
	public CsvDemoId(CsvDemoExportConfigurator config){
37
		this.config = config;
38
	}
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

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

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

    
78
	private String nullSafe(Object o){
79
		return o == null ? null : o.toString();
80
	}
81

    
82

    
83
}
(6-6/10)