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
		}
50
		public UUID getCdmUuid() {return cdmUuid;}
51
		public String getTitleCache() {return titleCache;}
52
		public T getEntity() {return entity;}
53

    
54
	}
55

    
56
	private Marker marker;
57

    
58
	private CdmEntity cdmEntity;
59

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

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

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

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

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

    
86

    
87
}
(8-8/11)