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.dwca.out;
|
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.ICdmBase;
|
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 DwcaId {
|
27
|
@SuppressWarnings("unused")
|
28
|
private static final Logger logger = Logger.getLogger(DwcaId.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 DwcaTaxExportConfigurator config;
|
37
|
|
38
|
public DwcaId(DwcaTaxExportConfigurator 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(ICdmBase 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
|
}
|