1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2014 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.api.service.dto;
|
11
|
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import eu.etaxonomy.cdm.model.common.DefinedTerm;
|
15
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
16
|
|
17
|
/**
|
18
|
* @author a.mueller
|
19
|
* @date 2015-01-19
|
20
|
*
|
21
|
*/
|
22
|
public class IdentifiedEntityDTO<T extends IdentifiableEntity> extends EntityDTOBase<T> {
|
23
|
|
24
|
public class AlternativeIdentifier{
|
25
|
UUID typeUuid;
|
26
|
String typeLabel;
|
27
|
String identifier;
|
28
|
public AlternativeIdentifier(DefinedTerm identifierType, String identifier) {
|
29
|
this.typeUuid = identifierType.getUuid();
|
30
|
this.typeLabel = identifierType.getTitleCache();
|
31
|
this.identifier = identifier;
|
32
|
}
|
33
|
public UUID getTypeUuid() {return typeUuid;}
|
34
|
public String getTypeLabel() {return typeLabel;}
|
35
|
public String getIdentifier() {return identifier;}
|
36
|
}
|
37
|
|
38
|
private AlternativeIdentifier identifier;
|
39
|
|
40
|
|
41
|
public IdentifiedEntityDTO(DefinedTerm identifierType, String identifier, T entity){
|
42
|
this.identifier = new AlternativeIdentifier(identifierType, identifier);
|
43
|
this.cdmEntity = new CdmEntity(entity.getUuid(), entity.getTitleCache(), entity);
|
44
|
}
|
45
|
|
46
|
public IdentifiedEntityDTO(DefinedTerm identifierType, String identifier, UUID entityUuid, String titleCache){
|
47
|
this.identifier = new AlternativeIdentifier(identifierType, identifier);
|
48
|
this.cdmEntity = new CdmEntity(entityUuid, null, null);
|
49
|
}
|
50
|
|
51
|
public AlternativeIdentifier getIdentifier() {
|
52
|
return identifier;
|
53
|
}
|
54
|
|
55
|
|
56
|
/**
|
57
|
* {@inheritDoc}
|
58
|
*/
|
59
|
@Override
|
60
|
public String toString() {
|
61
|
return "(" + identifier.typeLabel + "; " + cdmEntity.getTitleCache() + "; " + cdmEntity.cdmUuid + ")";
|
62
|
}
|
63
|
}
|