2 * Copyright (C) 2016, 2017 Roland Häder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jcontactsbusiness.logo;
19 import java.util.Calendar;
20 import java.util.Objects;
21 import javax.persistence.Basic;
22 import javax.persistence.CascadeType;
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.GenerationType;
27 import javax.persistence.Id;
28 import javax.persistence.JoinColumn;
29 import javax.persistence.OneToOne;
30 import javax.persistence.Table;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33 import javax.persistence.Transient;
34 import org.mxchange.jusercore.model.user.LoginUser;
35 import org.mxchange.jusercore.model.user.User;
38 * A POJO for company logos
40 * @author Roland Häder<roland@mxchange.org>
42 @Entity (name = "company_logos")
43 @Table (name = "company_logos")
44 @SuppressWarnings ("PersistenceUnitPresent")
45 public class CompanyLogo implements BusinessLogo {
51 private static final long serialVersionUID = 475_871_875_718_751_285L;
54 * Timestamp when this entry has been created
56 @Basic (optional = false)
57 @Temporal (TemporalType.TIMESTAMP)
58 @Column (name = "logo_entry_created", nullable = false, updatable = false)
59 private Calendar logoCreated;
62 * Local file name of the logo (relative to /resources/logos/)
64 @Basic (optional = false)
65 @Column (name = "logo_file_name", nullable = false, unique = true, updatable = false)
66 private String logoFileName;
72 @GeneratedValue (strategy = GenerationType.IDENTITY)
73 @Column (name = "logo_id", nullable = false, updatable = false)
77 * Logo uploader user instance
79 @JoinColumn (name = "logo_uploader_id", nullable = false, updatable = false)
80 @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
81 private User logoUploader;
84 public boolean equals (final Object object) {
87 } else if (this.getClass() != object.getClass()) {
91 final BusinessLogo other = (BusinessLogo) object;
93 if (!Objects.equals(this.getLogoId(), other.getLogoId())) {
95 } else if (!Objects.equals(this.getLogoUploader(), other.getLogoUploader())) {
97 } else if (!Objects.equals(this.getLogoFileName(), other.getLogoFileName())) {
105 @SuppressWarnings ("ReturnOfDateField")
106 public Calendar getLogoCreated () {
107 return this.logoCreated;
111 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
112 public void setLogoCreated (final Calendar logoCreated) {
113 this.logoCreated = logoCreated;
117 public String getLogoFileName () {
118 return this.logoFileName;
122 public void setLogoFileName (final String logoFileName) {
123 this.logoFileName = logoFileName;
127 public Long getLogoId () {
132 public void setLogoId (final Long logoId) {
133 this.logoId = logoId;
137 public User getLogoUploader () {
138 return this.logoUploader;
142 public void setLogoUploader (final User logoUploader) {
143 this.logoUploader = logoUploader;
147 public int hashCode () {
150 hash = 53 * hash + Objects.hashCode(this.getLogoId());
151 hash = 53 * hash + Objects.hashCode(this.getLogoFileName());
152 hash = 53 * hash + Objects.hashCode(this.getLogoUploader());