sort states in aggregated descriptions on count
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / dto / IdentifiedEntityDTO.java
1 /**
2 * Copyright (C) 2014 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.api.service.dto;
10
11 import java.io.Serializable;
12 import java.util.UUID;
13
14 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
15 import eu.etaxonomy.cdm.model.term.DefinedTerm;
16
17 /**
18 * @author a.mueller
19 * @since 2015-01-19
20 *
21 */
22 public class IdentifiedEntityDTO<T extends IdentifiableEntity> extends EntityDTOBase<T> implements Serializable{
23
24 private static final long serialVersionUID = -6993723067086766695L;
25
26
27 public class AlternativeIdentifier implements Serializable{
28
29 private static final long serialVersionUID = -6342783530172264106L;
30
31 UUID typeUuid;
32 String typeLabel;
33 String identifier;
34 public AlternativeIdentifier(DefinedTerm identifierType, String identifier) {
35
36 if (identifierType != null){
37 this.typeUuid = identifierType.getUuid();
38 this.typeLabel = identifierType.getTitleCache();
39 }
40
41 this.identifier = identifier;
42 }
43 public UUID getTypeUuid() {return typeUuid;}
44 public String getTypeLabel() {return typeLabel;}
45 public String getIdentifier() {return identifier;}
46 }
47
48 private AlternativeIdentifier identifier;
49
50
51 public IdentifiedEntityDTO(DefinedTerm identifierType, String identifier, T entity){
52 super(entity);
53 this.identifier = new AlternativeIdentifier(identifierType, identifier);
54 }
55
56 public IdentifiedEntityDTO(DefinedTerm identifierType, String identifier,
57 UUID entityUuid, String titleCache, String abbrevTitleCache){
58 super(entityUuid, titleCache, abbrevTitleCache);
59 if (identifier != null){
60 this.identifier = new AlternativeIdentifier(identifierType, identifier);
61 }
62
63 }
64
65 public AlternativeIdentifier getIdentifier() {
66 return identifier;
67 }
68
69
70 /**
71 * {@inheritDoc}
72 */
73 @Override
74 public String toString() {
75 return "(" + identifier.typeLabel + "; " + cdmEntity.getTitleCache() + "; " + cdmEntity.getUuid() + ")";
76 }
77 }