/*
* Copyright (C) 2012, Emergya (http://www.emergya.es)
*
* @author <a href="mailto:jlrodriguez@emergya.es">Juan Luís Rodríguez</a>
* @author <a href="mailto:marias@emergya.es">María Arias</a>
*
* This file is part of GoFleet
*
* This software 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 software 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 library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* As a special exception, if you link this library with other files to
* produce an executable, this library does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* This exception does not however invalidate any other reasons why the
* executable file might be covered by the GNU General Public License.
*/
package org.gofleet.openLS.ddbb.bean;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.NamedNativeQuery;
import org.hibernate.annotations.Type;
import com.vividsolutions.jts.geom.Geometry;
@Entity
@Table(name = "hba", schema = "public")
@Immutable
@NamedNativeQuery(name = "tsp", resultClass = HBA.class, query = "select id, geom, name, cost from gls_tsp(:tablename, cast(ARRAY[:stoptable] as geometry[]), :gid, :start)", cacheable = false, readOnly = true)
@Cache(usage = CacheConcurrencyStrategy.NONE)
public class HBA implements java.io.Serializable {
private static final long serialVersionUID = 3718703072510002908L;
@Id
@Column(name = "id", unique = true, nullable = false)
private Long id;
@Column(name = "geom")
@Type(type = "org.hibernatespatial.GeometryUserType")
private Geometry geometria;
@Column(name = "name")
private String name;
@Column(name = "cost")
private Double cost;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Geometry getGeometria() {
return geometria;
}
public void setGeometria(Geometry geometria) {
this.geometria = geometria;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Double getCost() {
return cost;
}
public void setCost(Double cost) {
this.cost = cost;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((cost == null) ? 0 : cost.hashCode());
result = prime * result
+ ((geometria == null) ? 0 : geometria.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
HBA other = (HBA) obj;
if (cost == null) {
if (other.cost != null)
return false;
} else if (!cost.equals(other.cost))
return false;
if (geometria == null) {
if (other.geometria != null)
return false;
} else if (!geometria.equals(other.geometria))
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
@Override
public String toString() {
return "HBA [id=" + id + ", geometry=" + geometria + ", name=" + name
+ ", cost=" + cost + "]";
}
}