Project

General

Profile

Download (2.16 KB) Statistics
| Branch: | Tag: | Revision:
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.IdentifiableEntity;
15
import eu.etaxonomy.cdm.model.common.MarkerType;
16
import eu.etaxonomy.cdm.model.taxon.Taxon;
17

    
18
/**
19
 * DTO for IdentifiableEntities matching a certain marker.
20
 *
21
 * @author a.mueller
22
 * @date 2016-09-16
23
 *
24
 */
25
public class FindByMarkerDTO<T extends IdentifiableEntity> {
26

    
27
	public class Marker{
28
		UUID typeUuid;
29
		String typeLabel;
30
		Boolean flag;
31
		public Marker(MarkerType markerType, Boolean flag) {
32
			this.typeUuid = markerType.getUuid();
33
			this.typeLabel = markerType.getTitleCache();
34
			this.flag = flag;
35
		}
36
		public UUID getTypeUuid() {return typeUuid;}
37
		public String getTypeLabel() {return typeLabel;}
38
		public Boolean getFlag() {return flag;}
39
	}
40

    
41
	public class CdmEntity{
42
		UUID cdmUuid;
43
		String titleCache;
44
		T entity;
45
		public CdmEntity(UUID cdmUuid, String titleCache, T entity) {
46
			this.cdmUuid = cdmUuid;
47
			this.titleCache = titleCache;
48
			this.entity = (T)new Taxon();
49

    
50
		}
51
		public UUID getCdmUuid() {return cdmUuid;}
52
		public String getTitleCache() {return titleCache;}
53
		public T getEntity() {return entity;}
54

    
55
	}
56

    
57
	private Marker marker;
58

    
59
	private CdmEntity cdmEntity;
60

    
61
	public FindByMarkerDTO(MarkerType markerType, Boolean flag, T entity){
62
		this.marker = new Marker(markerType, flag);
63
		this.cdmEntity = new CdmEntity(entity.getUuid(), entity.getTitleCache(), entity);
64
	}
65

    
66
	public FindByMarkerDTO(MarkerType markerType, Boolean flag, UUID entityUuid, String titleCache){
67
		this.marker = new Marker(markerType, flag);
68
		this.cdmEntity = new CdmEntity(entityUuid, titleCache, null);
69
	}
70

    
71
	public Marker getMarker() {
72
		return marker;
73
	}
74

    
75
	public CdmEntity getCdmEntity() {
76
		return cdmEntity;
77
	}
78

    
79
    /**
80
     * {@inheritDoc}
81
     */
82
    @Override
83
    public String toString() {
84
        return "(" + marker.typeLabel + "; "  + cdmEntity.getTitleCache() + "; " + cdmEntity.cdmUuid +  ")";
85
    }
86

    
87

    
88
}
(8-8/11)