Commit f4074e4d by Tuomas Riihimäki

Rewrite on model stuff. Changed to inherit id and versionfield from Generic superclass

1 parent aedd68af
Showing with 236 additions and 1661 deletions
......@@ -39,7 +39,6 @@ import javax.persistence.TemporalType;
@NamedQuery(name = "AccountEvent.findByDelivered", query = "SELECT a FROM AccountEvent a WHERE a.delivered = :delivered") })
public class AccountEvent extends GenericEventChild {
/**
*
*/
......@@ -79,7 +78,7 @@ public class AccountEvent extends GenericEventChild {
*/
@JoinColumns({
@JoinColumn(name = "food_wave_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false) })
@JoinColumn(name = "event_id", referencedColumnName = "id", updatable = false, insertable = false) })
@ManyToOne
private FoodWave foodWave;
......@@ -89,21 +88,21 @@ public class AccountEvent extends GenericEventChild {
*/
@JoinColumns({
@JoinColumn(name = "product_id", referencedColumnName = "id", nullable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@JoinColumn(name = "event_id", referencedColumnName = "id", nullable = false, updatable = false, insertable = false) })
@ManyToOne(optional = false)
private Product product;
/**
* The user that bought the products.
*/
@JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false)
@JoinColumn(name = "user_id", referencedColumnName = "id", nullable = false)
@ManyToOne(optional = false)
private User user;
/**
* Who sold the items to the user.
*/
@JoinColumn(name = "seller_user_id", referencedColumnName = "user_id")
@JoinColumn(name = "seller_user_id", referencedColumnName = "id")
@ManyToOne(optional = true)
private User seller;
......@@ -174,11 +173,6 @@ public class AccountEvent extends GenericEventChild {
this.discountInstances = discountInstanceList;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.AccountEvent[id=" + getId() + "]";
}
public void setFoodWave(FoodWave foodWave) {
this.foodWave = foodWave;
}
......
......@@ -4,13 +4,14 @@
*/
package fi.insomnia.bortal.model;
import static javax.persistence.TemporalType.DATE;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
......@@ -24,13 +25,10 @@ import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
import javax.persistence.UniqueConstraint;
import org.eclipse.persistence.annotations.PrivateOwned;
import static javax.persistence.TemporalType.DATE;
/**
* The system can send bills to the users. When user pays bill a AccountEvent
* row is created for product whose price is +1 and Bills paidDate is changed to
......@@ -136,7 +134,7 @@ public class Bill extends GenericEventChild {
private User user;
@ManyToOne
@JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false)
@JoinColumn(name = "event_id", referencedColumnName = "id", updatable = false, insertable = false)
private LanEvent event;
public Integer getReferenceNumberBase() {
......@@ -185,22 +183,22 @@ public class Bill extends GenericEventChild {
return total;
}
public Bill() {
}
public Bill(LanEvent event) {
setId(new EventPk(event));
}
public Bill(LanEvent event, User user) {
setId(new EventPk(event));
this(event);
this.setUser(user);
this.setAddr1(user.getFirstnames() + " " + user.getLastname());
this.setAddr2(user.getAddress());
this.setAddr3(user.getZip() + " " + user.getTown());
}
public Bill(LanEvent event) {
super(event);
}
public Bill() {
super();
}
public Calendar getDueDate() {
Calendar dueDate = (Calendar) this.getSentDate().clone();
......@@ -248,11 +246,6 @@ public class Bill extends GenericEventChild {
this.user = usersId;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.Bill[id=" + getId() + "]";
}
public LanEvent getEvent() {
return event;
}
......
......@@ -8,7 +8,6 @@ package fi.insomnia.bortal.model;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
......@@ -18,14 +17,12 @@ import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Version;
/**
*
*/
@Entity
@Table(name = "bill_lines")
@NamedQueries({
@NamedQuery(name = "BillLine.findAll", query = "SELECT b FROM BillLine b"),
......@@ -33,13 +30,9 @@ import javax.persistence.Version;
@NamedQuery(name = "BillLine.findByQuantity", query = "SELECT b FROM BillLine b WHERE b.quantity = :quantity"),
@NamedQuery(name = "BillLine.findByUnitPrice", query = "SELECT b FROM BillLine b WHERE b.unitPrice = :unitPrice"),
@NamedQuery(name = "BillLine.findByVat", query = "SELECT b FROM BillLine b WHERE b.vat = :vat") })
public class BillLine implements EventChildInterface {
public class BillLine extends GenericEventChild {
private static final long serialVersionUID = 1L;
private static final BigDecimal DEFAULT_VAT = BigDecimal.ZERO;
@EmbeddedId
private EventPk id;
/**
* Product name shown on the bill
......@@ -82,10 +75,6 @@ public class BillLine implements EventChildInterface {
@ManyToOne
private Bill bill;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
@JoinColumns({
@JoinColumn(name = "lineProduct_id", referencedColumnName = "id", nullable = true, updatable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
......@@ -117,11 +106,12 @@ public class BillLine implements EventChildInterface {
}
public BillLine() {
super();
}
public BillLine(Bill bill) {
this.id = new EventPk(bill.getId().getEventId());
super();
setId(new EventPk(bill.getId().getEventId()));
this.bill = bill;
}
......@@ -151,53 +141,6 @@ public class BillLine implements EventChildInterface {
this.bill = billsId;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof BillLine)) {
return false;
}
BillLine other = (BillLine) object;
if ((this.id == null && other.id != null)
|| (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.BillLine[id=" + id + "]";
}
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
@Override
public EventPk getId() {
return id;
}
@Override
public void setId(EventPk id) {
this.id = id;
}
public void setQuantity(BigDecimal units) {
this.quantity = units;
}
......
......@@ -8,7 +8,6 @@ package fi.insomnia.bortal.model;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
......@@ -17,20 +16,17 @@ import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
/**
* ID-card templates for the event.
*/
@Entity
@Table(name = "card_templates")
@NamedQueries( {
@NamedQueries({
@NamedQuery(name = "CardTemplate.findAll", query = "SELECT c FROM CardTemplate c"),
@NamedQuery(name = "CardTemplate.findByName", query = "SELECT c FROM CardTemplate c WHERE c.name = :name") })
public class CardTemplate implements EventChildInterface {
public class CardTemplate extends GenericEventChild {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Lob
@Column(name = "template_image")
......@@ -39,7 +35,7 @@ public class CardTemplate implements EventChildInterface {
@Column(name = "template_name", nullable = false)
private String name;
@Column(name="power", nullable=false)
@Column(name = "power", nullable = false)
private int power = 0;
@OneToMany(mappedBy = "cardTemplate")
......@@ -49,22 +45,15 @@ public class CardTemplate implements EventChildInterface {
private List<PrintedCard> cards;
@ManyToOne
@JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false)
@JoinColumn(name = "event_id", referencedColumnName = "id", updatable = false, insertable = false)
private LanEvent event;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
public CardTemplate() {
}
public CardTemplate(LanEvent event) {
this.id = new EventPk(event);
super();
}
public CardTemplate(LanEvent event, String templateName) {
this.id = new EventPk(event);
super(event);
this.name = templateName;
}
......@@ -84,16 +73,6 @@ public class CardTemplate implements EventChildInterface {
this.name = templateName;
}
@Override
public EventPk getId() {
return id;
}
@Override
public void setId(EventPk id) {
this.id = id;
}
public List<Role> getRoles() {
return roles;
}
......@@ -102,43 +81,6 @@ public class CardTemplate implements EventChildInterface {
this.roles = roleList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof CardTemplate)) {
return false;
}
CardTemplate other = (CardTemplate) object;
if ((this.id == null && other.id != null)
|| (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.CardTemplate[id=" + id + "]";
}
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
public void setCards(List<PrintedCard> cards) {
this.cards = cards;
}
......
......@@ -10,7 +10,6 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
......@@ -21,14 +20,13 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
/**
* Competition to be held at the event.
*/
@Entity
@Table(name = "compos")
@NamedQueries( {
@NamedQueries({
@NamedQuery(name = "Compo.findAll", query = "SELECT c FROM Compo c"),
@NamedQuery(name = "Compo.findByName", query = "SELECT c FROM Compo c WHERE c.name = :name"),
@NamedQuery(name = "Compo.findByStartTime", query = "SELECT c FROM Compo c WHERE c.startTime = :startTime"),
......@@ -38,11 +36,8 @@ import javax.persistence.Version;
@NamedQuery(name = "Compo.findBySubmitEnd", query = "SELECT c FROM Compo c WHERE c.submitEnd = :submitEnd"),
@NamedQuery(name = "Compo.findByHoldVoting", query = "SELECT c FROM Compo c WHERE c.holdVoting = :holdVoting"),
@NamedQuery(name = "Compo.findByDescription", query = "SELECT c FROM Compo c WHERE c.description = :description") })
public class Compo implements EventChildInterface {
public class Compo extends GenericEventChild {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
/**
* Name of the competition.
......@@ -101,34 +96,21 @@ public class Compo implements EventChildInterface {
private List<CompoEntry> compoEntries;
@ManyToOne
@JoinColumn(name = "event_id", referencedColumnName = "event_id", insertable = false, updatable = false)
@JoinColumn(name = "event_id", referencedColumnName = "id", insertable = false, updatable = false)
private LanEvent event;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
@Override
public EventPk getId() {
return id;
}
@Override
public void setId(EventPk id) {
this.id = id;
public Compo(LanEvent event, String compoName, boolean holdVoting) {
this(event);
this.name = compoName;
this.holdVoting = holdVoting;
}
public Compo() {
super();
}
public Compo(LanEvent event) {
this.id = new EventPk(event);
}
public Compo(LanEvent event, String compoName, boolean holdVoting) {
this.id = new EventPk(event);
this.name = compoName;
this.holdVoting = holdVoting;
super(event);
}
public String getName() {
......@@ -195,43 +177,6 @@ public class Compo implements EventChildInterface {
this.compoEntries = compoEntryList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof Compo)) {
return false;
}
Compo other = (Compo) object;
if ((this.id == null && other.id != null)
|| (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.Compo[id=" + id + "]";
}
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
public void setDescription(String description) {
this.description = description;
}
......
......@@ -10,7 +10,6 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
......@@ -23,7 +22,6 @@ import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
import org.eclipse.persistence.annotations.PrivateOwned;
......@@ -39,10 +37,8 @@ import org.eclipse.persistence.annotations.PrivateOwned;
@NamedQuery(name = "CompoEntry.findByNotes", query = "SELECT c FROM CompoEntry c WHERE c.notes = :notes"),
@NamedQuery(name = "CompoEntry.findByScreenMessage", query = "SELECT c FROM CompoEntry c WHERE c.screenMessage = :screenMessage"),
@NamedQuery(name = "CompoEntry.findBySort", query = "SELECT c FROM CompoEntry c WHERE c.sort = :sort") })
public class CompoEntry implements EventChildInterface {
public class CompoEntry extends GenericEventChild {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Column(name = "entry_created", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
......@@ -87,33 +83,16 @@ public class CompoEntry implements EventChildInterface {
@ManyToOne(optional = false)
private Compo compo;
@JoinColumn(name = "creator_user_id", referencedColumnName = "user_id")
@JoinColumn(name = "creator_user_id", referencedColumnName = "id")
@ManyToOne
private User creator;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
@Override
public EventPk getId() {
return id;
}
@Override
public void setId(EventPk id) {
this.id = id;
}
public CompoEntry() {
}
public CompoEntry(LanEvent event) {
this.id = new EventPk(event);
super();
}
public CompoEntry(LanEvent event, Calendar entryCreated, String entryName) {
this(event);
super(event);
this.created = entryCreated;
this.name = entryName;
}
......@@ -199,43 +178,6 @@ public class CompoEntry implements EventChildInterface {
this.creator = creator;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof CompoEntry)) {
return false;
}
CompoEntry other = (CompoEntry) object;
if ((this.id == null && other.id != null)
|| (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.CompoEntry[entriesId=" + id + "]";
}
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
public void setFinalPosition(Integer finalPosition) {
this.finalPosition = finalPosition;
}
......
......@@ -8,7 +8,6 @@ package fi.insomnia.bortal.model;
import java.util.Calendar;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
......@@ -19,25 +18,21 @@ import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
/**
*
*/
@Entity
@Table(name = "entry_files")
@NamedQueries( {
@NamedQueries({
@NamedQuery(name = "CompoEntryFile.findAll", query = "SELECT c FROM CompoEntryFile c"),
@NamedQuery(name = "CompoEntryFile.findByMimeType", query = "SELECT c FROM CompoEntryFile c WHERE c.mimeType = :mimeType"),
@NamedQuery(name = "CompoEntryFile.findByFileName", query = "SELECT c FROM CompoEntryFile c WHERE c.fileName = :fileName"),
@NamedQuery(name = "CompoEntryFile.findByDescription", query = "SELECT c FROM CompoEntryFile c WHERE c.description = :description"),
@NamedQuery(name = "CompoEntryFile.findByHash", query = "SELECT c FROM CompoEntryFile c WHERE c.hash = :hash"),
@NamedQuery(name = "CompoEntryFile.findByUploaded", query = "SELECT c FROM CompoEntryFile c WHERE c.uploaded = :uploaded") })
public class CompoEntryFile implements EventChildInterface {
public class CompoEntryFile extends GenericEventChild {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Column(name = "mime_type")
private String mimeType;
......@@ -59,35 +54,18 @@ public class CompoEntryFile implements EventChildInterface {
@Temporal(TemporalType.TIMESTAMP)
private Calendar uploaded = Calendar.getInstance();
@JoinColumns( {
@JoinColumns({
@JoinColumn(name = "entry_id", referencedColumnName = "id", nullable = false, updatable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne(optional = false)
private CompoEntry entry;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
@Override
public EventPk getId() {
return id;
}
@Override
public void setId(EventPk id) {
this.id = id;
}
public CompoEntryFile() {
}
public CompoEntryFile(LanEvent event) {
this.id = new EventPk(event);
super();
}
public CompoEntryFile(LanEvent event, CompoEntry entry) {
this(event);
super(event);
this.entry = entry;
}
......@@ -147,42 +125,4 @@ public class CompoEntryFile implements EventChildInterface {
this.entry = entriesId;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof CompoEntryFile)) {
return false;
}
CompoEntryFile other = (CompoEntryFile) object;
if ((this.id == null && other.id != null)
|| (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.CompoEntryFile[entryFilesId=" + id
+ "]";
}
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
}
......@@ -8,7 +8,6 @@ package fi.insomnia.bortal.model;
import java.util.Calendar;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
......@@ -18,23 +17,19 @@ import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
/**
*
*/
@Entity
@Table(name = "entry_participations")
@NamedQueries( {
@NamedQueries({
@NamedQuery(name = "CompoEntryParticipant.findAll", query = "SELECT c FROM CompoEntryParticipant c"),
@NamedQuery(name = "CompoEntryParticipant.findByRole", query = "SELECT c FROM CompoEntryParticipant c WHERE c.role = :role") })
public class CompoEntryParticipant implements EventChildInterface {
public class CompoEntryParticipant extends GenericEventChild {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Column(name = "role")
private String role;
......@@ -45,30 +40,16 @@ public class CompoEntryParticipant implements EventChildInterface {
@Temporal(TemporalType.TIMESTAMP)
private Calendar confirmed;
@JoinColumns( {
@JoinColumns({
@JoinColumn(name = "entry_id", referencedColumnName = "id", nullable = false, updatable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne(optional = false)
private CompoEntry entry;
@JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false, updatable = false)
@JoinColumn(name = "user_id", referencedColumnName = "id", nullable = false, updatable = false)
@ManyToOne(optional = false)
private User user;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
@Override
public EventPk getId() {
return id;
}
@Override
public void setId(EventPk id) {
this.id = id;
}
public CompoEntry getEntry() {
return entry;
}
......@@ -77,19 +58,20 @@ public class CompoEntryParticipant implements EventChildInterface {
this.entry = entry;
}
public CompoEntryParticipant() {
}
public CompoEntryParticipant(LanEvent event) {
this.id = new EventPk(event);
}
public CompoEntryParticipant(LanEvent event, CompoEntry entry, User participant) {
this(event);
this.entry = entry;
this.user = participant;
}
public CompoEntryParticipant() {
super();
}
public CompoEntryParticipant(LanEvent event) {
super(event);
}
public String getRole() {
return role;
}
......@@ -106,44 +88,6 @@ public class CompoEntryParticipant implements EventChildInterface {
this.user = user;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof CompoEntryParticipant)) {
return false;
}
CompoEntryParticipant other = (CompoEntryParticipant) object;
if ((this.id == null && other.id != null)
|| (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.CompoEntryParticipant[entryParticipationsId="
+ id + "]";
}
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @return the nick
*/
......
......@@ -10,18 +10,14 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
/**
*
......@@ -79,13 +75,6 @@ public class Discount extends GenericEventChild {
@ManyToMany(mappedBy = "discounts")
private List<Product> products;
public Discount() {
}
public Discount(LanEvent event) {
setId(new EventPk(event));
}
public BigDecimal getAmountMin() {
return amountMin;
}
......@@ -122,7 +111,6 @@ public class Discount extends GenericEventChild {
return active;
}
public String getCode() {
return code;
}
......@@ -151,11 +139,6 @@ public class Discount extends GenericEventChild {
this.discountInstances = discountInstanceList;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.Discount[id=" + getId() + "]";
}
public void setRole(Role role) {
this.role = role;
}
......
......@@ -62,11 +62,4 @@ public class DiscountInstance extends GenericEventChild {
this.discount = discountsId;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.DiscountInstance[discountsInstancesId="
+ getId() + "]";
}
}
package fi.insomnia.bortal.model;
import java.util.Date;
import java.util.Random;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
@MappedSuperclass
public abstract class EntityEquals {
@Override
public final String toString() {
return new StringBuilder(this.getClass().getCanonicalName()).append("[").append(getId()).append("]").toString();
}
@Transient
private Integer rndid;
protected abstract Object getId();
@Override
public final boolean equals(Object o) {
boolean ret = false;
if (o != null && o instanceof EntityEquals && this.getClass().getCanonicalName().equals(o.getClass().getCanonicalName())) {
EntityEquals oobj = (EntityEquals) o;
if (getId() == null) {
ret = (getRndid().equals(oobj.rndid));
} else {
ret = getId().equals(oobj.getId());
}
}
return ret;
}
private Integer getRndid() {
if (rndid == null) {
Random rng = new Random(new Date().getTime());
rndid = new Integer(rng.nextInt());
}
return rndid;
}
@Override
public final int hashCode() {
return ((rndid != null || getId() == null) ? getRndid() : getId().hashCode());
}
}
......@@ -9,7 +9,6 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
......@@ -19,10 +18,6 @@ import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
......@@ -32,12 +27,13 @@ import org.slf4j.LoggerFactory;
@NamedQueries({
@NamedQuery(name = "EventMap.findAll", query = "SELECT e FROM EventMap e"),
@NamedQuery(name = "EventMap.findByName", query = "SELECT e FROM EventMap e WHERE e.name = :name") })
public class EventMap implements EventChildInterface {
public class EventMap extends GenericEventChild {
/**
*
*/
private static final long serialVersionUID = 3411450245513673619L;
private static final Logger logger = LoggerFactory.getLogger(EventMap.class);
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Lob
@Column(name = "map_data")
private byte[] mapData;
......@@ -49,11 +45,8 @@ public class EventMap implements EventChildInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "map")
private List<Place> places = new ArrayList<Place>();
@ManyToOne(optional = false)
@JoinColumn(name = "event_id", referencedColumnName = "event_id", insertable = false, updatable = false, nullable = false)
@JoinColumn(name = "event_id", referencedColumnName = "id", insertable = false, updatable = false, nullable = false)
private LanEvent event;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
@OneToMany(mappedBy = "eventMap")
private List<Reader> readers;
......@@ -64,13 +57,6 @@ public class EventMap implements EventChildInterface {
@Lob
private String notes;
public EventMap() {
}
public EventMap(LanEvent event) {
this.id = new EventPk(event);
}
public String getName() {
return name;
}
......@@ -87,67 +73,6 @@ public class EventMap implements EventChildInterface {
this.places = placeList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof EventMap)) {
return false;
}
EventMap other = (EventMap) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.EventMap[id=" + getId() + "]";
}
/**
* @return the id
*/
@Override
public EventPk getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(EventPk id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
/**
* @return the readers
*/
......
......@@ -9,10 +9,6 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
......@@ -20,7 +16,6 @@ import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Version;
/**
*
......@@ -31,13 +26,9 @@ import javax.persistence.Version;
@NamedQuery(name = "EventOrganiser.findAll", query = "SELECT e FROM EventOrganiser e"),
@NamedQuery(name = "EventOrganiser.findByOrganisation", query = "SELECT e FROM EventOrganiser e WHERE e.organisation = :organisation"),
@NamedQuery(name = "EventOrganiser.findByBundleCountry", query = "SELECT e FROM EventOrganiser e WHERE e.bundleCountry = :bundleCountry") })
public class EventOrganiser implements ModelInterface {
public class EventOrganiser extends GenericEntity {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "event_organiser_id", nullable = false)
private Integer id;
@Column(name = "organisation")
private String organisation;
......@@ -50,13 +41,9 @@ public class EventOrganiser implements ModelInterface {
private List<LanEvent> events;
@ManyToOne()
@JoinColumn(name = "admin_user_id", referencedColumnName = "user_id", nullable = false)
@JoinColumn(name = "admin_user_id", referencedColumnName = "id", nullable = false)
private User admin;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
@Column(nullable = false, name = "bill_address1")
private String billAddress1 = "";
@Column(nullable = false, name = "bill_address2")
......@@ -74,9 +61,6 @@ public class EventOrganiser implements ModelInterface {
@Column(nullable = false, name = "bank_name2")
private String bankName2 = "";
public EventOrganiser() {
}
public List<LanEvent> getEvents() {
return events;
}
......@@ -85,67 +69,6 @@ public class EventOrganiser implements ModelInterface {
this.events = eventList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof EventOrganiser)) {
return false;
}
EventOrganiser other = (EventOrganiser) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.EventOrganiser[id=" + getId() + "]";
}
/**
* @return the id
*/
@Override
public Integer getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(Integer id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
/**
* @return the organisation
*/
......
......@@ -9,46 +9,28 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
/**
*
*/
@Entity
@Table(name = "event_status")
//, uniqueConstraints = { @UniqueConstraint(columnNames = { "status_name" }) })
@NamedQueries( {
// , uniqueConstraints = { @UniqueConstraint(columnNames = { "status_name" }) })
@NamedQueries({
@NamedQuery(name = "EventStatus.findAll", query = "SELECT e FROM EventStatus e"),
@NamedQuery(name = "EventStatus.findByStatusName", query = "SELECT e FROM EventStatus e WHERE e.name = :name") })
public class EventStatus implements ModelInterface {
public class EventStatus extends GenericEntity {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "event_status_id", nullable = false)
private Integer id;
@Column(name = "status_name", nullable = false, unique=true)
@Column(name = "status_name", nullable = false, unique = true)
private String name;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "status")
private List<LanEvent> events;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
public EventStatus() {
}
public EventStatus(String name) {
this.name = name;
}
public String getName() {
return name;
......@@ -66,64 +48,4 @@ public class EventStatus implements ModelInterface {
this.events = eventList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof EventStatus)) {
return false;
}
EventStatus other = (EventStatus) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.EventStatus[id=" + getId() + "]";
}
/**
* @return the id
*/
@Override
public Integer getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(Integer id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
}
......@@ -112,11 +112,6 @@ public class FoodWave extends GenericEventChild {
this.accountEvents = accountEventList;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.FoodWave[id=" + getId() + "]";
}
public void setTemplate(FoodWaveTemplate template) {
this.template = template;
}
......
......@@ -70,11 +70,6 @@ public class FoodWaveTemplate extends GenericEventChild {
this.description = templateDescription;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.FoodWaveTemplate[id=" + getId() + "]";
}
/**
* @return the products
*/
......
......@@ -5,21 +5,11 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import javax.persistence.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.utilities.PasswordFunctions;
@MappedSuperclass
public class GenericEntity implements ModelInterface {
public class GenericEntity extends EntityEquals implements ModelInterface {
private static final Logger logger = LoggerFactory.getLogger(GenericEntity.class);
/**
*
*/
private static final long serialVersionUID = -9041737052951021560L;
@Id
@Column(name = "id", nullable = false)
......@@ -31,38 +21,6 @@ public class GenericEntity implements ModelInterface {
private int jpaVersionField = 0;
@Override
public final boolean equals(Object object) {
if (!this.getClass().equals(object.getClass())) {
logger.debug("Classes dont match {} {}", getClass(), object.getClass());
return false;
}
GenericEntity other = (GenericEntity) object;
if (tempId != null && tempId.equals(other.tempId)) {
return true;
}
if (this.id == null) {
if (other.id != null) {
return false;
}
logger.debug("Ids are null. Resorting to randomidcheck!");
return getRandomId().equals(other.tempId);
}
return this.id.equals(other.id);
}
@Transient
private String tempId;
private String getRandomId() {
if (tempId == null) {
tempId = PasswordFunctions.generateRandomString(10);
}
return tempId;
}
@Override
public final int getJpaVersionField() {
return jpaVersionField;
}
......@@ -73,16 +31,11 @@ public class GenericEntity implements ModelInterface {
}
@Override
public final int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : getRandomId().hashCode());
return hash;
}
public Integer getId() {
return id;
}
@Override
public void setId(Integer id) {
this.id = id;
}
......
......@@ -3,21 +3,11 @@ package fi.insomnia.bortal.model;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import javax.persistence.Version;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.utilities.PasswordFunctions;
@MappedSuperclass
public abstract class GenericEventChild implements EventChildInterface {
public abstract class GenericEventChild extends EntityEquals implements EventChildInterface {
private static final Logger logger = LoggerFactory.getLogger(GenericEventChild.class);
/**
*
*/
private static final long serialVersionUID = -9041737052951021560L;
@EmbeddedId
private EventPk id;
......@@ -38,38 +28,6 @@ public abstract class GenericEventChild implements EventChildInterface {
}
@Override
public boolean equals(Object object) {
if (!this.getClass().equals(object.getClass())) {
logger.debug("Classes dont match {} {}", getClass(), object.getClass());
return false;
}
GenericEventChild other = (GenericEventChild) object;
if (tempId != null && tempId.equals(other.tempId)) {
return true;
}
if (this.id == null) {
if (other.id != null) {
return false;
}
logger.debug("Ids are null. Resorting to randomidcheck!");
return getRandomId().equals(other.tempId);
}
return this.id.equals(other.id);
}
@Transient
private String tempId;
private String getRandomId() {
if (tempId == null) {
tempId = PasswordFunctions.generateRandomString(10);
}
return tempId;
}
@Override
public final EventPk getId() {
return id;
}
......@@ -89,11 +47,4 @@ public abstract class GenericEventChild implements EventChildInterface {
this.jpaVersionField = jpaVersionField;
}
@Override
public final int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : getRandomId().hashCode());
return hash;
}
}
......@@ -62,7 +62,7 @@ public class GroupMembership extends GenericEventChild {
@OneToOne(optional = false)
private Place placeReservation;
@JoinColumn(name = "user_id", referencedColumnName = "user_id")
@JoinColumn(name = "user_id", referencedColumnName = "id")
@ManyToOne
private User user;
......@@ -128,13 +128,6 @@ public class GroupMembership extends GenericEventChild {
this.user = usersId;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.GroupMembership[id=" + getId() + "]";
}
/**
* @return the enteredEvent
*/
......
......@@ -10,9 +10,6 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
......@@ -23,7 +20,6 @@ import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
/**
*
......@@ -36,18 +32,13 @@ import javax.persistence.Version;
@NamedQuery(name = "LanEvent.findByEndTime", query = "SELECT e FROM LanEvent e WHERE e.endTime = :endTime"),
@NamedQuery(name = "LanEvent.findByName", query = "SELECT e FROM LanEvent e WHERE e.name = :name"),
@NamedQuery(name = "LanEvent.findByReferer", query = "SELECT e FROM LanEvent e WHERE e.referer = :referer") })
public class LanEvent implements ModelInterface {
public class LanEvent extends GenericEntity {
/**
*
*/
private static final long serialVersionUID = 179811358211927126L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "event_id", nullable = false)
private Integer id;
@Column(name = "start_time")
@Temporal(TemporalType.TIMESTAMP)
private Calendar startTime;
......@@ -56,10 +47,10 @@ public class LanEvent implements ModelInterface {
@Temporal(TemporalType.TIMESTAMP)
private Calendar endTime;
@Column(name = "name", nullable = false, unique=true)
@Column(name = "name", nullable = false, unique = true)
private String name;
@Column(name = "referer", unique=true, nullable=true)
@Column(name = "referer", unique = true, nullable = true)
private String referer;
/**
......@@ -70,11 +61,11 @@ public class LanEvent implements ModelInterface {
@Column(nullable = false)
private int nextBillNumber = 1;
@JoinColumn(name = "event_organiser_id", referencedColumnName = "event_organiser_id", nullable = false, updatable = false)
@JoinColumn(name = "event_organiser_id", referencedColumnName = "id", nullable = false, updatable = false)
@ManyToOne(optional = false)
private EventOrganiser organiser;
@JoinColumn(name = "event_status_id", referencedColumnName = "event_status_id", nullable = false)
@JoinColumn(name = "event_status_id", referencedColumnName = "id", nullable = false)
@ManyToOne(optional = false)
private EventStatus status;
......@@ -83,7 +74,7 @@ public class LanEvent implements ModelInterface {
@JoinColumns({
@JoinColumn(name = "default_role_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@JoinColumn(name = "id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@OneToOne
private Role defaultRole;
......@@ -99,10 +90,6 @@ public class LanEvent implements ModelInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "event")
private List<Role> roles;
@Version
@Column(nullable = true)
private int jpaVersionField = 0;
@OneToMany(mappedBy = "event")
private List<Bill> bills;
......@@ -192,67 +179,6 @@ public class LanEvent implements ModelInterface {
this.roles = roleList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof LanEvent)) {
return false;
}
LanEvent other = (LanEvent) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.Event[eventsId=" + getId() + "]";
}
/**
* @return the id
*/
@Override
public Integer getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(Integer id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
/**
* @return the bills
*/
......
......@@ -7,28 +7,24 @@ package fi.insomnia.bortal.model;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
/**
*
*/
@Entity
@Table(name = "locations")
@NamedQueries( {
@NamedQueries({
@NamedQuery(name = "Location.findAll", query = "SELECT l FROM Location l"),
@NamedQuery(name = "Location.findByLocationName", query = "SELECT l FROM Location l WHERE l.name = :name") })
public class Location implements EventChildInterface {
public class Location extends GenericEventChild {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Column(name = "location_name", nullable = false)
private String name;
......@@ -39,19 +35,16 @@ public class Location implements EventChildInterface {
@OneToMany(mappedBy = "currentLocation")
private List<PrintedCard> printedCardsAtLocation;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
public Location() {
super();
}
public Location(LanEvent event) {
this.id = new EventPk(event);
super(event);
}
public Location(LanEvent event, String name) {
this(event);
super(event);
this.name = name;
}
......@@ -79,64 +72,4 @@ public class Location implements EventChildInterface {
this.printedCardsAtLocation = printedCardList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof Location)) {
return false;
}
Location other = (Location) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.Location[id=" + getId() + "]";
}
/**
* @return the id
*/
@Override
public EventPk getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(EventPk id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
}
......@@ -55,7 +55,7 @@ public class LogEntry implements ModelInterface {
@ManyToOne(optional = false)
private LogEntryType type;
@JoinColumn(name = "user_id", referencedColumnName = "user_id")
@JoinColumn(name = "user_id", referencedColumnName = "id")
@ManyToOne
private User user;
......
......@@ -9,34 +9,27 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
/**
*
*/
@Entity
@Table(name = "event_log_types") //, uniqueConstraints = { @UniqueConstraint(columnNames = { "events_pk_id", "type_name" }) })
@NamedQueries( {
@Table(name = "event_log_types")
// , uniqueConstraints = { @UniqueConstraint(columnNames = { "events_pk_id",
// "type_name" }) })
@NamedQueries({
@NamedQuery(name = "LogEntryType.findAll", query = "SELECT l FROM LogEntryType l"),
@NamedQuery(name = "LogEntryType.findByName", query = "SELECT l FROM LogEntryType l WHERE l.name = :name"),
@NamedQuery(name = "LogEntryType.findByDescription", query = "SELECT l FROM LogEntryType l WHERE l.description = :description") })
public class LogEntryType implements ModelInterface {
public class LogEntryType extends GenericEntity {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Integer id;
/**
* Do not change this.. log entries are added to this field..
*/
......@@ -53,10 +46,6 @@ public class LogEntryType implements ModelInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "type")
private List<LogEntry> logEntries;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
/**
* Admins can change the loglevel of EntryTypes to receive eg. email for
* certain entry types.
......@@ -82,67 +71,6 @@ public class LogEntryType implements ModelInterface {
this.logEntries = logEntryList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof LogEntryType)) {
return false;
}
LogEntryType other = (LogEntryType) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.LogEntryType[id=" + getId() + "]";
}
/**
* @return the id
*/
@Override
public Integer getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(Integer id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
public void setName(String name) {
this.name = name;
}
......
......@@ -7,7 +7,6 @@ package fi.insomnia.bortal.model;
import java.util.Calendar;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
......@@ -18,7 +17,6 @@ import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
/**
*
......@@ -26,7 +24,7 @@ import javax.persistence.Version;
*/
@Entity
@Table(name = "news")
@NamedQueries( {
@NamedQueries({
@NamedQuery(name = "News.findAll", query = "SELECT n FROM News n"),
@NamedQuery(name = "News.findByTitle", query = "SELECT n FROM News n WHERE n.title = :title"),
......@@ -35,17 +33,15 @@ import javax.persistence.Version;
@NamedQuery(name = "News.findByPublish", query = "SELECT n FROM News n WHERE n.publish = :publish"),
@NamedQuery(name = "News.findByExpire", query = "SELECT n FROM News n WHERE n.expire = :expire"),
@NamedQuery(name = "News.findByPriority", query = "SELECT n FROM News n WHERE n.priority = :priority") })
public class News implements EventChildInterface {
public class News extends GenericEventChild {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
private static final long serialVersionUID = 498925968565236275L;
@Column(name = "title", nullable = false)
private String title;
@Lob
@Column(name = "body")
@Column(name = "body", nullable = false)
private String body;
@Lob
......@@ -63,25 +59,18 @@ public class News implements EventChildInterface {
@Column(name = "priority", nullable = false)
private int priority;
@JoinColumns( {
@JoinColumns({
@JoinColumn(name = "news_group_id", referencedColumnName = "id", nullable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne(optional = false)
private NewsGroup group;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
public News() {
}
public News(LanEvent event) {
this.id = new EventPk(event);
super();
}
public News(LanEvent event, String title, int priority) {
this(event);
super(event);
this.title = title;
this.priority = priority;
}
......@@ -142,64 +131,4 @@ public class News implements EventChildInterface {
this.group = newsGroupsId;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof News)) {
return false;
}
News other = (News) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.News[id=" + getId() + "]";
}
/**
* @return the id
*/
@Override
public EventPk getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(EventPk id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
}
......@@ -8,7 +8,6 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
......@@ -19,7 +18,6 @@ import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Version;
/**
*
......@@ -27,18 +25,15 @@ import javax.persistence.Version;
*/
@Entity
@Table(name = "news_groups")
@NamedQueries( {
@NamedQueries({
@NamedQuery(name = "NewsGroup.findAll", query = "SELECT n FROM NewsGroup n"),
@NamedQuery(name = "NewsGroup.findByName", query = "SELECT n FROM NewsGroup n WHERE n.name = :name"),
@NamedQuery(name = "NewsGroup.findByDescription", query = "SELECT n FROM NewsGroup n WHERE n.description = :description"),
@NamedQuery(name = "NewsGroup.findByPriority", query = "SELECT n FROM NewsGroup n WHERE n.priority = :priority") })
public class NewsGroup implements EventChildInterface {
public class NewsGroup extends GenericEventChild {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Column(name = "group_name", nullable = false)
private String name;
......@@ -61,20 +56,16 @@ public class NewsGroup implements EventChildInterface {
@JoinColumn(name = "event_id", referencedColumnName = "event_id") })
private List<Role> roles;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
public NewsGroup() {
super();
}
public NewsGroup(LanEvent event) {
this.id = new EventPk(event);
super(event);
}
public NewsGroup(LanEvent event, String groupName, int priority) {
this(event);
super(event);
this.name = groupName;
this.priority = priority;
}
......@@ -103,7 +94,7 @@ public class NewsGroup implements EventChildInterface {
this.priority = priority;
}
@OrderBy("id")
@OrderBy("priority")
public List<News> getNews() {
return news;
}
......@@ -112,68 +103,6 @@ public class NewsGroup implements EventChildInterface {
this.news = newsList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof NewsGroup)) {
return false;
}
NewsGroup other = (NewsGroup) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.NewsGroup[newsGroupsId=" + getId()
+ "]";
}
/**
* @return the id
*/
@Override
public EventPk getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(EventPk id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
public void setRoles(List<Role> roles) {
this.roles = roles;
}
......
......@@ -72,7 +72,7 @@ public class Place extends GenericEventChild {
* Which group has bought the place
*/
@JoinColumns({
@JoinColumn(name = "group_id", referencedColumnName = "id", nullable=false),
@JoinColumn(name = "group_id", referencedColumnName = "id", nullable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne
private PlaceGroup group;
......@@ -100,11 +100,12 @@ public class Place extends GenericEventChild {
* Who is the current currentUser (mapped with code printed on the place) of
* the place. Used in Vectorama currentUser tracking.
*/
@JoinColumn(name = "current_user_id", referencedColumnName = "user_id")
@JoinColumn(name = "current_user_id", referencedColumnName = "id")
@ManyToOne
private User currentUser;
public Place() {
super();
}
public Place(EventMap eventMap) {
......@@ -201,11 +202,6 @@ public class Place extends GenericEventChild {
this.currentUser = usersId;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.Place[id=" + getId() + "]";
}
public void setPlaceReserver(GroupMembership placeReserver) {
this.placeReserver = placeReserver;
}
......
......@@ -10,7 +10,6 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
......@@ -22,7 +21,6 @@ import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
/**
*
......@@ -39,11 +37,9 @@ import javax.persistence.Version;
@NamedQuery(name = "PlaceGroup.findByName", query = "SELECT p FROM PlaceGroup p WHERE p.name = :name"),
@NamedQuery(name = "PlaceGroup.findByActive", query = "SELECT p FROM PlaceGroup p WHERE p.active = :active"),
@NamedQuery(name = "PlaceGroup.findByDetails", query = "SELECT p FROM PlaceGroup p WHERE p.details = :details") })
public class PlaceGroup implements EventChildInterface {
public class PlaceGroup extends GenericEventChild {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Column(name = "group_created", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
......@@ -66,7 +62,7 @@ public class PlaceGroup implements EventChildInterface {
@Column(name = "group_details")
private String details;
@JoinColumn(name = "creator_user_id", referencedColumnName = "user_id")
@JoinColumn(name = "creator_user_id", referencedColumnName = "id")
@ManyToOne
private User creator;
......@@ -77,17 +73,6 @@ public class PlaceGroup implements EventChildInterface {
@OrderBy("name")
private List<Place> places;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
public PlaceGroup() {
}
public PlaceGroup(LanEvent event) {
this.id = new EventPk(event);
}
public PlaceGroup(LanEvent event, Calendar groupCreated, Calendar groupEdited,
boolean groupActive) {
this(event);
......@@ -96,6 +81,14 @@ public class PlaceGroup implements EventChildInterface {
this.active = groupActive;
}
public PlaceGroup(LanEvent event) {
super(event);
}
public PlaceGroup() {
super();
}
public Calendar getCreated() {
return created;
}
......@@ -168,64 +161,4 @@ public class PlaceGroup implements EventChildInterface {
this.places = placeList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof PlaceGroup)) {
return false;
}
PlaceGroup other = (PlaceGroup) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.PlaceGroup[id=" + getId() + "]";
}
/**
* @return the id
*/
@Override
public EventPk getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(EventPk id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
}
......@@ -10,15 +10,15 @@ import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Entity
@Table(name = "poll_answer")
public class PollAnswer extends GenericEventChild implements Serializable {
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(PollAnswer.class);
/**
*
*/
private static final long serialVersionUID = -9170023819401407461L;
@Lob
@Column(name = "answer_text", nullable = true)
private String answerText = "";
......@@ -33,7 +33,7 @@ public class PollAnswer extends GenericEventChild implements Serializable {
private PossibleAnswer choice;
@ManyToOne
@JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false)
@JoinColumn(name = "user_id", referencedColumnName = "id", nullable = false)
private User user;
public PollAnswer() {
......@@ -77,22 +77,4 @@ public class PollAnswer extends GenericEventChild implements Serializable {
return answerBoolean;
}
@Override
public boolean equals(Object p) {
boolean ret = false;
if (p != null && p instanceof PollAnswer) {
PollAnswer ans = (PollAnswer) p;
if (this.getId() != null && ans.getId() != null) {
ret = super.equals(p);
} else {
if (this.getChoice() != null && this.getChoice().equals(ans.getChoice())) {
ret = true;
}
}
}
logger.debug("Equalling {} {}, ret: {}", new Object[] { this, p, ret });
return ret;
}
}
......@@ -11,25 +11,21 @@ import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Basic;
@Entity
@Table(name = "possible_answer")
public class PossibleAnswer extends GenericEventChild {
public PossibleAnswer() {
super();
}
public PossibleAnswer(PollQuestion pq, String answer) {
super(pq.getId());
this.answer = answer;
this.question = pq;
}
/**
*
*/
public PossibleAnswer() {
super();
}
private static final long serialVersionUID = 1686553713211996800L;
@Column(nullable = false)
private String answer;
......
......@@ -26,9 +26,6 @@ import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
*/
......@@ -74,7 +71,7 @@ public class PrintedCard extends GenericEventChild {
@ManyToOne
private Location currentLocation;
@JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false)
@JoinColumn(name = "user_id", referencedColumnName = "id", nullable = false)
@ManyToOne(optional = false)
private User user;
......@@ -84,19 +81,20 @@ public class PrintedCard extends GenericEventChild {
@ManyToOne(optional = false)
private CardTemplate template;
public PrintedCard() {
}
public PrintedCard(LanEvent event) {
setId(new EventPk(event));
}
public PrintedCard(LanEvent event, Calendar printTime, boolean cardEnabled) {
this(event);
this.printTime = printTime;
this.enabled = cardEnabled;
}
public PrintedCard() {
super();
}
public PrintedCard(LanEvent event) {
super(event);
}
public Calendar getPrintTime() {
return printTime;
}
......@@ -153,11 +151,6 @@ public class PrintedCard extends GenericEventChild {
this.user = usersId;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.PrintedCard[id=" + getId() + "]";
}
public void setTemplate(CardTemplate template) {
this.template = template;
}
......@@ -177,7 +170,6 @@ public class PrintedCard extends GenericEventChild {
@Transient
private Integer gamepoints = null;
private static final Logger logger = LoggerFactory.getLogger(PrintedCard.class);
public static final Comparator<PrintedCard> GAMEPOINT_COMPARATOR = new Comparator<PrintedCard>() {
@Override
......
......@@ -9,7 +9,6 @@ import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
......@@ -21,7 +20,6 @@ import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
/**
*
......@@ -168,11 +166,6 @@ public class Product extends GenericEventChild {
this.accountEvents = accountEventList;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.Product[productsId=" + getId() + "]";
}
public void setDiscounts(List<Discount> discounts) {
this.discounts = discounts;
}
......
......@@ -8,7 +8,6 @@ import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
......@@ -18,9 +17,7 @@ import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Version;
import javax.persistence.UniqueConstraint;
import static javax.persistence.CascadeType.ALL;
/**
*
......@@ -34,13 +31,17 @@ import static javax.persistence.CascadeType.ALL;
@NamedQuery(name = "Reader.findByDescription", query = "SELECT r FROM Reader r WHERE r.description = :description") })
public class Reader extends GenericEventChild {
public Reader(LanEvent ev, String ident) {
this(ev);
this.identification = ident;
}
public Reader() {
super();
}
public Reader(LanEvent ev, String ident) {
public Reader(LanEvent ev) {
super(ev);
this.identification = ident;
}
@Column(nullable = false)
......@@ -73,7 +74,7 @@ public class Reader extends GenericEventChild {
private EventMap eventMap;
@ManyToOne
@JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false)
@JoinColumn(name = "event_id", referencedColumnName = "id", updatable = false, insertable = false)
private LanEvent event;
@Column(name = "map_x")
......@@ -108,11 +109,6 @@ public class Reader extends GenericEventChild {
this.location = locationsId;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.Reader[id=" + getId() + "]";
}
/**
* @return the mapX
*/
......
......@@ -55,16 +55,21 @@ public class ReaderEvent extends GenericEventChild {
@ManyToOne(optional = false, cascade = ALL)
private Reader reader;
public ReaderEvent() {
}
public ReaderEvent(LanEvent event, Calendar eventTime, PrintedCard card, Reader reader) {
super(event);
this(event);
this.time = eventTime;
this.printedCard = card;
this.reader = reader;
}
public ReaderEvent() {
super();
}
public ReaderEvent(LanEvent event) {
super(event);
}
public Calendar getTime() {
return time;
}
......@@ -97,11 +102,6 @@ public class ReaderEvent extends GenericEventChild {
this.reader = readersId;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.ReaderEvent[id=" + getId() + "]";
}
public void setGamePoint(Integer gamePoint) {
this.gamePoint = gamePoint;
}
......
......@@ -80,10 +80,11 @@ public class Role extends GenericEventChild {
private List<NewsGroup> newsGroups;
@ManyToOne
@JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false)
@JoinColumn(name = "event_id", referencedColumnName = "id", updatable = false, insertable = false)
private LanEvent event;
public Role() {
super();
}
public Role(LanEvent event) {
......@@ -120,11 +121,6 @@ public class Role extends GenericEventChild {
this.cardTemplate = cardTemplatesId;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.Role[id=" + getId() + "]";
}
public void setUsers(List<User> users) {
this.users = users;
}
......@@ -184,4 +180,8 @@ public class Role extends GenericEventChild {
public List<Place> getPlacesProvide() {
return placesProvide;
}
public void setEvent(LanEvent event) {
this.event = event;
}
}
......@@ -5,7 +5,6 @@
package fi.insomnia.bortal.model;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
......@@ -14,7 +13,6 @@ import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
import org.eclipse.persistence.annotations.ConversionValue;
import org.eclipse.persistence.annotations.Convert;
......@@ -43,13 +41,10 @@ import fi.insomnia.bortal.enums.Permission;
@ConversionValue(dataValue = "GAME", objectValue = "GAME"),
@ConversionValue(dataValue = "POLL", objectValue = "POLL")
})
public class RoleRight implements EventChildInterface {
public class RoleRight extends GenericEventChild {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Column(name = "read_permission", nullable = false)
private boolean read = false;
......@@ -73,16 +68,13 @@ public class RoleRight implements EventChildInterface {
@ManyToOne(optional = false)
private Role role;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
public RoleRight() {
super();
}
public RoleRight(Role role) {
this.id = new EventPk(role.getEvent());
this(new EventPk(role.getEvent()));
this.role = role;
}
......@@ -94,6 +86,10 @@ public class RoleRight implements EventChildInterface {
this.execute = execute;
}
public RoleRight(EventPk eventPk) {
super(eventPk);
}
public boolean isRead() {
return read;
}
......@@ -118,67 +114,6 @@ public class RoleRight implements EventChildInterface {
this.role = rolesId;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof RoleRight)) {
return false;
}
RoleRight other = (RoleRight) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.RoleRight[roleRights=" + getId() + "]";
}
/**
* @return the id
*/
@Override
public EventPk getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(EventPk id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
public void setExecute(boolean execute) {
this.execute = execute;
}
......
......@@ -14,9 +14,6 @@ import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
......@@ -29,7 +26,6 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
......@@ -55,14 +51,12 @@ import fi.insomnia.bortal.utilities.PasswordFunctions;
@NamedQueries({
@NamedQuery(name = "User.findAll", query = "SELECT u FROM User u order by u.created"),
@NamedQuery(name = "User.findByLogin", query = "SELECT u FROM User u WHERE u.login = :login") })
public class User implements ModelInterface {
public class User extends GenericEntity {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "user_id", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
*
*/
private static final long serialVersionUID = -1632200627103418206L;
@Column(name = "created", nullable = false)
// , columnDefinition = "timestamptz default now()")
......@@ -109,6 +103,7 @@ public class User implements ModelInterface {
private String phone = "";
@OneToOne
@JoinColumn(name = "current_image_id", referencedColumnName = "id")
private UserImage currentImage;
@Convert("gender")
......@@ -135,7 +130,7 @@ public class User implements ModelInterface {
@JoinTable(name = "role_memberships", inverseJoinColumns = {
@JoinColumn(name = "role_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id") },
joinColumns = { @JoinColumn(name = "user_id", referencedColumnName = "user_id") })
joinColumns = { @JoinColumn(name = "user_id", referencedColumnName = "id") })
private List<Role> roles = new ArrayList<Role>();
@OneToMany(mappedBy = "user")
......@@ -180,10 +175,6 @@ public class User implements ModelInterface {
@OrderBy("id.id")
private List<AccountEvent> soldItems;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
@OneToMany(mappedBy = "admin")
private List<EventOrganiser> eventOrganiser;
......@@ -201,13 +192,6 @@ public class User implements ModelInterface {
return ret;
}
public User() {
}
public User(Integer usersId) {
this.id = usersId;
}
public List<Vote> getVotes() {
return votes;
}
......@@ -216,14 +200,6 @@ public class User implements ModelInterface {
this.votes = votes;
}
public User(Integer usersId, Calendar created, boolean active, String lastname, String firstnames) {
this.id = usersId;
this.created = created;
this.active = active;
this.lastname = lastname;
this.firstnames = firstnames;
}
public Calendar getCreated() {
return created;
}
......@@ -428,67 +404,6 @@ public class User implements ModelInterface {
this.bills = billList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof User)) {
return false;
}
User other = (User) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.User[id=" + getId() + "]";
}
/**
* @return the id
*/
@Override
public Integer getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(Integer id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
public void setRoles(List<Role> roles) {
this.roles = roles;
}
......
......@@ -8,9 +8,6 @@ import java.util.Calendar;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
......@@ -18,29 +15,26 @@ import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
/**
*
*/
@Entity
@Table(name = "user_images")
//@NamedQueries({
// @NamedQueries({
// @NamedQuery(name = "UserImage.findAll", query = "SELECT u FROM UserImage u"),
//
// @NamedQuery(name = "UserImage.findByName", query = "SELECT u FROM UserImage u WHERE u.name = :name"),
// @NamedQuery(name = "UserImage.findByDescription", query = "SELECT u FROM UserImage u WHERE u.description = :description"),
// @NamedQuery(name = "UserImage.findByMimeType", query = "SELECT u FROM UserImage u WHERE u.mimeType = :mimeType") })
public class UserImage implements ModelInterface {
// @NamedQuery(name = "UserImage.findByName", query =
// "SELECT u FROM UserImage u WHERE u.name = :name"),
// @NamedQuery(name = "UserImage.findByDescription", query =
// "SELECT u FROM UserImage u WHERE u.description = :description"),
// @NamedQuery(name = "UserImage.findByMimeType", query =
// "SELECT u FROM UserImage u WHERE u.mimeType = :mimeType") })
public class UserImage extends GenericEntity {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_image_id", nullable = false)
private Integer id;
@Column(name="uploaded",nullable=false)
@Column(name = "uploaded", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Calendar uploaded = Calendar.getInstance();
......@@ -58,18 +52,15 @@ public class UserImage implements ModelInterface {
@Column(name = "image_data")
private byte[] imageData;
@JoinColumn(name = "user_id", referencedColumnName = "user_id")
@JoinColumn(name = "user_id", referencedColumnName = "id")
@ManyToOne
private User user;
@OneToOne(mappedBy = "currentImage")
private User defaultImage;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
public UserImage() {
super();
}
public UserImage(User user) {
......@@ -108,67 +99,6 @@ public class UserImage implements ModelInterface {
this.imageData = imageData;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof UserImage)) {
return false;
}
UserImage other = (UserImage) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.UserImage[id=" + getId() + "]";
}
/**
* @return the id
*/
@Override
public Integer getId() {
return id;
}
/**
* @param id
* the id to set
*/
@Override
public void setId(Integer id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
/**
* @return the user
*/
......
......@@ -7,7 +7,6 @@ package fi.insomnia.bortal.model;
import java.util.Calendar;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
......@@ -18,8 +17,6 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
/**
* A vote for a compo entry
......@@ -30,11 +27,9 @@ import javax.persistence.Version;
@NamedQuery(name = "Vote.findAll", query = "SELECT v FROM Vote v"),
@NamedQuery(name = "Vote.findByScore", query = "SELECT v FROM Vote v WHERE v.score = :score"),
@NamedQuery(name = "Vote.findByTime", query = "SELECT v FROM Vote v WHERE v.time = :time") })
public class Vote implements EventChildInterface {
public class Vote extends GenericEventChild {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Column(name = "score")
private Integer score;
......@@ -49,34 +44,21 @@ public class Vote implements EventChildInterface {
@ManyToOne(optional = false)
private CompoEntry compoEntry;
@JoinColumn(name = "voter_user_id", referencedColumnName = "user_id", nullable = false)
@JoinColumn(name = "voter_user_id", referencedColumnName = "id", nullable = false)
@ManyToOne(optional = false)
private User voter;
@Version
@Column(nullable = false)
private int jpaVersionField = 0;
public Vote() {
}
public Vote(LanEvent event) {
this.id = new EventPk(event);
}
public Vote(LanEvent event, Calendar voteTime) {
this(event);
this.time = voteTime;
}
@Override
public EventPk getId() {
return id;
public Vote(LanEvent event) {
super();
}
@Override
public void setId(EventPk votesId) {
this.id = votesId;
public Vote() {
super();
}
public Integer getScore() {
......@@ -95,50 +77,6 @@ public class Vote implements EventChildInterface {
this.time = voteTime;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof Vote)) {
return false;
}
Vote other = (Vote) object;
if ((this.id == null && other.id != null)
|| (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.Vote[id=" + id + "]";
}
/**
* @return the jpaVersionField
*/
@Override
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
@Override
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
/**
* @return the compoEntry
*/
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!