merge hibernate4 migration branch into trunk
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / common / Figure.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.cdm.model.common;
11
12
13 import java.net.URI;
14
15 import org.apache.log4j.Logger;
16 import org.hibernate.envers.Audited;
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;
21 import eu.etaxonomy.cdm.model.media.ReferencedMediaBase;
22
23 import javax.persistence.*;
24 import javax.xml.bind.annotation.XmlAccessType;
25 import javax.xml.bind.annotation.XmlAccessorType;
26 import javax.xml.bind.annotation.XmlType;
27
28 /**
29 * @author m.doering
30 * @version 1.0
31 * @created 08-Nov-2007 13:06:25
32 */
33 @XmlAccessorType(XmlAccessType.FIELD)
34 @XmlType(name = "Figure")
35 @Entity
36 @Audited
37 public class Figure extends ReferencedMediaBase {
38 private static final long serialVersionUID = -1712467725277327725L;
39 @SuppressWarnings("unused")
40 private static final Logger logger = Logger.getLogger(Figure.class);
41
42 /**
43 * Factory method
44 * @return
45 */
46 public static Figure NewInstance(){
47 return new Figure();
48 }
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
66 /**
67 * Constructor
68 */
69 protected Figure() {
70 super();
71 }
72
73 }