Ignore:
Timestamp:
03/15/10 18:10:30 (14 years ago)
Author:
oschonef
Message:
  • remove preliminary support for copied metadata

HEADS UP: internal XML format and database layout has changed!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/model/Resource.java

    r146 r226  
    22
    33import javax.persistence.Column;
    4 import javax.persistence.DiscriminatorColumn;
    5 import javax.persistence.DiscriminatorType;
    64import javax.persistence.Entity;
     5import javax.persistence.EnumType;
     6import javax.persistence.Enumerated;
    77import javax.persistence.GeneratedValue;
    88import javax.persistence.GenerationType;
    99import javax.persistence.Id;
    10 import javax.persistence.Inheritance;
    11 import javax.persistence.InheritanceType;
    1210import javax.persistence.Table;
    1311import javax.xml.bind.annotation.XmlAccessType;
    1412import javax.xml.bind.annotation.XmlAccessorType;
    1513import javax.xml.bind.annotation.XmlAttribute;
     14import javax.xml.bind.annotation.XmlElement;
    1615import javax.xml.bind.annotation.XmlID;
    17 import javax.xml.bind.annotation.XmlSeeAlso;
     16import javax.xml.bind.annotation.XmlType;
     17
     18import org.apache.commons.lang.builder.HashCodeBuilder;
    1819
    1920@Entity
    2021@Table(name = "resource")
    21 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
    22 @DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING, length=1)
    2322@XmlAccessorType(XmlAccessType.NONE)
    24 @XmlSeeAlso({ ResourceProxy.class, ResourceMetadata.class })
    25 public abstract class Resource {
     23@XmlType(propOrder = { "type", "ref" })
     24public class Resource {
    2625        @Id
    2726        @GeneratedValue(strategy = GenerationType.AUTO)
    2827        @Column(name = "id", nullable = false, updatable = false, insertable = true)
    2928        private long id = -1;
     29        @Column(name = "type", nullable = false)
     30        @Enumerated(EnumType.ORDINAL)
     31        private ResourceType type;
     32        @Column(name = "ref", nullable = false)
     33        private String ref;
    3034
    31         protected Resource() {
     35        private Resource() {
    3236                super();
     37        }
     38
     39        public Resource(ResourceType type, String ref) {
     40                this();
     41                this.setType(type);
     42                this.setRef(ref);
    3343        }
    3444
     
    4252                return "r" + id;
    4353        }
    44        
    45         public abstract ResourceType getType();
    4654
    47         public abstract String getRef();
     55        public void setType(ResourceType type) {
     56                if (type == null) {
     57                        throw new NullPointerException("type == null");
     58                }
     59                this.type = type;
     60        }
    4861
    49         abstract int getSignature();
     62        @XmlElement(name = "ResourceType")
     63        public ResourceType getType() {
     64                return type;
     65        }
    5066
    51 } // abstract class Resource
     67        public void setRef(String ref) {
     68                if (ref == null) {
     69                        throw new NullPointerException("ref == null");
     70                }
     71                this.ref = ref;
     72        }
     73
     74        @XmlElement(name = "ResourceRef")
     75        public String getRef() {
     76                return ref;
     77        }
     78
     79        protected int getSignature() {
     80                return new HashCodeBuilder(799, 51)
     81                        .append(type)
     82                        .append(ref)
     83                        .toHashCode();
     84        }
     85
     86} // class Resource
Note: See TracChangeset for help on using the changeset viewer.