Revision e6f1aeb9
Added by Andreas Kohlbecker over 2 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/MediaDTO.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
private Integer size; |
37 | 37 |
|
38 |
private List<SourceDTO> sources = new ArrayList<>(); |
|
39 |
|
|
38 | 40 |
/** |
39 | 41 |
* Creates a list of DTOs from the Media entity. |
40 | 42 |
* For each MediaRepresentationPart a single MediaDTO is being created. |
... | ... | |
44 | 46 |
public static List<MediaDTO> fromEntity(Media entity) { |
45 | 47 |
List<MediaDTO> dtos = new ArrayList<>(); |
46 | 48 |
entity.getAllTitles(); // initialize all titles!!! |
49 |
MediaDTO dto = new MediaDTO(entity.getUuid()); |
|
47 | 50 |
for (MediaRepresentation rep :entity.getRepresentations()){ |
48 | 51 |
for(MediaRepresentationPart p : rep.getParts()){ |
49 | 52 |
if(p.getUri() != null){ |
50 |
MediaDTO dto = new MediaDTO(entity.getUuid()); |
|
51 | 53 |
dto.setUri(p.getUri().toString()); |
52 |
dtos.add(dto);
|
|
54 |
break;
|
|
53 | 55 |
} |
54 | 56 |
} |
55 | 57 |
} |
58 |
entity.getSources().stream().forEach(s -> dto.getSources().add(SourceDTO.fromIdentifiableSource(s))); |
|
59 |
if(dto.getUri() != null || !dto.getSources().isEmpty()) { |
|
60 |
dtos.add(dto); |
|
61 |
} |
|
56 | 62 |
return dtos; |
57 | 63 |
} |
58 | 64 |
|
... | ... | |
92 | 98 |
this.size = size; |
93 | 99 |
} |
94 | 100 |
|
101 |
public List<SourceDTO> getSources() { |
|
102 |
return sources; |
|
103 |
} |
|
104 |
|
|
105 |
|
|
95 | 106 |
} |
Also available in: Unified diff
ref #9388 adding sources to MediaDTO