View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  package org.opencastproject.oaipmh.persistence;
22  
23  import javax.persistence.Column;
24  import javax.persistence.Entity;
25  import javax.persistence.GeneratedValue;
26  import javax.persistence.Id;
27  import javax.persistence.JoinColumn;
28  import javax.persistence.JoinColumns;
29  import javax.persistence.Lob;
30  import javax.persistence.ManyToOne;
31  import javax.persistence.Table;
32  
33  @Entity(name = "OaiPmhElementEntity")
34  @Table(name = "oc_oaipmh_elements")
35  public class OaiPmhElementEntity {
36  
37    /** The auto generated unique database ID */
38    @Id
39    @GeneratedValue
40    @Column(name = "id")
41    private long id;
42  
43    /** The type of the media package element. Only Catalog and Attachment are supported currently. */
44    @Column(name = "element_type", length = 16, nullable = false)
45    private String elementType;
46  
47    /** The flavor of the media package element */
48    @Column(name = "flavor", nullable = false)
49    private String flavor;
50  
51    /** The XML serialized media package element content */
52    @Lob
53    @Column(name = "xml", length = 65535, nullable = false)
54    private String xml;
55  
56    /** The OAI-PMH entity belongs to this element */
57    @ManyToOne(optional = false)
58    @JoinColumns({
59        @JoinColumn(name = "mp_id", referencedColumnName = "mp_id", nullable = false, table = "oc_oaipmh_elements"),
60        @JoinColumn(name = "organization", referencedColumnName = "organization", nullable = false,
61            table = "oc_oaipmh_elements"),
62        @JoinColumn(name = "repo_id", referencedColumnName = "repo_id", nullable = false, table = "oc_oaipmh_elements")
63    })
64    private OaiPmhEntity oaiPmhEntity;
65  
66    public OaiPmhElementEntity() { }
67  
68    /**
69     * Constructor
70     *
71     * @param elementType the type of the media package element. Only Catalog and Attachment are supported currently
72     * @param flavor the flavor of the media package element
73     * @param xml the XML serialized media package element content
74     */
75    public OaiPmhElementEntity(String elementType, String flavor, String xml) {
76      this.elementType = elementType;
77      this.flavor = flavor;
78      this.xml = xml;
79    }
80  
81    /**
82     * @return the type of the media package element
83     */
84    public String getElementType() {
85      return elementType;
86    }
87  
88    /**
89     * Set thetype of the media package element. Only Catalog and Attachment are supported currently
90     * @param elementType the media package elementy type to set
91     */
92    public void setElementType(String elementType) {
93      this.elementType = elementType;
94    }
95  
96    /**
97     * @return the media package element flavor
98     */
99    public String getFlavor() {
100     return flavor;
101   }
102 
103   /**
104    * @param flavor the media package element flavor to set
105    */
106   public void setFlavor(String flavor) {
107     this.flavor = flavor;
108   }
109 
110   /**
111    * @return the XML serialized content of the media package element
112    */
113   public String getXml() {
114     return xml;
115   }
116 
117   /**
118    * @param xml the XML serialized content of the media package element to set
119    */
120   public void setXml(String xml) {
121     this.xml = xml;
122   }
123 
124   /**
125    * @return the OAI-PMH entity
126    */
127   public OaiPmhEntity getOaiPmhEntity() {
128     return oaiPmhEntity;
129   }
130 
131   /**
132    * @param oaiPmhEntity the OAI-PMH entity to set
133    */
134   public void setOaiPmhEntity(OaiPmhEntity oaiPmhEntity) {
135     this.oaiPmhEntity = oaiPmhEntity;
136   }
137 }