2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.api
.service
.dto
;
11 import java
.util
.ArrayList
;
12 import java
.util
.List
;
13 import java
.util
.UUID
;
15 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
16 import eu
.etaxonomy
.cdm
.model
.media
.MediaRepresentation
;
17 import eu
.etaxonomy
.cdm
.model
.media
.MediaRepresentationPart
;
18 import eu
.etaxonomy
.cdm
.model
.media
.MediaUtils
;
19 import eu
.etaxonomy
.cdm
.ref
.TypedEntityReference
;
22 * @author a.kohlbecker
26 public class MediaDTO
extends TypedEntityReference
<Media
> {
28 private static final long serialVersionUID
= 1981292478312137355L;
32 private String title_L10n
;
34 private String mimeType
;
39 * Creates a list of DTOs from the Media entity.
40 * For each MediaRepresentationPart a single MediaDTO is being created.
41 * TODO this needs to be changed so that it is possible to filter the representations by preferences,
42 * see {@link MediaUtils#findBestMatchingRepresentation(Media, Class, Integer, Integer, Integer, String[], eu.etaxonomy.cdm.model.media.MediaUtils.MissingValueStrategy)}
44 public static List
<MediaDTO
> fromEntity(Media entity
) {
45 List
<MediaDTO
> dtos
= new ArrayList
<>();
46 entity
.getAllTitles(); // initialize all titles!!!
47 for (MediaRepresentation rep
:entity
.getRepresentations()){
48 for(MediaRepresentationPart p
: rep
.getParts()){
49 if(p
.getUri() != null){
50 MediaDTO dto
= new MediaDTO(entity
.getUuid());
51 dto
.setUri(p
.getUri().toString());
63 public MediaDTO(UUID uuid
) {
64 super(Media
.class, uuid
);
67 public String
getUri() {
70 public void setUri(String uri
) {
74 public String
getTitle_l10n() {
77 public void setTitle_l10n(String title_l10n
) {
78 this.title_L10n
= title_l10n
;
81 public String
getMimeType() {
84 public void setMimeType(String mimeType
) {
85 this.mimeType
= mimeType
;
88 public Integer
getSize() {
91 public void setSize(Integer size
) {