/* ==================================================================== * * Copyright (C) 2007 - 2011 GeoSolutions S.A.S. * http://www.geo-solutions.it * * GPLv3 + Classpath exception * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. * * ==================================================================== * * This software consists of voluntary contributions made by developers * of GeoSolutions. For more information on GeoSolutions, please see * <http://www.geo-solutions.it/>. * */ package it.geosolutions.geostore.core.model; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.OneToOne; import javax.persistence.Table; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.ForeignKey; /** * Class StoredData. * * @author ETj (etj at geo-solutions.it) * @author Tobia di Pisa (tobia.dipisa at geo-solutions.it) * */ @Entity(name = "StoreData") @Table(name = "gs_stored_data") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "gs_stored_data") @XmlRootElement(name = "StoredData") public class StoredData implements Serializable { private static final long serialVersionUID = -2584592064221812813L; @Id private Long id; @Column(name = "stored_data", nullable = false, updatable = true, length = 500000) private String data; @OneToOne(optional = false) @ForeignKey(name = "fk_data_resource") private Resource resource; /** * Instantiates a new instance. */ public StoredData() { } /** * @return the id */ @XmlTransient public Long getId() { return id; } /** * @param id the id to set */ public void setId(long id) { this.id = id; } public String getData() { return data; } public void setData(String data) { this.data = data; } /** * @return the resource */ @XmlTransient public Resource getResource() { return resource; } /** * @param resource the resource to set */ public void setResource(Resource resource) { this.resource = resource; } /* * (non-Javadoc) @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()).append('['); builder.append("id=").append(id); if (data != null) { builder.append(", "); builder.append("data=").append(data); } builder.append(']'); return builder.toString(); } /* * (non-Javadoc) @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + ((data == null) ? 0 : data.hashCode()); result = (prime * result) + ((id == null) ? 0 : id.hashCode()); result = (prime * result) + ((resource == null) ? 0 : resource.hashCode()); return result; } /* * (non-Javadoc) @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } StoredData other = (StoredData) obj; if (data == null) { if (other.data != null) { return false; } } else if (!data.equals(other.data)) { return false; } if (id == null) { if (other.id != null) { return false; } } else if (!id.equals(other.id)) { return false; } if (resource == null) { if (other.resource != null) { return false; } } else if (!resource.equals(other.resource)) { return false; } return true; } }