/** * The contents of this file are subject to the license and copyright * detailed in the LICENSE and NOTICE files at the root of the source * tree and available online at * * http://www.dspace.org/license/ */ package org.dspace.content; import java.sql.SQLException; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.OneToOne; import javax.persistence.OrderColumn; import javax.persistence.Table; import javax.persistence.Transient; import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.service.BundleService; import org.dspace.core.Constants; import org.dspace.core.Context; import org.hibernate.proxy.HibernateProxyHelper; /** * Class representing bundles of bitstreams stored in the DSpace system *
* The corresponding Bitstream objects are loaded into memory. At present, there
* is no metadata associated with bundles - they are simple containers. Thus,
* the update
method doesn't do much yet. Creating, adding or
* removing bitstreams has instant effect in the database.
*
* @author Robert Tansley
* @version $Revision$
*/
@Entity
@Table(name = "bundle")
public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport {
@Column(name = "bundle_id", insertable = false, updatable = false)
private Integer legacyId;
@OneToOne
@JoinColumn(name = "primary_bitstream_id")
private Bitstream primaryBitstream;
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(
name = "bundle2bitstream",
joinColumns = {@JoinColumn(name = "bundle_id")},
inverseJoinColumns = {@JoinColumn(name = "bitstream_id")}
)
@OrderColumn(name = "bitstream_order")
private final ListItem
s this bundle appears in
*/
public ListItem
s this bundle appears in
*/
void addItem(Item item) {
getItems().add(item);
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
Class> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj);
if (this.getClass() != objClass) {
return false;
}
final Bundle other = (Bundle) obj;
if (this.getType() != other.getType()) {
return false;
}
if (!this.getID().equals(other.getID())) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 5;
hash += 71 * hash + getType();
hash += 71 * hash + getID().hashCode();
return hash;
}
/**
* return type found in Constants
*
* @return bundle type
*/
@Override
public int getType() {
return Constants.BUNDLE;
}
private BundleService getBundleService() {
if (bundleService == null) {
bundleService = ContentServiceFactory.getInstance().getBundleService();
}
return bundleService;
}
}