/* Copyright 2006 - 2010 Under Dusken 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.aranea.model; import javax.persistence.*; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; /** * This is a representation of an banner Advertisment. * * @author Erlend Hamnaberg<erlenha@underdusken.no> * @author Asbjørn L. Johansen<asbjorjo@underdusken.no> */ @Entity @Table(name = "banner") @SequenceGenerator(name = "banner_seq", sequenceName = "banner_id_seq") @NamedQueries({ @NamedQuery(name = "banners_all", query = "select b from Banner b order by b.timeCreated desc"), @NamedQuery(name = "banner_byhash", query = "select a from Banner a where a.hash = :hash")}) public class Banner extends AraneaObject { /** * MD5-hashed name of the file. */ @Column(nullable = false, length = 1000) private String hash; /** * number of clicks this Ad has received */ private Long clicks = 0L; /** * Short description of the banner */ @Basic @Size(max = 512, min = 5) @NotNull @Column(length = 512) private String description; /** * Uses to save script text for the banner. */ @Basic @Column(length = 5000) @Size(max = 5000) private String script; /** * The filetype of the Advertisment. Different types requires different * displaycode. Eg: Flash vs animated gif * * @see BannerType */ @Enumerated(EnumType.STRING) // @NotNull(message = "Please specify banner type") private BannerType type = BannerType.GIF; /** * Where is this banner placed, if it is currently displayed? */ @OneToOne @JoinColumn(nullable = true) private BannerLocation location; /** * The url to redirect to when the Ad is clicked */ @Size(max = 255) private String url = "http://www.example.com/"; @Column @Min(0) @NotNull private Integer width; @Column @Min(0) @NotNull private Integer height; public Banner() { } public Banner(Long ID) { super(ID); } public String getHash() { return hash; } public void setHash(String hash) { this.hash = hash; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public Long getClicks() { return clicks; } public void setClicks(Long clicks) { this.clicks = clicks; } public BannerType getType() { return type; } public void setType(BannerType type) { this.type = type; } public BannerLocation getLocation() { return location; } public void setLocation(BannerLocation location) { this.location = location; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String toString() { return "Banner( " + ID + "): " + hash + "." + type; } public String getScript() { return script; } public void setScript(String script) { this.script = script; } public Integer getWidth() { return width; } public void setWidth(Integer width) { this.width = width; } public Integer getHeight() { return height; } public void setHeight(Integer height) { this.height = height; } }