Project

General

Profile

Download (2.11 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

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

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

    
40
	public class CdmEntity{
41
		UUID cdmUuid;
42
		String titleCache;
43
		T entity;
44
		public CdmEntity(UUID cdmUuid, String titleCache, T entity) {
45
			this.cdmUuid = cdmUuid;
46
			this.titleCache = titleCache;
47
			this.entity = entity;
48
		}
49
		public UUID getCdmUuid() {return cdmUuid;}
50
		public String getTitleCache() {return titleCache;}
51
		public T getEntity() {return entity;}
52

    
53
	}
54

    
55
	private Marker marker;
56

    
57
	private CdmEntity cdmEntity;
58

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

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

    
69
	public Marker getMarker() {
70
		return marker;
71
	}
72

    
73
	public CdmEntity getCdmEntity() {
74
		return cdmEntity;
75
	}
76

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

    
85

    
86
}
(8-8/11)