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, table = "oc_oaipmh_elements"),
61      @JoinColumn(name = "repo_id", referencedColumnName = "repo_id", nullable = false, table = "oc_oaipmh_elements")
62    })
63    private OaiPmhEntity oaiPmhEntity;
64  
65    public OaiPmhElementEntity() { }
66  
67    /**
68     * Constructor
69     *
70     * @param elementType the type of the media package element. Only Catalog and Attachment are supported currently
71     * @param flavor the flavor of the media package element
72     * @param xml the XML serialized media package element content
73     */
74    public OaiPmhElementEntity(String elementType, String flavor, String xml) {
75      this.elementType = elementType;
76      this.flavor = flavor;
77      this.xml = xml;
78    }
79  
80    /**
81     * @return the type of the media package element
82     */
83    public String getElementType() {
84      return elementType;
85    }
86  
87    /**
88     * Set thetype of the media package element. Only Catalog and Attachment are supported currently
89     * @param elementType the media package elementy type to set
90     */
91    public void setElementType(String elementType) {
92      this.elementType = elementType;
93    }
94  
95    /**
96     * @return the media package element flavor
97     */
98    public String getFlavor() {
99      return flavor;
100   }
101 
102   /**
103    * @param flavor the media package element flavor to set
104    */
105   public void setFlavor(String flavor) {
106     this.flavor = flavor;
107   }
108 
109   /**
110    * @return the XML serialized content of the media package element
111    */
112   public String getXml() {
113     return xml;
114   }
115 
116   /**
117    * @param xml the XML serialized content of the media package element to set
118    */
119   public void setXml(String xml) {
120     this.xml = xml;
121   }
122 
123   /**
124    * @return the OAI-PMH entity
125    */
126   public OaiPmhEntity getOaiPmhEntity() {
127     return oaiPmhEntity;
128   }
129 
130   /**
131    * @param oaiPmhEntity the OAI-PMH entity to set
132    */
133   public void setOaiPmhEntity(OaiPmhEntity oaiPmhEntity) {
134     this.oaiPmhEntity = oaiPmhEntity;
135   }
136 }