Commit f4074e4d by Tuomas Riihimäki

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

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