Revision 1e9848aa
Added by Andreas Müller over 12 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/Figure.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.cdm.model.common; |
11 | 11 |
|
12 | 12 |
|
13 |
import java.net.URI; |
|
14 |
|
|
13 | 15 |
import org.apache.log4j.Logger; |
14 | 16 |
import org.hibernate.envers.Audited; |
15 | 17 |
|
18 |
import eu.etaxonomy.cdm.model.media.ImageFile; |
|
19 |
import eu.etaxonomy.cdm.model.media.Media; |
|
20 |
import eu.etaxonomy.cdm.model.media.MediaRepresentation; |
|
16 | 21 |
import eu.etaxonomy.cdm.model.media.ReferencedMedia; |
17 | 22 |
|
18 | 23 |
import javax.persistence.*; |
... | ... | |
42 | 47 |
return new Figure(); |
43 | 48 |
} |
44 | 49 |
|
50 |
/** |
|
51 |
* Factory method which creates a new figure, adds a reprsentation including mime type and suffix information |
|
52 |
* and adds to the later a representation part for a given uri and size |
|
53 |
* Returns <code>null</code> if uri is empty |
|
54 |
* @return Media |
|
55 |
*/ |
|
56 |
public static Media NewInstance(URI uri, Integer size, String mimeType, String suffix){ |
|
57 |
MediaRepresentation representation = MediaRepresentation.NewInstance(mimeType, suffix, uri, size, ImageFile.class); |
|
58 |
if (representation == null){ |
|
59 |
return null; |
|
60 |
} |
|
61 |
Figure figure = Figure.NewInstance(); |
|
62 |
figure.addRepresentation(representation); |
|
63 |
return figure; |
|
64 |
} |
|
65 |
|
|
45 | 66 |
/** |
46 | 67 |
* Constructor |
47 | 68 |
*/ |
Also available in: Unified diff
some updates on factory methods for media, figure, media representations