/* * Copyright 2016 Studentmediene i Trondheim AS * * 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 no.dusken.momus.model; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; import javax.persistence.*; import java.util.Arrays; import java.util.Set; @Entity public class Source { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String name; private String description; private String telephone; private String email; private String webPage; private String address; private String note; @ManyToMany(fetch = FetchType.EAGER) @Fetch(FetchMode.SUBSELECT) private Set<SourceTag> tags; public Source() { } public Source(String name, Set<SourceTag> tags) { this.name = name; this.tags = tags; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getTelephone() { return telephone; } public void setTelephone(String telephone) { this.telephone = telephone; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getWebPage() { return webPage; } public void setWebPage(String webPage) { this.webPage = webPage; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getNote() { return note; } public void setNote(String note) { this.note = note; } public Set<SourceTag> getTags() { return tags; } public void setTags(Set<SourceTag> tags) { this.tags = tags; } @Override public String toString() { return "Source{" + "id=" + id + ", name='" + name + '\'' + '}'; } public String dump() { return "Source{" + "id=" + id + ", name='" + name + '\'' + ", description='" + description + '\'' + ", telephone='" + telephone + '\'' + ", email='" + email + '\'' + ", webPage='" + webPage + '\'' + ", address='" + address + '\'' + ", note='" + note + '\'' + ", tags=" + (tags == null ? "[]" : Arrays.toString(tags.toArray())) + '}'; } }