/** * Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2016 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.glite.security.voms.admin.integration.orgdb.model; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import org.hibernate.annotations.Immutable; @Entity @Immutable @Table(name = "INSTITUTES") public class Institute implements Serializable { /** * */ private static final long serialVersionUID = 1L; @Id @Column(name = "CODE", length = 6) String code; @Column(name = "ENGLISH_NAME", length = 71) String englishName; @Column(name = "ORIGINAL_NAME", length = 71) String originalName; @Column(name = "NAME", length = 71) String name; @ManyToOne(optional = true) @JoinColumn(name = "PARENT_INSTITUTE") Institute parent; @ManyToOne(optional = true) @JoinColumn(name = "ADDRESS_ID") InstituteAddress address; @Column(name = "INSTITUTE_TYPE", length = 2) String type; @ManyToOne(optional = true, fetch = FetchType.LAZY) @JoinColumn(name = "COUNTRY_CODE") Country country; @Column(name = "PLACE", length = 30, nullable = false) String place; @Column(name = "URL", length = 100) String url; @Column(name = "STATUS", length = 1, nullable = false) String status; @Column(name = "LIBRARY", length = 1, nullable = false) String library; public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getEnglishName() { return englishName; } public void setEnglishName(String englishName) { this.englishName = englishName; } public String getOriginalName() { return originalName; } public void setOriginalName(String originalName) { this.originalName = originalName; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Institute getParent() { return parent; } public void setParent(Institute parent) { this.parent = parent; } public String getType() { return type; } public void setType(String type) { this.type = type; } public Country getCountry() { return country; } public void setCountry(Country country) { this.country = country; } public String getPlace() { return place; } public void setPlace(String place) { this.place = place; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public String getLibrary() { return library; } public void setLibrary(String library) { this.library = library; } /* * (non-Javadoc) * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((country == null) ? 0 : country.hashCode()); result = prime * result + ((englishName == null) ? 0 : englishName.hashCode()); result = prime * result + ((library == null) ? 0 : library.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((originalName == null) ? 0 : originalName.hashCode()); result = prime * result + ((place == null) ? 0 : place.hashCode()); result = prime * result + ((status == null) ? 0 : status.hashCode()); result = prime * result + ((type == null) ? 0 : type.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; Institute other = (Institute) obj; if (country == null) { if (other.country != null) return false; } else if (!country.equals(other.country)) return false; if (englishName == null) { if (other.englishName != null) return false; } else if (!englishName.equals(other.englishName)) return false; if (library == null) { if (other.library != null) return false; } else if (!library.equals(other.library)) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (originalName == null) { if (other.originalName != null) return false; } else if (!originalName.equals(other.originalName)) return false; if (place == null) { if (other.place != null) return false; } else if (!place.equals(other.place)) return false; if (status == null) { if (other.status != null) return false; } else if (!status.equals(other.status)) return false; if (type == null) { if (other.type != null) return false; } else if (!type.equals(other.type)) return false; return true; } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Institute [code=").append(code).append(", name=") .append(name).append(", englishName=").append(englishName) .append(", originalName=").append(originalName).append("]"); return builder.toString(); } }