Commit d091843b by Juho Juopperi

model reference fixes

1 parent 5da87cc4
Showing with 389 additions and 532 deletions
...@@ -11,7 +11,7 @@ import fi.insomnia.bortal.model.LogEntryType; ...@@ -11,7 +11,7 @@ import fi.insomnia.bortal.model.LogEntryType;
@Stateless @Stateless
@LocalBean @LocalBean
public class LogEntryTypeFacade extends EventChildGenericFacade<LogEntryType> { public class LogEntryTypeFacade extends GenericFacade<Integer, LogEntryType> {
@PersistenceContext @PersistenceContext
private EntityManager em; private EntityManager em;
......
...@@ -8,7 +8,7 @@ import fi.insomnia.bortal.model.UserImage; ...@@ -8,7 +8,7 @@ import fi.insomnia.bortal.model.UserImage;
@Stateless @Stateless
@LocalBean @LocalBean
public class UserImageFacade extends EventChildGenericFacade<UserImage> { public class UserImageFacade extends GenericFacade<Integer, UserImage> {
@PersistenceContext @PersistenceContext
private EntityManager em; private EntityManager em;
......
...@@ -27,23 +27,23 @@ import javax.persistence.Version; ...@@ -27,23 +27,23 @@ import javax.persistence.Version;
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "AccessRight.findAll", query = "SELECT a FROM AccessRight a"), @NamedQuery(name = "AccessRight.findAll", query = "SELECT a FROM AccessRight a"),
@NamedQuery(name = "AccessRight.findByName", query = "SELECT a FROM AccessRight a WHERE a.name = :name") }) @NamedQuery(name = "AccessRight.findByName", query = "SELECT a FROM AccessRight a WHERE a.name = :name") })
public class AccessRight implements ModelInterface<Integer>{ public class AccessRight implements ModelInterface<Integer> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* AccessRight is global entity, and thus does not have a reference to Event. * AccessRight is global entity, and thus does not have a reference to
* Event.
*/ */
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "access_rights_id", nullable = false) @Column(name = "access_right_id", nullable = false)
private Integer id; private Integer id;
/** /**
* Name of the access right. Code finds rights by this name, so * Name of the access right. Code finds rights by this name, so this field
* this field should not be changed under any circumstances. * should not be changed under any circumstances.
*/ */
@Column(name = "right_name", nullable = false, updatable=false) @Column(name = "right_name", nullable = false, updatable = false)
private String name; private String name;
/** /**
...@@ -59,11 +59,9 @@ public class AccessRight implements ModelInterface<Integer>{ ...@@ -59,11 +59,9 @@ public class AccessRight implements ModelInterface<Integer>{
@OneToMany(mappedBy = "accessRight") @OneToMany(mappedBy = "accessRight")
private List<RoleRight> roleRights; private List<RoleRight> roleRights;
@Override @Override
public Integer getId() { public Integer getId() {
return id; return id;
} }
@Override @Override
...@@ -78,20 +76,15 @@ public class AccessRight implements ModelInterface<Integer>{ ...@@ -78,20 +76,15 @@ public class AccessRight implements ModelInterface<Integer>{
public AccessRight() { public AccessRight() {
} }
public AccessRight(Integer accessRightsId) { public AccessRight(String name) {
this.id = accessRightsId; this.name = name;
}
public AccessRight(Integer accessRightsId, String accessRight) {
this.id = accessRightsId;
this.name = accessRight;
} }
public String getAccessRight() { public String getName() {
return name; return name;
} }
public void setAccessRight(String accessRight) { public void setName(String accessRight) {
this.name = accessRight; this.name = accessRight;
} }
......
...@@ -30,7 +30,7 @@ import javax.persistence.Version; ...@@ -30,7 +30,7 @@ import javax.persistence.Version;
*/ */
@Entity @Entity
@Table(name = "account_events") @Table(name = "account_events")
@NamedQueries({ @NamedQueries( {
@NamedQuery(name = "AccountEvent.findAll", query = "SELECT a FROM AccountEvent a"), @NamedQuery(name = "AccountEvent.findAll", query = "SELECT a FROM AccountEvent a"),
@NamedQuery(name = "AccountEvent.findByUnitPrice", query = "SELECT a FROM AccountEvent a WHERE a.unitPrice = :unitPrice"), @NamedQuery(name = "AccountEvent.findByUnitPrice", query = "SELECT a FROM AccountEvent a WHERE a.unitPrice = :unitPrice"),
@NamedQuery(name = "AccountEvent.findByUnits", query = "SELECT a FROM AccountEvent a WHERE a.units = :units"), @NamedQuery(name = "AccountEvent.findByUnits", query = "SELECT a FROM AccountEvent a WHERE a.units = :units"),
...@@ -51,7 +51,7 @@ public class AccountEvent implements EventChildInterface { ...@@ -51,7 +51,7 @@ public class AccountEvent implements EventChildInterface {
/** /**
* The units of the product, eg 1.345 (l), 5 (units) 888.32 (g).. * The units of the product, eg 1.345 (l), 5 (units) 888.32 (g)..
*/ */
@Column(name = "unit_count", nullable = false, precision = 24, scale = 4) @Column(name = "quantity", nullable = false, precision = 24, scale = 4)
private BigDecimal units; private BigDecimal units;
/** /**
...@@ -72,9 +72,9 @@ public class AccountEvent implements EventChildInterface { ...@@ -72,9 +72,9 @@ public class AccountEvent implements EventChildInterface {
* If this AccountEvent is a product in foodwace, this field is a reference * If this AccountEvent is a product in foodwace, this field is a reference
* to that foodwave. * to that foodwave.
*/ */
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "food_waves_id", referencedColumnName = "entity_id", updatable = false, insertable = false), @JoinColumn(name = "food_wave_id", referencedColumnName = "id"),
@JoinColumn(name = "food_waves_event_id", referencedColumnName = "events_pk_id", updatable = false, insertable = false) }) @JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false) })
@ManyToOne @ManyToOne
private FoodWave foodWave; private FoodWave foodWave;
...@@ -82,23 +82,23 @@ public class AccountEvent implements EventChildInterface { ...@@ -82,23 +82,23 @@ public class AccountEvent implements EventChildInterface {
* The product user has acquired and this this AccountEvent is a reference * The product user has acquired and this this AccountEvent is a reference
* to. * to.
*/ */
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "products_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "product_id", referencedColumnName = "id", nullable = false),
@JoinColumn(name = "products_event_id", referencedColumnName = "events_pk_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 Product product; private Product product;
/** /**
* The user that bought the products. * The user that bought the products.
*/ */
@JoinColumn(name = "users_id", referencedColumnName = "users_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", referencedColumnName = "users_id", nullable = false) @JoinColumn(name = "seller_user_id", referencedColumnName = "id")
@ManyToOne(optional = true) @ManyToOne(optional = true)
private User seller; private User seller;
...@@ -113,9 +113,9 @@ public class AccountEvent implements EventChildInterface { ...@@ -113,9 +113,9 @@ public class AccountEvent implements EventChildInterface {
* When user has paid a bill a Account event for product "Credit" is created * When user has paid a bill a Account event for product "Credit" is created
* and reference to that bill is here.. * and reference to that bill is here..
*/ */
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "bill_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "bill_id", referencedColumnName = "id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "bill_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) }) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@OneToOne @OneToOne
private Bill bill; private Bill bill;
...@@ -146,15 +146,15 @@ public class AccountEvent implements EventChildInterface { ...@@ -146,15 +146,15 @@ public class AccountEvent implements EventChildInterface {
public AccountEvent() { public AccountEvent() {
} }
public AccountEvent(EventPk accountEventsId) { public AccountEvent(Event event) {
this.id = accountEventsId; this.id = new EventPk(event);
} }
public AccountEvent(EventPk accountEventsId, BigDecimal unitPrice, public AccountEvent(Event event, BigDecimal unitPrice,
BigDecimal unitCount, Calendar eventTime) { BigDecimal quantity, Calendar eventTime) {
this.id = accountEventsId; this.id = new EventPk(event);
this.setUnitPrice(unitPrice); this.setUnitPrice(unitPrice);
this.setUnits(unitCount); this.setQuantity(quantity);
this.eventTime = eventTime; this.eventTime = eventTime;
} }
...@@ -258,11 +258,11 @@ public class AccountEvent implements EventChildInterface { ...@@ -258,11 +258,11 @@ public class AccountEvent implements EventChildInterface {
return unitPrice; return unitPrice;
} }
public void setUnits(BigDecimal units) { public void setQuantity(BigDecimal units) {
this.units = units; this.units = units;
} }
public BigDecimal getUnits() { public BigDecimal getQuantity() {
return units; return units;
} }
......
...@@ -25,13 +25,13 @@ import javax.persistence.TemporalType; ...@@ -25,13 +25,13 @@ import javax.persistence.TemporalType;
import javax.persistence.Version; import javax.persistence.Version;
/** /**
* The system can send bills to the users. * The system can send bills to the users. When user pays bill a AccountEvent
* When user pays bill a AccountEvent row is created for product whose price is +1 * row is created for product whose price is +1 and Bills paidDate is changed to
* and Bills paidDate is changed to not null. * not null.
*/ */
@Entity @Entity
@Table(name = "bills") @Table(name = "bills")
@NamedQueries({ @NamedQueries( {
@NamedQuery(name = "Bill.findAll", query = "SELECT b FROM Bill b"), @NamedQuery(name = "Bill.findAll", query = "SELECT b FROM Bill b"),
@NamedQuery(name = "Bill.findByDueDate", query = "SELECT b FROM Bill b WHERE b.dueDate = :dueDate"), @NamedQuery(name = "Bill.findByDueDate", query = "SELECT b FROM Bill b WHERE b.dueDate = :dueDate"),
@NamedQuery(name = "Bill.findByPaidDate", query = "SELECT b FROM Bill b WHERE b.paidDate = :paidDate"), @NamedQuery(name = "Bill.findByPaidDate", query = "SELECT b FROM Bill b WHERE b.paidDate = :paidDate"),
...@@ -60,6 +60,7 @@ public class Bill implements EventChildInterface { ...@@ -60,6 +60,7 @@ public class Bill implements EventChildInterface {
/** /**
* Reference number of the bill. * Reference number of the bill.
*
* @See http://www.fkl.fi/www/page/fk_www_1293 * @See http://www.fkl.fi/www/page/fk_www_1293
*/ */
@Column(name = "reference_number") @Column(name = "reference_number")
...@@ -79,38 +80,30 @@ public class Bill implements EventChildInterface { ...@@ -79,38 +80,30 @@ public class Bill implements EventChildInterface {
private List<BillLine> billLines; private List<BillLine> billLines;
/** /**
* When the bill is paid this AccountEvent is created and this is a reference * When the bill is paid this AccountEvent is created and this is a
* to that accountAction. * reference to that accountAction.
*/ */
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "account_event_id", referencedColumnName = "entity_id", updatable = false, insertable = false), @JoinColumn(name = "account_event_id", referencedColumnName = "id", updatable = false),
@JoinColumn(name = "account_event_event_id", referencedColumnName = "events_pk_id", updatable = false, insertable = false) }) @JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false) })
@OneToOne @OneToOne
private AccountEvent accountEvent; private AccountEvent accountEvent;
/** /**
* User who should pay this bill. * User who should pay this bill.
*/ */
@JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false) @JoinColumn(name = "user_id", referencedColumnName = "id", nullable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private User user; private User user;
/** /**
* Which event the bill is assigned to.
*/
@ManyToOne
@JoinColumn(name = "events_id", referencedColumnName = "events_id")
private Event event;
/**
* Commodity function to calculate the total price of the bill. * Commodity function to calculate the total price of the bill.
*
* @return The total sum of the bill ( unitPrice * units * vat ) * @return The total sum of the bill ( unitPrice * units * vat )
*/ */
public BigDecimal totalPrice() public BigDecimal totalPrice() {
{
BigDecimal total = BigDecimal.ZERO; BigDecimal total = BigDecimal.ZERO;
for(BillLine line: getBillLines()) for (BillLine line : getBillLines()) {
{
total = total.add(line.getLinePrice()); total = total.add(line.getLinePrice());
} }
return total; return total;
...@@ -118,13 +111,12 @@ public class Bill implements EventChildInterface { ...@@ -118,13 +111,12 @@ public class Bill implements EventChildInterface {
/** /**
* Commodity function to return the vatless price of the bill * Commodity function to return the vatless price of the bill
*
* @return The total VAT-less sum of the bill ( unitPrice * units ) * @return The total VAT-less sum of the bill ( unitPrice * units )
*/ */
public BigDecimal totalPriceVatless() public BigDecimal totalPriceVatless() {
{
BigDecimal total = BigDecimal.ZERO; BigDecimal total = BigDecimal.ZERO;
for(BillLine line: getBillLines()) for (BillLine line : getBillLines()) {
{
total = total.add(line.getLinePriceVatless()); total = total.add(line.getLinePriceVatless());
} }
return total; return total;
...@@ -147,8 +139,8 @@ public class Bill implements EventChildInterface { ...@@ -147,8 +139,8 @@ public class Bill implements EventChildInterface {
public Bill() { public Bill() {
} }
public Bill(EventPk billsId) { public Bill(Event event) {
this.id = billsId; this.id = new EventPk(event);
} }
public Calendar getDueDate() { public Calendar getDueDate() {
...@@ -243,19 +235,4 @@ public class Bill implements EventChildInterface { ...@@ -243,19 +235,4 @@ public class Bill implements EventChildInterface {
public int getJpaVersionField() { public int getJpaVersionField() {
return jpaVersionField; return jpaVersionField;
} }
/**
* @return the event
*/
public Event getEvent() {
return event;
}
/**
* @param event
* the event to set
*/
public void setEvent(Event event) {
this.event = event;
}
} }
...@@ -23,10 +23,10 @@ import javax.persistence.Version; ...@@ -23,10 +23,10 @@ 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"),
@NamedQuery(name = "BillLine.findByProduct", query = "SELECT b FROM BillLine b WHERE b.name = :name"), @NamedQuery(name = "BillLine.findByProduct", query = "SELECT b FROM BillLine b WHERE b.name = :name"),
@NamedQuery(name = "BillLine.findByUnits", query = "SELECT b FROM BillLine b WHERE b.units = :units"), @NamedQuery(name = "BillLine.findByUnits", query = "SELECT b FROM BillLine b WHERE b.units = :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 implements EventChildInterface {
...@@ -38,15 +38,15 @@ public class BillLine implements EventChildInterface { ...@@ -38,15 +38,15 @@ public class BillLine implements EventChildInterface {
/** /**
* Product name shown on the bill * Product name shown on the bill
*/ */
@Column(name = "name", nullable = false) @Column(name = "product_name", nullable = false)
private String name; private String name;
/** /**
* How many units the of the product has been purchased eg. 14 (Entrance * How many quantity the of the product has been purchased eg. 14 (Entrance
* tickets), 1.5 (l) eh.. something.. * tickets), 1.5 (l) eh.. something..
*/ */
@Column(name = "units", nullable = false, precision = 24, scale = 4) @Column(name = "quantity", nullable = false, precision = 24, scale = 4)
private BigDecimal units = BigDecimal.ZERO; private BigDecimal quantity = BigDecimal.ZERO;
/** /**
* How much one(1) unit of this product costs * How much one(1) unit of this product costs
...@@ -64,9 +64,9 @@ public class BillLine implements EventChildInterface { ...@@ -64,9 +64,9 @@ public class BillLine implements EventChildInterface {
/** /**
* Which bill this bill line belongs to * Which bill this bill line belongs to
*/ */
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "bills_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "bill_id", referencedColumnName = "id", nullable = false, updatable = false),
@JoinColumn(name = "bills_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) }) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne @ManyToOne
private Bill bill; private Bill bill;
...@@ -76,41 +76,41 @@ public class BillLine implements EventChildInterface { ...@@ -76,41 +76,41 @@ public class BillLine implements EventChildInterface {
/** /**
* Calculate the total price for the items on this line * Calculate the total price for the items on this line
*
* @return * @return
*/ */
public BigDecimal getLinePrice() public BigDecimal getLinePrice() {
{
BigDecimal vatMultiplicand = BigDecimal.ONE.add(getVat()); BigDecimal vatMultiplicand = BigDecimal.ONE.add(getVat());
return getLinePriceVatless().multiply(vatMultiplicand); return getLinePriceVatless().multiply(vatMultiplicand);
} }
/** /**
* Calculate the total VAT-less price for the items on this lin * Calculate the total VAT-less price for the items on this lin
*
* @return * @return
*/ */
public BigDecimal getLinePriceVatless() public BigDecimal getLinePriceVatless() {
{ return getUnitPrice().multiply(getQuantity());
return getUnitPrice().multiply(getUnits());
} }
public BillLine() { public BillLine() {
} }
public BillLine(EventPk billLinesId) { public BillLine(Bill bill) {
this.id = billLinesId; this.id = new EventPk(bill.getId().getEvent());
this.bill = bill;
} }
public BillLine(EventPk billLinesId, String product, BigDecimal units, public BillLine(Bill bill, String product, BigDecimal units,
BigDecimal unitPrice, BigDecimal vat) { BigDecimal unitPrice, BigDecimal vat) {
this.id = billLinesId; this.id = new EventPk(bill.getId().getEvent());
this.bill = bill;
this.name = product; this.name = product;
this.setUnits(units); this.setQuantity(units);
this.setUnitPrice(unitPrice); this.setUnitPrice(unitPrice);
this.setVat(vat); this.setVat(vat);
} }
public String getName() { public String getName() {
return name; return name;
} }
...@@ -174,12 +174,12 @@ public class BillLine implements EventChildInterface { ...@@ -174,12 +174,12 @@ public class BillLine implements EventChildInterface {
this.id = id; this.id = id;
} }
public void setUnits(BigDecimal units) { public void setQuantity(BigDecimal units) {
this.units = units; this.quantity = units;
} }
public BigDecimal getUnits() { public BigDecimal getQuantity() {
return units; return quantity;
} }
public void setUnitPrice(BigDecimal price) { public void setUnitPrice(BigDecimal price) {
......
...@@ -27,7 +27,7 @@ import javax.persistence.Version; ...@@ -27,7 +27,7 @@ import javax.persistence.Version;
@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 implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
private EventPk id; private EventPk id;
...@@ -39,10 +39,6 @@ public class CardTemplate implements EventChildInterface{ ...@@ -39,10 +39,6 @@ public class CardTemplate implements EventChildInterface{
@Column(name = "template_name", nullable = false) @Column(name = "template_name", nullable = false)
private String name; private String name;
@JoinColumn(name = "events_id", referencedColumnName = "events_id")
@ManyToOne
private Event event;
@OneToMany(mappedBy = "cardTemplate") @OneToMany(mappedBy = "cardTemplate")
private List<Role> roles; private List<Role> roles;
...@@ -56,12 +52,12 @@ public class CardTemplate implements EventChildInterface{ ...@@ -56,12 +52,12 @@ public class CardTemplate implements EventChildInterface{
public CardTemplate() { public CardTemplate() {
} }
public CardTemplate(EventPk cardTemplatesId) { public CardTemplate(Event event) {
this.id = cardTemplatesId; this.id = new EventPk(event);
} }
public CardTemplate(EventPk cardTemplatesId, String templateName) { public CardTemplate(Event event, String templateName) {
this.id = cardTemplatesId; this.id = new EventPk(event);
this.name = templateName; this.name = templateName;
} }
...@@ -81,10 +77,6 @@ public class CardTemplate implements EventChildInterface{ ...@@ -81,10 +77,6 @@ public class CardTemplate implements EventChildInterface{
this.name = templateName; this.name = templateName;
} }
public Event getEvent() {
return event;
}
@Override @Override
public EventPk getId() { public EventPk getId() {
return id; return id;
...@@ -95,10 +87,6 @@ public class CardTemplate implements EventChildInterface{ ...@@ -95,10 +87,6 @@ public class CardTemplate implements EventChildInterface{
this.id = id; this.id = id;
} }
public void setEvent(Event eventsId) {
this.event = eventsId;
}
public List<Role> getRoles() { public List<Role> getRoles() {
return roles; return roles;
} }
......
...@@ -38,7 +38,7 @@ import javax.persistence.Version; ...@@ -38,7 +38,7 @@ 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 implements EventChildInterface{ public class Compo implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
private EventPk id; private EventPk id;
...@@ -50,8 +50,8 @@ public class Compo implements EventChildInterface{ ...@@ -50,8 +50,8 @@ public class Compo implements EventChildInterface{
private String name; private String name;
/** /**
* Start time of the competition * Start time of the competition Submitting entries should be disabled after
* Submitting entries should be disabled after this time. * this time.
*/ */
@Column(name = "compo_start") @Column(name = "compo_start")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
...@@ -59,6 +59,7 @@ public class Compo implements EventChildInterface{ ...@@ -59,6 +59,7 @@ public class Compo implements EventChildInterface{
/** /**
* When the voting should start * When the voting should start
*
* @See {@link #holdVoting} * @See {@link #holdVoting}
*/ */
@Column(name = "vote_start") @Column(name = "vote_start")
...@@ -81,14 +82,13 @@ public class Compo implements EventChildInterface{ ...@@ -81,14 +82,13 @@ public class Compo implements EventChildInterface{
@Column(name = "description") @Column(name = "description")
private String description; private String description;
@Column(name = "max_participant_count") @Column(name = "max_participant_count")
private int maxParticipantCount; private int maxParticipantCount;
/** /**
* If ( for some unimaginable reason ) compo is delayed * If ( for some unimaginable reason ) compo is delayed hold voting can be
* hold voting can be used to postpone the start of the voting * used to postpone the start of the voting from the time specified in
* from the time specified in {@link #voteStart} * {@link #voteStart}
*/ */
@Column(name = "hold_voting", nullable = false) @Column(name = "hold_voting", nullable = false)
private boolean holdVoting = true; private boolean holdVoting = true;
...@@ -99,13 +99,6 @@ public class Compo implements EventChildInterface{ ...@@ -99,13 +99,6 @@ public class Compo implements EventChildInterface{
@OneToMany(cascade = CascadeType.ALL, mappedBy = "compo") @OneToMany(cascade = CascadeType.ALL, mappedBy = "compo")
private List<CompoEntry> compoEntries; private List<CompoEntry> compoEntries;
/**
* Which event the compo belongs to
*/
@JoinColumn(name = "events_id", referencedColumnName = "events_id", nullable = false)
@ManyToOne(optional = false)
private Event event;
@Version @Version
@Column(nullable = false) @Column(nullable = false)
private int jpaVersionField; private int jpaVersionField;
...@@ -123,12 +116,12 @@ public class Compo implements EventChildInterface{ ...@@ -123,12 +116,12 @@ public class Compo implements EventChildInterface{
public Compo() { public Compo() {
} }
public Compo(EventPk composId) { public Compo(Event event) {
this.id = composId; this.id = new EventPk(event);
} }
public Compo(EventPk composId, String compoName, boolean holdVoting) { public Compo(Event event, String compoName, boolean holdVoting) {
this.id = composId; this.id = new EventPk(event);
this.name = compoName; this.name = compoName;
this.holdVoting = holdVoting; this.holdVoting = holdVoting;
} }
...@@ -197,14 +190,6 @@ public class Compo implements EventChildInterface{ ...@@ -197,14 +190,6 @@ public class Compo implements EventChildInterface{
this.compoEntries = compoEntryList; this.compoEntries = compoEntryList;
} }
public Event getEvent() {
return event;
}
public void setEvent(Event eventsId) {
this.event = eventsId;
}
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 0; int hash = 0;
...@@ -258,7 +243,8 @@ public class Compo implements EventChildInterface{ ...@@ -258,7 +243,8 @@ public class Compo implements EventChildInterface{
} }
/** /**
* @param maxParticipantCount the maxParticipantCount to set * @param maxParticipantCount
* the maxParticipantCount to set
*/ */
public void setMaxParticipantCount(int maxParticipantCount) { public void setMaxParticipantCount(int maxParticipantCount) {
this.maxParticipantCount = maxParticipantCount; this.maxParticipantCount = maxParticipantCount;
......
...@@ -37,7 +37,7 @@ import javax.persistence.Version; ...@@ -37,7 +37,7 @@ import javax.persistence.Version;
@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 implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
private EventPk id; private EventPk id;
...@@ -63,10 +63,9 @@ public class CompoEntry implements EventChildInterface{ ...@@ -63,10 +63,9 @@ public class CompoEntry implements EventChildInterface{
@Column(name = "final_position") @Column(name = "final_position")
private Integer finalPosition; private Integer finalPosition;
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "currentFile_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "current_file_id", referencedColumnName = "id"),
@JoinColumn(name="currentFile_event_id",referencedColumnName = "events_pk_id",nullable=false, updatable=false,insertable=false) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
})
@OneToOne @OneToOne
private CompoEntryFile currentFile; private CompoEntryFile currentFile;
...@@ -79,14 +78,13 @@ public class CompoEntry implements EventChildInterface{ ...@@ -79,14 +78,13 @@ public class CompoEntry implements EventChildInterface{
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry") @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry")
private List<CompoEntryParticipant> participants; private List<CompoEntryParticipant> participants;
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "compos_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "compo_id", referencedColumnName = "id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="compos_event_id",referencedColumnName = "events_pk_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 Compo compo; private Compo compo;
@JoinColumn(name = "creator_id", referencedColumnName = "users_id") @JoinColumn(name = "creator_user_id", referencedColumnName = "id")
@ManyToOne @ManyToOne
private User creator; private User creator;
...@@ -107,12 +105,12 @@ public class CompoEntry implements EventChildInterface{ ...@@ -107,12 +105,12 @@ public class CompoEntry implements EventChildInterface{
public CompoEntry() { public CompoEntry() {
} }
public CompoEntry(EventPk entriesId) { public CompoEntry(Event event) {
this.id = entriesId; this.id = new EventPk(event);
} }
public CompoEntry(EventPk entriesId, Calendar entryCreated, String entryName) { public CompoEntry(Event event, Calendar entryCreated, String entryName) {
this.id = entriesId; this(event);
this.created = entryCreated; this.created = entryCreated;
this.name = entryName; this.name = entryName;
} }
......
...@@ -33,7 +33,7 @@ import javax.persistence.Version; ...@@ -33,7 +33,7 @@ import javax.persistence.Version;
@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 implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
private EventPk id; private EventPk id;
...@@ -57,12 +57,11 @@ public class CompoEntryFile implements EventChildInterface{ ...@@ -57,12 +57,11 @@ public class CompoEntryFile implements EventChildInterface{
@Column(name = "uploaded", nullable = false) @Column(name = "uploaded", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar uploaded; private Calendar uploaded = Calendar.getInstance();
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "entries_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "entry_id", referencedColumnName = "id", nullable = false, updatable = false),
@JoinColumn(name="entries_event_id",referencedColumnName = "events_pk_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;
...@@ -83,13 +82,13 @@ public class CompoEntryFile implements EventChildInterface{ ...@@ -83,13 +82,13 @@ public class CompoEntryFile implements EventChildInterface{
public CompoEntryFile() { public CompoEntryFile() {
} }
public CompoEntryFile(EventPk entryFilesId) { public CompoEntryFile(Event event) {
this.id = entryFilesId; this.id = new EventPk(event);
} }
public CompoEntryFile(EventPk entryFilesId, Calendar uploaded) { public CompoEntryFile(Event event, CompoEntry entry) {
this.id = entryFilesId; this(event);
this.uploaded = uploaded; this.entry = entry;
} }
public String getMimeType() { public String getMimeType() {
......
...@@ -46,16 +46,14 @@ public class CompoEntryParticipant implements EventChildInterface { ...@@ -46,16 +46,14 @@ public class CompoEntryParticipant implements EventChildInterface {
private Calendar confirmed; private Calendar confirmed;
@JoinColumns( { @JoinColumns( {
@JoinColumn(name = "entries_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "entry_id", referencedColumnName = "id", nullable = false, updatable = false),
@JoinColumn(name = "entries_event_id", referencedColumnName = "events_pk_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 = "users_id", referencedColumnName = "users_id", nullable = false, updatable = false, insertable = false) @JoinColumn(name = "user_id", referencedColumnName = "id", nullable = false, updatable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private User users; private User user;
@Version @Version
@Column(nullable = false) @Column(nullable = false)
...@@ -79,19 +77,17 @@ public class CompoEntryParticipant implements EventChildInterface { ...@@ -79,19 +77,17 @@ public class CompoEntryParticipant implements EventChildInterface {
this.entry = entry; this.entry = entry;
} }
public User getUsers() { public CompoEntryParticipant() {
return users;
}
public void setUsers(User users) {
this.users = users;
} }
public CompoEntryParticipant() { public CompoEntryParticipant(Event event) {
this.id = new EventPk(event);
} }
public CompoEntryParticipant(EventPk entryParticipationsId) { public CompoEntryParticipant(CompoEntry entry, User participant) {
this.id = entryParticipationsId; this(entry.getId().getEvent());
this.entry = entry;
this.user = participant;
} }
public String getRole() { public String getRole() {
...@@ -102,20 +98,12 @@ public class CompoEntryParticipant implements EventChildInterface { ...@@ -102,20 +98,12 @@ public class CompoEntryParticipant implements EventChildInterface {
this.role = role; this.role = role;
} }
public CompoEntry getEntriesId() { public User getUser() {
return entry; return user;
}
public void setEntriesId(CompoEntry entriesId) {
this.entry = entriesId;
}
public User getUsersId() {
return users;
} }
public void setUsersId(User usersId) { public void setUser(User user) {
this.users = usersId; this.user = user;
} }
@Override @Override
......
...@@ -37,7 +37,7 @@ import javax.persistence.Version; ...@@ -37,7 +37,7 @@ import javax.persistence.Version;
@NamedQuery(name = "Discount.findByActive", query = "SELECT d FROM Discount d WHERE d.active = :active"), @NamedQuery(name = "Discount.findByActive", query = "SELECT d FROM Discount d WHERE d.active = :active"),
@NamedQuery(name = "Discount.findByMaxNum", query = "SELECT d FROM Discount d WHERE d.maxNum = :maxNum"), @NamedQuery(name = "Discount.findByMaxNum", query = "SELECT d FROM Discount d WHERE d.maxNum = :maxNum"),
@NamedQuery(name = "Discount.findByPerUser", query = "SELECT d FROM Discount d WHERE d.perUser = :perUser") }) @NamedQuery(name = "Discount.findByPerUser", query = "SELECT d FROM Discount d WHERE d.perUser = :perUser") })
public class Discount implements EventChildInterface{ public class Discount implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
private EventPk id; private EventPk id;
...@@ -70,16 +70,16 @@ public class Discount implements EventChildInterface{ ...@@ -70,16 +70,16 @@ public class Discount implements EventChildInterface{
@OneToMany(cascade = CascadeType.ALL, mappedBy = "discount") @OneToMany(cascade = CascadeType.ALL, mappedBy = "discount")
private List<DiscountInstance> discountInstances; private List<DiscountInstance> discountInstances;
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "roles_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "role_id", referencedColumnName = "id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="roles_event_id",referencedColumnName = "events_pk_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 Role role; private Role role;
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "products_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "product_id", referencedColumnName = "id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="products_event_id",referencedColumnName = "events_pk_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)
...@@ -92,8 +92,8 @@ public class Discount implements EventChildInterface{ ...@@ -92,8 +92,8 @@ public class Discount implements EventChildInterface{
public Discount() { public Discount() {
} }
public Discount(EventPk discountsId) { public Discount(Event event) {
this.id = discountsId; this.id = new EventPk(event);
} }
@Override @Override
...@@ -106,9 +106,9 @@ public class Discount implements EventChildInterface{ ...@@ -106,9 +106,9 @@ public class Discount implements EventChildInterface{
this.id = id; this.id = id;
} }
public Discount(EventPk discountsId, int percentage, int amountMin, public Discount(Event event, int percentage, int amountMin,
int amountMax, boolean active, int maxNum, int perUser) { int amountMax, boolean active, int maxNum, int perUser) {
this.id = discountsId; this(event);
this.setPercentage(percentage); this.setPercentage(percentage);
this.amountMin = amountMin; this.amountMin = amountMin;
this.amountMax = amountMax; this.amountMax = amountMax;
......
...@@ -25,7 +25,7 @@ import javax.persistence.Version; ...@@ -25,7 +25,7 @@ import javax.persistence.Version;
@Entity @Entity
@Table(name = "discount_instances") @Table(name = "discount_instances")
@NamedQueries( { @NamedQuery(name = "DiscountInstance.findAll", query = "SELECT d FROM DiscountInstance d") }) @NamedQueries( { @NamedQuery(name = "DiscountInstance.findAll", query = "SELECT d FROM DiscountInstance d") })
public class DiscountInstance implements EventChildInterface{ public class DiscountInstance implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
...@@ -35,21 +35,19 @@ public class DiscountInstance implements EventChildInterface{ ...@@ -35,21 +35,19 @@ public class DiscountInstance implements EventChildInterface{
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar createTime = Calendar.getInstance(); private Calendar createTime = Calendar.getInstance();
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "account_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "account_event_id", referencedColumnName = "id", nullable = false, updatable = false),
@JoinColumn(name="account_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
})
@ManyToOne @ManyToOne
private AccountEvent accountEvent; private AccountEvent accountEvent;
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "discounts_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "discount_id", referencedColumnName = "id", nullable = false, updatable = false),
@JoinColumn(name="discounts_event_id",referencedColumnName = "events_pk_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 Discount discount; private Discount discount;
@JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false) @JoinColumn(name = "user_id", referencedColumnName = "id", nullable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private User user; private User user;
...@@ -60,8 +58,8 @@ public class DiscountInstance implements EventChildInterface{ ...@@ -60,8 +58,8 @@ public class DiscountInstance implements EventChildInterface{
public DiscountInstance() { public DiscountInstance() {
} }
public DiscountInstance(EventPk discountsInstancesId) { public DiscountInstance(Event event) {
this.id = discountsInstancesId; this.id = new EventPk(event);
} }
public AccountEvent getAccountEvent() { public AccountEvent getAccountEvent() {
......
...@@ -32,7 +32,6 @@ import javax.persistence.Version; ...@@ -32,7 +32,6 @@ import javax.persistence.Version;
@Table(name = "events") @Table(name = "events")
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "Event.findAll", query = "SELECT e FROM Event e"), @NamedQuery(name = "Event.findAll", query = "SELECT e FROM Event e"),
@NamedQuery(name = "Event.findByStartTime", query = "SELECT e FROM Event e WHERE e.startTime = :startTime"), @NamedQuery(name = "Event.findByStartTime", query = "SELECT e FROM Event e WHERE e.startTime = :startTime"),
@NamedQuery(name = "Event.findByEndTime", query = "SELECT e FROM Event e WHERE e.endTime = :endTime"), @NamedQuery(name = "Event.findByEndTime", query = "SELECT e FROM Event e WHERE e.endTime = :endTime"),
@NamedQuery(name = "Event.findByName", query = "SELECT e FROM Event e WHERE e.name = :name"), @NamedQuery(name = "Event.findByName", query = "SELECT e FROM Event e WHERE e.name = :name"),
...@@ -42,7 +41,7 @@ public class Event implements ModelInterface<Integer> { ...@@ -42,7 +41,7 @@ public class Event implements ModelInterface<Integer> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "events_id", nullable = false) @Column(name = "event_id", nullable = false)
private Integer id; private Integer id;
@Column(name = "start_time") @Column(name = "start_time")
...@@ -69,7 +68,7 @@ public class Event implements ModelInterface<Integer> { ...@@ -69,7 +68,7 @@ public class Event implements ModelInterface<Integer> {
@JoinColumns( { @JoinColumns( {
@JoinColumn(name = "default_role_id", referencedColumnName = "id"), @JoinColumn(name = "default_role_id", referencedColumnName = "id"),
@JoinColumn(name = "events_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) }) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@OneToOne @OneToOne
private Role defaultRole; private Role defaultRole;
...@@ -89,21 +88,21 @@ public class Event implements ModelInterface<Integer> { ...@@ -89,21 +88,21 @@ public class Event implements ModelInterface<Integer> {
@Column(nullable = false) @Column(nullable = false)
private int jpaVersionField; private int jpaVersionField;
@OneToMany(mappedBy = "event") @OneToMany(mappedBy = "event_id")
private List<Bill> bills; private List<Bill> bills;
@OneToMany(mappedBy = "event") @OneToMany(mappedBy = "event_id")
private List<Reader> readers; private List<Reader> readers;
public Event() { public Event() {
} }
public Event(Integer eventsId) { public Event(EventSettings settings) {
this.id = eventsId; this.settings = settings;
} }
public Event(Integer eventsId, String name) { public Event(EventSettings settings, String name) {
this.id = eventsId; this.settings = settings;
this.name = name; this.name = name;
} }
......
...@@ -28,7 +28,7 @@ import javax.persistence.Version; ...@@ -28,7 +28,7 @@ import javax.persistence.Version;
@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 implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
...@@ -44,10 +44,6 @@ public class EventMap implements EventChildInterface{ ...@@ -44,10 +44,6 @@ public class EventMap implements EventChildInterface{
@OneToMany(cascade = CascadeType.ALL, mappedBy = "map") @OneToMany(cascade = CascadeType.ALL, mappedBy = "map")
private List<Place> places; private List<Place> places;
@JoinColumn(name = "events_id", referencedColumnName = "events_id", nullable = false)
@ManyToOne(optional = false)
private Event event;
@Version @Version
@Column(nullable = false) @Column(nullable = false)
private int jpaVersionField; private int jpaVersionField;
...@@ -57,8 +53,8 @@ public class EventMap implements EventChildInterface{ ...@@ -57,8 +53,8 @@ public class EventMap implements EventChildInterface{
public EventMap() { public EventMap() {
} }
public EventMap(EventPk mapsId) { public EventMap(Event event) {
this.id = mapsId; this.id = new EventPk(event);
} }
public byte[] getMapData() { public byte[] getMapData() {
...@@ -85,14 +81,6 @@ public class EventMap implements EventChildInterface{ ...@@ -85,14 +81,6 @@ public class EventMap implements EventChildInterface{
this.places = placeList; this.places = placeList;
} }
public Event getEvent() {
return event;
}
public void setEvent(Event eventsId) {
this.event = eventsId;
}
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 0; int hash = 0;
...@@ -162,7 +150,8 @@ public class EventMap implements EventChildInterface{ ...@@ -162,7 +150,8 @@ public class EventMap implements EventChildInterface{
} }
/** /**
* @param readers the readers to set * @param readers
* the readers to set
*/ */
public void setReaders(List<Reader> readers) { public void setReaders(List<Reader> readers) {
this.readers = readers; this.readers = readers;
......
...@@ -14,13 +14,18 @@ public class EventPk implements Serializable { ...@@ -14,13 +14,18 @@ public class EventPk implements Serializable {
@Column(name = "id", nullable = false) @Column(name = "id", nullable = false)
private Integer id; private Integer id;
@Column(name = "events_pk_id", nullable = false, updatable = false) @Column(name = "event_id", nullable = false, updatable = false)
private Integer eventId; private Integer eventId;
@JoinColumn(name = "event_id", referencedColumnName = "event_id")
@ManyToOne
private Event event;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public EventPk() { public EventPk(Event event) {
super(); super();
this.event = event;
} }
public void setId(Integer id) { public void setId(Integer id) {
...@@ -31,14 +36,6 @@ public class EventPk implements Serializable { ...@@ -31,14 +36,6 @@ public class EventPk implements Serializable {
return id; return id;
} }
public void setEventId(Integer eventId) {
this.eventId = eventId;
}
public Integer getEventId() {
return eventId;
}
public int hashCode() { public int hashCode() {
return id.hashCode() + eventId.hashCode(); return id.hashCode() + eventId.hashCode();
} }
...@@ -54,4 +51,11 @@ public class EventPk implements Serializable { ...@@ -54,4 +51,11 @@ public class EventPk implements Serializable {
return pk.id == this.id && pk.eventId == this.eventId; return pk.id == this.id && pk.eventId == this.eventId;
} }
public void setEvent(Event event) {
this.event = event;
}
public Event getEvent() {
return event;
}
} }
...@@ -47,7 +47,7 @@ public class EventSettings implements ModelInterface<Integer> { ...@@ -47,7 +47,7 @@ public class EventSettings implements ModelInterface<Integer> {
private List<Event> events; private List<Event> events;
@ManyToOne @ManyToOne
@JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false) @JoinColumn(name = "admin_user_id", referencedColumnName = "id", nullable = false)
private User admin; private User admin;
@Version @Version
......
...@@ -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.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
...@@ -27,8 +26,7 @@ import javax.persistence.Version; ...@@ -27,8 +26,7 @@ import javax.persistence.Version;
@Table(name = "event_status", uniqueConstraints = { @UniqueConstraint(columnNames = { "status_name" }) }) @Table(name = "event_status", 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.statusName = :name") })
@NamedQuery(name = "EventStatus.findByStatusName", query = "SELECT e FROM EventStatus e WHERE e.statusName = :statusName") })
public class EventStatus implements ModelInterface<Integer> { public class EventStatus implements ModelInterface<Integer> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -39,7 +37,7 @@ public class EventStatus implements ModelInterface<Integer> { ...@@ -39,7 +37,7 @@ public class EventStatus implements ModelInterface<Integer> {
private Integer id; private Integer id;
@Column(name = "status_name", nullable = false) @Column(name = "status_name", nullable = false)
private String statusName; private String name;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "status") @OneToMany(cascade = CascadeType.ALL, mappedBy = "status")
private List<Event> events; private List<Event> events;
...@@ -51,16 +49,16 @@ public class EventStatus implements ModelInterface<Integer> { ...@@ -51,16 +49,16 @@ public class EventStatus implements ModelInterface<Integer> {
public EventStatus() { public EventStatus() {
} }
public EventStatus(String statusName) { public EventStatus(String name) {
this.statusName = statusName; this.name = name;
} }
public String getStatusName() { public String getName() {
return statusName; return name;
} }
public void setStatusName(String statusName) { public void setName(String statusName) {
this.statusName = statusName; this.name = statusName;
} }
public List<Event> getEvents() { public List<Event> getEvents() {
......
...@@ -31,7 +31,7 @@ import javax.persistence.Version; ...@@ -31,7 +31,7 @@ import javax.persistence.Version;
@NamedQuery(name = "FoodWave.findByDescription", query = "SELECT f FROM FoodWave f WHERE f.description = :description"), @NamedQuery(name = "FoodWave.findByDescription", query = "SELECT f FROM FoodWave f WHERE f.description = :description"),
@NamedQuery(name = "FoodWave.findByTime", query = "SELECT f FROM FoodWave f WHERE f.time = :time"), @NamedQuery(name = "FoodWave.findByTime", query = "SELECT f FROM FoodWave f WHERE f.time = :time"),
@NamedQuery(name = "FoodWave.findByClosed", query = "SELECT f FROM FoodWave f WHERE f.closed = :closed") }) @NamedQuery(name = "FoodWave.findByClosed", query = "SELECT f FROM FoodWave f WHERE f.closed = :closed") })
public class FoodWave implements EventChildInterface{ public class FoodWave implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
...@@ -61,12 +61,12 @@ public class FoodWave implements EventChildInterface{ ...@@ -61,12 +61,12 @@ public class FoodWave implements EventChildInterface{
public FoodWave() { public FoodWave() {
} }
public FoodWave(EventPk foodWavesId) { public FoodWave(Event event) {
this.id = foodWavesId; this.id = new EventPk(event);
} }
public FoodWave(EventPk foodWavesId, String waveName, boolean waveClosed) { public FoodWave(Event event, String waveName, boolean waveClosed) {
this.id = foodWavesId; this(event);
this.name = waveName; this.name = waveName;
this.closed = waveClosed; this.closed = waveClosed;
} }
......
...@@ -26,7 +26,7 @@ import javax.persistence.Version; ...@@ -26,7 +26,7 @@ import javax.persistence.Version;
@NamedQuery(name = "FoodWaveTemplate.findByName", query = "SELECT f FROM FoodWaveTemplate f WHERE f.name = :name"), @NamedQuery(name = "FoodWaveTemplate.findByName", query = "SELECT f FROM FoodWaveTemplate f WHERE f.name = :name"),
@NamedQuery(name = "FoodWaveTemplate.findByDescription", query = "SELECT f FROM FoodWaveTemplate f WHERE f.description = :description") }) @NamedQuery(name = "FoodWaveTemplate.findByDescription", query = "SELECT f FROM FoodWaveTemplate f WHERE f.description = :description") })
public class FoodWaveTemplate implements EventChildInterface{ public class FoodWaveTemplate implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
...@@ -49,12 +49,12 @@ public class FoodWaveTemplate implements EventChildInterface{ ...@@ -49,12 +49,12 @@ public class FoodWaveTemplate implements EventChildInterface{
public FoodWaveTemplate() { public FoodWaveTemplate() {
} }
public FoodWaveTemplate(EventPk foodWaveTemplatesId) { public FoodWaveTemplate(Event event) {
this.id = foodWaveTemplatesId; this.id = new EventPk(event);
} }
public FoodWaveTemplate(EventPk foodWaveTemplatesId, String templateName) { public FoodWaveTemplate(Event event, String templateName) {
this.id = foodWaveTemplatesId; this(event);
this.name = templateName; this.name = templateName;
} }
......
...@@ -26,7 +26,7 @@ import javax.persistence.Version; ...@@ -26,7 +26,7 @@ import javax.persistence.Version;
*/ */
@Entity @Entity
@Table(name = "group_memberships", uniqueConstraints = { @UniqueConstraint(columnNames = { @Table(name = "group_memberships", uniqueConstraints = { @UniqueConstraint(columnNames = {
"users_id", "groups_id" }) }) "user_id", "group_id" }) })
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "GroupMembership.findAll", query = "SELECT g FROM GroupMembership g"), @NamedQuery(name = "GroupMembership.findAll", query = "SELECT g FROM GroupMembership g"),
...@@ -50,22 +50,18 @@ public class GroupMembership implements EventChildInterface { ...@@ -50,22 +50,18 @@ public class GroupMembership implements EventChildInterface {
private String inviteName; private String inviteName;
@JoinColumns( { @JoinColumns( {
@JoinColumn(name = "groups_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "group_id", referencedColumnName = "id", nullable = false),
@JoinColumn(name = "groups_event_id", referencedColumnName = "events_pk_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 PlaceGroup placeGroup; private PlaceGroup placeGroup;
@JoinColumns( { @JoinColumns( {
@JoinColumn(name = "place_reservation_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "place_reservation_id", referencedColumnName = "id", nullable = false),
@JoinColumn(name = "place_reservation_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
})
@OneToOne(optional = false) @OneToOne(optional = false)
private Place placeReservation; private Place placeReservation;
@JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false, updatable = false, insertable = false) @JoinColumn(name = "user_id", referencedColumnName = "id")
@ManyToOne @ManyToOne
private User user; private User user;
...@@ -80,8 +76,8 @@ public class GroupMembership implements EventChildInterface { ...@@ -80,8 +76,8 @@ public class GroupMembership implements EventChildInterface {
public GroupMembership() { public GroupMembership() {
} }
public GroupMembership(EventPk groupMembershipsId) { public GroupMembership(Event event) {
this.id = groupMembershipsId; this.id = new EventPk(event);
} }
public Calendar getInviteAccepted() { public Calendar getInviteAccepted() {
......
...@@ -24,7 +24,7 @@ import javax.persistence.Version; ...@@ -24,7 +24,7 @@ import javax.persistence.Version;
@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 implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
...@@ -46,13 +46,13 @@ public class Location implements EventChildInterface{ ...@@ -46,13 +46,13 @@ public class Location implements EventChildInterface{
public Location() { public Location() {
} }
public Location(EventPk locationsId) { public Location(Event event) {
this.id = locationsId; this.id = new EventPk(event);
} }
public Location(EventPk locationsId, String locationName) { public Location(Event event, String name) {
this.id = locationsId; this(event);
this.name = locationName; this.name = name;
} }
public String getName() { public String getName() {
......
...@@ -30,7 +30,7 @@ import javax.persistence.Version; ...@@ -30,7 +30,7 @@ import javax.persistence.Version;
@NamedQuery(name = "LogEntry.findAll", query = "SELECT l FROM LogEntry l"), @NamedQuery(name = "LogEntry.findAll", query = "SELECT l FROM LogEntry l"),
@NamedQuery(name = "LogEntry.findByTime", query = "SELECT l FROM LogEntry l WHERE l.time = :time"), @NamedQuery(name = "LogEntry.findByTime", query = "SELECT l FROM LogEntry l WHERE l.time = :time"),
@NamedQuery(name = "LogEntry.findByDescription", query = "SELECT l FROM LogEntry l WHERE l.description = :description") }) @NamedQuery(name = "LogEntry.findByDescription", query = "SELECT l FROM LogEntry l WHERE l.description = :description") })
public class LogEntry implements EventChildInterface{ public class LogEntry implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -45,14 +45,11 @@ public class LogEntry implements EventChildInterface{ ...@@ -45,14 +45,11 @@ public class LogEntry implements EventChildInterface{
@Column(name = "event_description") @Column(name = "event_description")
private String description; private String description;
@JoinColumns({ @JoinColumn(name = "event_log_type_id", referencedColumnName = "id", nullable = false)
@JoinColumn(name = "event_log_type_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="event_log_event_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private LogEntryType type; private LogEntryType type;
@JoinColumn(name = "users_id", referencedColumnName = "users_id") @JoinColumn(name = "user_id", referencedColumnName = "id")
@ManyToOne @ManyToOne
private User user; private User user;
...@@ -63,12 +60,12 @@ public class LogEntry implements EventChildInterface{ ...@@ -63,12 +60,12 @@ public class LogEntry implements EventChildInterface{
public LogEntry() { public LogEntry() {
} }
public LogEntry(EventPk eventLogId) { public LogEntry(Event event) {
this.id = eventLogId; this.id = new EventPk(event);
} }
public LogEntry(EventPk eventLogId, Calendar eventTime) { public LogEntry(Event event, Calendar eventTime) {
this.id = eventLogId; this(event);
this.time = eventTime; this.time = eventTime;
} }
......
...@@ -8,8 +8,10 @@ import java.util.List; ...@@ -8,8 +8,10 @@ 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.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;
...@@ -23,25 +25,27 @@ import javax.persistence.Version; ...@@ -23,25 +25,27 @@ import javax.persistence.Version;
*/ */
@Entity @Entity
@Table(name = "event_log_types", uniqueConstraints = { @UniqueConstraint(columnNames = { "events_pk_id", "logentry_name" }) }) @Table(name = "event_log_types", uniqueConstraints = { @UniqueConstraint(columnNames = { "events_pk_id", "logentry_name" }) })
@NamedQueries({ @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 EventChildInterface { public class LogEntryType implements ModelInterface<Integer> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @Id
private EventPk id; @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "event_log_type_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..
*/ */
@Column(name = "logentry_name", nullable = false, updatable = false) @Column(name = "type_name", nullable = false, updatable = false)
private String name; private String name;
@Lob @Lob
@Column(name = "event_type_description", nullable = false) @Column(name = "event_type_description")
private String description; private String description;
/** /**
...@@ -63,15 +67,6 @@ public class LogEntryType implements EventChildInterface { ...@@ -63,15 +67,6 @@ public class LogEntryType implements EventChildInterface {
public LogEntryType() { public LogEntryType() {
} }
public LogEntryType(EventPk eventLogTypesId) {
this.id = eventLogTypesId;
}
public LogEntryType(EventPk eventLogTypesId, String eventTypeDescription) {
this.id = eventLogTypesId;
this.description = eventTypeDescription;
}
public String getDescription() { public String getDescription() {
return description; return description;
} }
...@@ -119,7 +114,7 @@ public class LogEntryType implements EventChildInterface { ...@@ -119,7 +114,7 @@ public class LogEntryType implements EventChildInterface {
* @return the id * @return the id
*/ */
@Override @Override
public EventPk getId() { public Integer getId() {
return id; return id;
} }
...@@ -128,7 +123,7 @@ public class LogEntryType implements EventChildInterface { ...@@ -128,7 +123,7 @@ public class LogEntryType implements EventChildInterface {
* the id to set * the id to set
*/ */
@Override @Override
public void setId(EventPk id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
......
...@@ -35,7 +35,7 @@ import javax.persistence.Version; ...@@ -35,7 +35,7 @@ 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 implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
...@@ -63,12 +63,9 @@ public class News implements EventChildInterface{ ...@@ -63,12 +63,9 @@ 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_groups_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@JoinColumn(name="news_groups_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false) @ManyToOne(optional = false)
private NewsGroup group; private NewsGroup group;
...@@ -79,12 +76,12 @@ public class News implements EventChildInterface{ ...@@ -79,12 +76,12 @@ public class News implements EventChildInterface{
public News() { public News() {
} }
public News(EventPk newsId) { public News(Event event) {
this.id = newsId; this.id = new EventPk(event);
} }
public News(EventPk newsId, String title, int priority) { public News(Event event, String title, int priority) {
this.id = newsId; this(event);
this.title = title; this.title = title;
this.priority = priority; this.priority = priority;
} }
......
...@@ -29,7 +29,7 @@ import javax.persistence.Version; ...@@ -29,7 +29,7 @@ import javax.persistence.Version;
@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 implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -46,17 +46,6 @@ public class NewsGroup implements EventChildInterface{ ...@@ -46,17 +46,6 @@ public class NewsGroup implements EventChildInterface{
@Column(name = "priority", nullable = false) @Column(name = "priority", nullable = false)
private int priority; private int priority;
@ManyToMany
/* @JoinTable(name = "roles_news_groups", joinColumns = {
@JoinColumn(name = "entity_id", referencedColumnName = "news_groups_id"),
@JoinColumn(name = "events_pk_id", referencedColumnName = "news_groups_event_id")
}, inverseJoinColumns ={
@JoinColumn(name = "entity_id", referencedColumnName = "roles_id"),
@JoinColumn(name = "events_pk_id", referencedColumnName = "roles_event_id")}
)
}*/
private List<Role> roles;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "group") @OneToMany(cascade = CascadeType.ALL, mappedBy = "group")
private List<News> news; private List<News> news;
...@@ -67,12 +56,12 @@ public class NewsGroup implements EventChildInterface{ ...@@ -67,12 +56,12 @@ public class NewsGroup implements EventChildInterface{
public NewsGroup() { public NewsGroup() {
} }
public NewsGroup(EventPk newsGroupsId) { public NewsGroup(Event event) {
this.id = newsGroupsId; this.id = new EventPk(event);
} }
public NewsGroup(EventPk newsGroupsId, String groupName, int priority) { public NewsGroup(Event event, String groupName, int priority) {
this.id = newsGroupsId; this(event);
this.name = groupName; this.name = groupName;
this.priority = priority; this.priority = priority;
} }
...@@ -170,18 +159,4 @@ public class NewsGroup implements EventChildInterface{ ...@@ -170,18 +159,4 @@ public class NewsGroup implements EventChildInterface{
public void setJpaVersionField(int jpaVersionField) { public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField; this.jpaVersionField = jpaVersionField;
} }
/**
* @return the roles
*/
public List<Role> getRoles() {
return roles;
}
/**
* @param roles the roles to set
*/
public void setRoles(List<Role> roles) {
this.roles = roles;
}
} }
...@@ -30,7 +30,7 @@ import javax.persistence.Version; ...@@ -30,7 +30,7 @@ import javax.persistence.Version;
@NamedQuery(name = "Place.findByMapY", query = "SELECT p FROM Place p WHERE p.mapY = :mapY"), @NamedQuery(name = "Place.findByMapY", query = "SELECT p FROM Place p WHERE p.mapY = :mapY"),
@NamedQuery(name = "Place.findByDetails", query = "SELECT p FROM Place p WHERE p.details = :details"), @NamedQuery(name = "Place.findByDetails", query = "SELECT p FROM Place p WHERE p.details = :details"),
@NamedQuery(name = "Place.findByCode", query = "SELECT p FROM Place p WHERE p.code = :code") }) @NamedQuery(name = "Place.findByCode", query = "SELECT p FROM Place p WHERE p.code = :code") })
public class Place implements EventChildInterface{ public class Place implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
...@@ -56,37 +56,32 @@ public class Place implements EventChildInterface{ ...@@ -56,37 +56,32 @@ public class Place implements EventChildInterface{
/** /**
* Which group has bought the place * Which group has bought the place
*/ */
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "groups_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "group_id", referencedColumnName = "id", nullable = false),
@JoinColumn(name="groups_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
})
@ManyToOne @ManyToOne
private PlaceGroup placeGroup; private PlaceGroup group;
@JoinColumns({
@JoinColumn(name = "maps_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="maps_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
}) @JoinColumns( {
@JoinColumn(name = "map_id", referencedColumnName = "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 EventMap map; private EventMap map;
/** /**
* Which ticket type is this place sold as * Which ticket type is this place sold as
*/ */
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "products_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "products_id", referencedColumnName = "id"),
@JoinColumn(name="products_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
}) @ManyToOne()
@ManyToOne(optional = false)
private Product product; private Product product;
/** /**
* 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 = "users_id", referencedColumnName = "users_id") @JoinColumn(name = "current_user_id", referencedColumnName = "id")
@ManyToOne @ManyToOne
private User currentUser; private User currentUser;
...@@ -149,12 +144,12 @@ public class Place implements EventChildInterface{ ...@@ -149,12 +144,12 @@ public class Place implements EventChildInterface{
this.code = placeCode; this.code = placeCode;
} }
public PlaceGroup getPlaceGroup() { public PlaceGroup getGroup() {
return placeGroup; return group;
} }
public void setPlaceGroup(PlaceGroup groupsId) { public void setGroup(PlaceGroup groupsId) {
this.placeGroup = groupsId; this.group = groupsId;
} }
public EventMap getMap() { public EventMap getMap() {
......
...@@ -35,7 +35,7 @@ import javax.persistence.Version; ...@@ -35,7 +35,7 @@ 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 implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
...@@ -62,14 +62,14 @@ public class PlaceGroup implements EventChildInterface{ ...@@ -62,14 +62,14 @@ public class PlaceGroup implements EventChildInterface{
@Column(name = "group_details") @Column(name = "group_details")
private String details; private String details;
@JoinColumn(name = "group_creator", referencedColumnName = "users_id") @JoinColumn(name = "creator_user_id", referencedColumnName = "id")
@ManyToOne @ManyToOne
private User creator; private User creator;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "placeGroup") @OneToMany(cascade = CascadeType.ALL, mappedBy = "placeGroup")
private List<GroupMembership> members; private List<GroupMembership> members;
@OneToMany(mappedBy = "placeGroup") @OneToMany(mappedBy = "group")
private List<Place> places; private List<Place> places;
@Version @Version
...@@ -79,13 +79,13 @@ public class PlaceGroup implements EventChildInterface{ ...@@ -79,13 +79,13 @@ public class PlaceGroup implements EventChildInterface{
public PlaceGroup() { public PlaceGroup() {
} }
public PlaceGroup(EventPk groupsId) { public PlaceGroup(Event event) {
this.id = groupsId; this.id = new EventPk(event);
} }
public PlaceGroup(EventPk groupsId, Calendar groupCreated, Calendar groupEdited, public PlaceGroup(Event event, Calendar groupCreated, Calendar groupEdited,
boolean groupActive) { boolean groupActive) {
this.id = groupsId; this(event);
this.created = groupCreated; this.created = groupCreated;
this.edited = groupEdited; this.edited = groupEdited;
this.active = groupActive; this.active = groupActive;
......
...@@ -35,7 +35,7 @@ import javax.persistence.Version; ...@@ -35,7 +35,7 @@ import javax.persistence.Version;
@NamedQuery(name = "PrintedCard.findByBarcode", query = "SELECT p FROM PrintedCard p WHERE p.barcode = :barcode"), @NamedQuery(name = "PrintedCard.findByBarcode", query = "SELECT p FROM PrintedCard p WHERE p.barcode = :barcode"),
@NamedQuery(name = "PrintedCard.findByEnabled", query = "SELECT p FROM PrintedCard p WHERE p.enabled = :enabled"), @NamedQuery(name = "PrintedCard.findByEnabled", query = "SELECT p FROM PrintedCard p WHERE p.enabled = :enabled"),
@NamedQuery(name = "PrintedCard.findByRfidUid", query = "SELECT p FROM PrintedCard p WHERE p.rfidUid = :rfidUid") }) @NamedQuery(name = "PrintedCard.findByRfidUid", query = "SELECT p FROM PrintedCard p WHERE p.rfidUid = :rfidUid") })
public class PrintedCard implements EventChildInterface{ public class PrintedCard implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
private EventPk id; private EventPk id;
...@@ -56,10 +56,9 @@ public class PrintedCard implements EventChildInterface{ ...@@ -56,10 +56,9 @@ public class PrintedCard implements EventChildInterface{
@OneToMany(cascade = CascadeType.ALL, mappedBy = "printedCard") @OneToMany(cascade = CascadeType.ALL, mappedBy = "printedCard")
private List<ReaderEvent> readerEvents; private List<ReaderEvent> readerEvents;
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "current_location_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "current_location_id", referencedColumnName = "id"),
@JoinColumn(name="current_location_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
})
@ManyToOne @ManyToOne
private Location currentLocation; private Location currentLocation;
...@@ -67,10 +66,9 @@ public class PrintedCard implements EventChildInterface{ ...@@ -67,10 +66,9 @@ public class PrintedCard implements EventChildInterface{
@ManyToOne(optional = false) @ManyToOne(optional = false)
private User user; private User user;
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "card_template_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "card_template_id", referencedColumnName = "id", nullable = false, updatable = false),
@JoinColumn(name="card_template_event_id",referencedColumnName = "events_pk_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 CardTemplate template; private CardTemplate template;
...@@ -91,13 +89,13 @@ public class PrintedCard implements EventChildInterface{ ...@@ -91,13 +89,13 @@ public class PrintedCard implements EventChildInterface{
this.id = id; this.id = id;
} }
public PrintedCard(EventPk printedCardsId) { public PrintedCard(Event event) {
this.id = printedCardsId; this.id = new EventPk(event);
} }
public PrintedCard(EventPk printedCardsId, Calendar printTime, public PrintedCard(Event event, Calendar printTime,
boolean cardEnabled) { boolean cardEnabled) {
this.id = printedCardsId; this(event);
this.printTime = printTime; this.printTime = printTime;
this.enabled = cardEnabled; this.enabled = cardEnabled;
} }
......
...@@ -23,7 +23,7 @@ import javax.persistence.Version; ...@@ -23,7 +23,7 @@ import javax.persistence.Version;
*/ */
@Entity @Entity
@Table(name = "products") @Table(name = "products")
@NamedQueries({ @NamedQueries( {
@NamedQuery(name = "Product.findAll", query = "SELECT p FROM Product p"), @NamedQuery(name = "Product.findAll", query = "SELECT p FROM Product p"),
@NamedQuery(name = "Product.findByProductName", query = "SELECT p FROM Product p WHERE p.name = :name"), @NamedQuery(name = "Product.findByProductName", query = "SELECT p FROM Product p WHERE p.name = :name"),
...@@ -55,16 +55,6 @@ public class Product implements EventChildInterface { ...@@ -55,16 +55,6 @@ public class Product implements EventChildInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "product") @OneToMany(cascade = CascadeType.ALL, mappedBy = "product")
private List<AccountEvent> accountEvents; private List<AccountEvent> accountEvents;
/* @JoinTable(name = "food_wave_templates_products", joinColumns =
{ @JoinColumn(name = "entity_id", referencedColumnName = "products_id"),
@JoinColumn(name = "events_pk_id", referencedColumnName = "product_event_id") },
inverseJoinColumns =
{ @JoinColumn(name = "entity_id", referencedColumnName = "food_wave_templates_id"),
@JoinColumn(name = "events_pk_id", referencedColumnName = "food_wave_templates_event_id") })
*/
@ManyToMany
private List<FoodWaveTemplate> foodWaveTemplate;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "product") @OneToMany(cascade = CascadeType.ALL, mappedBy = "product")
private List<Discount> discounts; private List<Discount> discounts;
...@@ -75,12 +65,12 @@ public class Product implements EventChildInterface { ...@@ -75,12 +65,12 @@ public class Product implements EventChildInterface {
public Product() { public Product() {
} }
public Product(EventPk productsId) { public Product(Event event) {
this.id = productsId; this.id = new EventPk(event);
} }
public Product(EventPk productsId, BigInteger price, int sort) { public Product(Event event, BigInteger price, int sort) {
this.id = productsId; this(event);
this.price = price; this.price = price;
this.sort = sort; this.sort = sort;
} }
...@@ -161,21 +151,6 @@ public class Product implements EventChildInterface { ...@@ -161,21 +151,6 @@ public class Product implements EventChildInterface {
} }
/** /**
* @return the foodWaveTemplate
*/
public List<FoodWaveTemplate> getFoodWaveTemplate() {
return foodWaveTemplate;
}
/**
* @param foodWaveTemplate
* the foodWaveTemplate to set
*/
public void setFoodWaveTemplate(List<FoodWaveTemplate> foodWaveTemplate) {
this.foodWaveTemplate = foodWaveTemplate;
}
/**
* @return the id * @return the id
*/ */
@Override @Override
......
...@@ -30,7 +30,7 @@ import javax.persistence.Version; ...@@ -30,7 +30,7 @@ import javax.persistence.Version;
@NamedQuery(name = "Reader.findByIdentification", query = "SELECT r FROM Reader r WHERE r.identification = :identification"), @NamedQuery(name = "Reader.findByIdentification", query = "SELECT r FROM Reader r WHERE r.identification = :identification"),
@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 implements EventChildInterface{ public class Reader implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -46,24 +46,18 @@ public class Reader implements EventChildInterface{ ...@@ -46,24 +46,18 @@ public class Reader implements EventChildInterface{
@OneToMany(cascade = CascadeType.ALL, mappedBy = "reader") @OneToMany(cascade = CascadeType.ALL, mappedBy = "reader")
private List<ReaderEvent> events; private List<ReaderEvent> events;
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "location_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "location_id", referencedColumnName = "id"),
@JoinColumn(name = "location_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) }) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne @ManyToOne
private Location location; private Location location;
@ManyToOne @ManyToOne
@JoinColumn(name = "events_id", referencedColumnName = "events_id") @JoinColumns( {
private Event event; @JoinColumn(name = "map_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne
@JoinColumns({
@JoinColumn(name = "maps_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "maps_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) })
private EventMap eventMap; private EventMap eventMap;
@Column(name = "map_x") @Column(name = "map_x")
private Integer mapX; private Integer mapX;
@Column(name = "map_y") @Column(name = "map_y")
...@@ -76,8 +70,8 @@ public class Reader implements EventChildInterface{ ...@@ -76,8 +70,8 @@ public class Reader implements EventChildInterface{
public Reader() { public Reader() {
} }
public Reader(EventPk readersId) { public Reader(Event event) {
this.id = readersId; this.id = new EventPk(event);
} }
public String getIdentification() { public String getIdentification() {
...@@ -181,7 +175,8 @@ public class Reader implements EventChildInterface{ ...@@ -181,7 +175,8 @@ public class Reader implements EventChildInterface{
} }
/** /**
* @param event the event to set * @param event
* the event to set
*/ */
public void setEvent(Event event) { public void setEvent(Event event) {
this.event = event; this.event = event;
...@@ -195,7 +190,8 @@ public class Reader implements EventChildInterface{ ...@@ -195,7 +190,8 @@ public class Reader implements EventChildInterface{
} }
/** /**
* @param mapX the mapX to set * @param mapX
* the mapX to set
*/ */
public void setMapX(Integer mapX) { public void setMapX(Integer mapX) {
this.mapX = mapX; this.mapX = mapX;
...@@ -209,7 +205,8 @@ public class Reader implements EventChildInterface{ ...@@ -209,7 +205,8 @@ public class Reader implements EventChildInterface{
} }
/** /**
* @param mapY the mapY to set * @param mapY
* the mapY to set
*/ */
public void setMapY(Integer mapY) { public void setMapY(Integer mapY) {
this.mapY = mapY; this.mapY = mapY;
...@@ -223,7 +220,8 @@ public class Reader implements EventChildInterface{ ...@@ -223,7 +220,8 @@ public class Reader implements EventChildInterface{
} }
/** /**
* @param eventMap the eventMap to set * @param eventMap
* the eventMap to set
*/ */
public void setEventMap(EventMap eventMap) { public void setEventMap(EventMap eventMap) {
this.eventMap = eventMap; this.eventMap = eventMap;
......
...@@ -29,7 +29,7 @@ import javax.persistence.Version; ...@@ -29,7 +29,7 @@ import javax.persistence.Version;
@NamedQuery(name = "ReaderEvent.findByTime", query = "SELECT r FROM ReaderEvent r WHERE r.time = :time"), @NamedQuery(name = "ReaderEvent.findByTime", query = "SELECT r FROM ReaderEvent r WHERE r.time = :time"),
@NamedQuery(name = "ReaderEvent.findByValue", query = "SELECT r FROM ReaderEvent r WHERE r.value = :value") }) @NamedQuery(name = "ReaderEvent.findByValue", query = "SELECT r FROM ReaderEvent r WHERE r.value = :value") })
public class ReaderEvent implements EventChildInterface{ public class ReaderEvent implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -43,17 +43,15 @@ public class ReaderEvent implements EventChildInterface{ ...@@ -43,17 +43,15 @@ public class ReaderEvent implements EventChildInterface{
@Column(name = "value") @Column(name = "value")
private String value; private String value;
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "printed_cards_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "printed_cards_id", referencedColumnName = "id", nullable = false, updatable = false),
@JoinColumn(name="printed_cards_event_id",referencedColumnName = "events_pk_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 PrintedCard printedCard; private PrintedCard printedCard;
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "readers_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "readers_id", referencedColumnName = "id", nullable = false, updatable = false),
@JoinColumn(name="readers_event_id",referencedColumnName = "events_pk_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 Reader reader; private Reader reader;
...@@ -64,13 +62,15 @@ public class ReaderEvent implements EventChildInterface{ ...@@ -64,13 +62,15 @@ public class ReaderEvent implements EventChildInterface{
public ReaderEvent() { public ReaderEvent() {
} }
public ReaderEvent(EventPk readerEventsId) { public ReaderEvent(Event event) {
this.id = readerEventsId; this.id = new EventPk(event);
} }
public ReaderEvent(EventPk readerEventsId, Calendar eventTime) { public ReaderEvent(Event event, Calendar eventTime, PrintedCard card, Reader reader) {
this.id = readerEventsId; this(event);
this.time = eventTime; this.time = eventTime;
this.printedCard = card;
this.reader = reader;
} }
public Calendar getTime() { public Calendar getTime() {
......
...@@ -27,45 +27,53 @@ import javax.persistence.Version; ...@@ -27,45 +27,53 @@ import javax.persistence.Version;
* *
*/ */
@Entity @Entity
@Table(name = "roles", uniqueConstraints = { @Table(name = "roles", uniqueConstraints = { @UniqueConstraint(columnNames = { "events_pk_id", "role_name" }) })
@UniqueConstraint(columnNames = {"events_pk_id", "role_name"})}) @NamedQueries( {
@NamedQueries({
@NamedQuery(name = "Role.findAll", query = "SELECT r FROM Role r"), @NamedQuery(name = "Role.findAll", query = "SELECT r FROM Role r"),
@NamedQuery(name = "Role.findByRoleName", query = "SELECT r FROM Role r WHERE r.name = :name")}) @NamedQuery(name = "Role.findByRoleName", query = "SELECT r FROM Role r WHERE r.name = :name") })
public class Role implements EventChildInterface { public class Role implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
private EventPk id; private EventPk id;
@Column(name = "role_name", nullable = false) @Column(name = "role_name", nullable = false)
private String name; private String name;
@ManyToMany(cascade = CascadeType.ALL) @ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "role_memberships", joinColumns = { @JoinTable(name = "role_memberships", joinColumns = {
@JoinColumn(name = "roles_id", referencedColumnName = "entity_id"), @JoinColumn(name = "role_id", referencedColumnName = "id"),
@JoinColumn(name = "roles_event_id", referencedColumnName = "events_pk_id")}, inverseJoinColumns = @JoinColumn(name = "event_id", referencedColumnName = "event_id") }, inverseJoinColumns = {
@JoinColumn(name = "users_id", referencedColumnName = "users_id")) @JoinColumn(name = "user_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id") })
private List<User> users; private List<User> users;
@ManyToMany @ManyToMany
@JoinTable(name = "role_chlidren", joinColumns = { @JoinTable(name = "role_children", joinColumns = {
@JoinColumn(name = "role_id", referencedColumnName = "entity_id", updatable = false, insertable = false), @JoinColumn(name = "role_id", referencedColumnName = "id"),
@JoinColumn(name = "role_event_id", referencedColumnName = "events_pk_id", updatable = false, insertable = false)}) @JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false) }, inverseJoinColumns = {
@JoinColumn(name = "role_id", referencedColumnName = "id"),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", updatable = false, insertable = false) })
private List<Role> children = new ArrayList<Role>(); private List<Role> children = new ArrayList<Role>();
@ManyToMany(mappedBy = "children") @ManyToMany(mappedBy = "children")
private List<Role> parents = new ArrayList<Role>(); private List<Role> parents = new ArrayList<Role>();
@OneToMany(cascade = CascadeType.ALL, mappedBy = "role") @OneToMany(cascade = CascadeType.ALL, mappedBy = "role")
private List<RoleRight> roleRights; private List<RoleRight> roleRights;
@JoinColumns({
@JoinColumn(name = "card_template_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumns( {
@JoinColumn(name = "card_template_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)}) @JoinColumn(name = "card_template_id", referencedColumnName = "id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne @ManyToOne
private CardTemplate cardTemplate; private CardTemplate cardTemplate;
@JoinColumn(name = "events_id", referencedColumnName = "events_id", nullable = false)
@ManyToOne(optional = false)
private Event event;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "role") @OneToMany(cascade = CascadeType.ALL, mappedBy = "role")
private List<Discount> discounts; private List<Discount> discounts;
@ManyToMany(mappedBy = "roles") @ManyToMany(mappedBy = "roles")
private List<NewsGroup> newsGroups; private List<NewsGroup> newsGroups;
@Version @Version
@Column(nullable = false) @Column(nullable = false)
private int jpaVersionField; private int jpaVersionField;
...@@ -73,12 +81,12 @@ public class Role implements EventChildInterface { ...@@ -73,12 +81,12 @@ public class Role implements EventChildInterface {
public Role() { public Role() {
} }
public Role(EventPk rolesId) { public Role(Event event) {
this.id = rolesId; this.id = new EventPk(event);
} }
public Role(EventPk rolesId, String roleName) { public Role(Event event, String roleName) {
this.id = rolesId; this(event);
this.name = roleName; this.name = roleName;
} }
...@@ -106,14 +114,6 @@ public class Role implements EventChildInterface { ...@@ -106,14 +114,6 @@ public class Role implements EventChildInterface {
this.cardTemplate = cardTemplatesId; this.cardTemplate = cardTemplatesId;
} }
public Event getEvent() {
return event;
}
public void setEvent(Event eventsId) {
this.event = eventsId;
}
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 0; int hash = 0;
......
...@@ -34,28 +34,28 @@ import javax.persistence.Version; ...@@ -34,28 +34,28 @@ import javax.persistence.Version;
* @ NamedQuery ( name = "RoleRight.findByExecute" , query = * @ NamedQuery ( name = "RoleRight.findByExecute" , query =
* "SELECT r FROM RoleRight r WHERE r.execute = :execute" ) * "SELECT r FROM RoleRight r WHERE r.execute = :execute" )
*/}) */})
public class RoleRight implements EventChildInterface{ public class RoleRight implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
private EventPk id; private EventPk id;
@Column(name = "read_permission", nullable = false) @Column(name = "read_permission", nullable = false)
private boolean read; private boolean read = false;
@Column(name = "write_permission", nullable = false) @Column(name = "write_permission", nullable = false)
private boolean write; private boolean write = false;
@Column(name = "execute_permission", nullable = false) @Column(name = "execute_permission", nullable = false)
private boolean execute; private boolean execute = false;
@JoinColumn(name = "access_rights_id", referencedColumnName = "access_rights_id") @JoinColumn(name = "access_right_id", referencedColumnName = "id")
@ManyToOne @ManyToOne
private AccessRight accessRight; private AccessRight accessRight;
@JoinColumns({ @JoinColumns( {
@JoinColumn(name = "role_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false), @JoinColumn(name = "role_id", referencedColumnName = "id", nullable = false, updatable = false),
@JoinColumn(name = "role_event_id", referencedColumnName = "events_pk_id", nullable = false) }) @JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Role role; private Role role;
...@@ -66,14 +66,17 @@ public class RoleRight implements EventChildInterface{ ...@@ -66,14 +66,17 @@ public class RoleRight implements EventChildInterface{
public RoleRight() { public RoleRight() {
} }
public RoleRight(EventPk roleRights) { public RoleRight(Event event) {
this.id = roleRights; this.id = new EventPk(event);
} }
public RoleRight(EventPk roleRights, boolean read, boolean write) { public RoleRight(Role role, AccessRight right, boolean read, boolean write, boolean execute) {
this.id = roleRights; this(role.getId().getEvent());
this.role = role;
this.accessRight = right;
this.read = read; this.read = read;
this.write = write; this.write = write;
this.execute = execute;
} }
public boolean getRead() { public boolean getRead() {
......
...@@ -7,6 +7,9 @@ package fi.insomnia.bortal.model; ...@@ -7,6 +7,9 @@ package fi.insomnia.bortal.model;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.EmbeddedId; import javax.persistence.EmbeddedId;
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;
...@@ -26,12 +29,14 @@ import javax.persistence.Version; ...@@ -26,12 +29,14 @@ import javax.persistence.Version;
@NamedQuery(name = "UserImage.findByName", query = "SELECT u FROM UserImage u WHERE u.name = :name"), @NamedQuery(name = "UserImage.findByName", query = "SELECT u FROM UserImage u WHERE u.name = :name"),
@NamedQuery(name = "UserImage.findByDescription", query = "SELECT u FROM UserImage u WHERE u.description = :description"), @NamedQuery(name = "UserImage.findByDescription", query = "SELECT u FROM UserImage u WHERE u.description = :description"),
@NamedQuery(name = "UserImage.findByMimeType", query = "SELECT u FROM UserImage u WHERE u.mimeType = :mimeType") }) @NamedQuery(name = "UserImage.findByMimeType", query = "SELECT u FROM UserImage u WHERE u.mimeType = :mimeType") })
public class UserImage implements EventChildInterface{ public class UserImage implements ModelInterface<Integer> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @Id
private EventPk id; @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_image_id", nullable = false)
private Integer id;
@Column(name = "name") @Column(name = "name")
private String name; private String name;
...@@ -47,7 +52,7 @@ public class UserImage implements EventChildInterface{ ...@@ -47,7 +52,7 @@ public class UserImage implements EventChildInterface{
@Column(name = "image_data") @Column(name = "image_data")
private byte[] imageData; private byte[] imageData;
@JoinColumn(name = "users_id", referencedColumnName = "users_id") @JoinColumn(name = "user_id", referencedColumnName = "id")
@ManyToOne @ManyToOne
private User user; private User user;
...@@ -58,8 +63,8 @@ public class UserImage implements EventChildInterface{ ...@@ -58,8 +63,8 @@ public class UserImage implements EventChildInterface{
public UserImage() { public UserImage() {
} }
public UserImage(EventPk userImagesId) { public UserImage(User user) {
this.id = userImagesId; this.user = user;
} }
public String getName() { public String getName() {
...@@ -125,7 +130,7 @@ public class UserImage implements EventChildInterface{ ...@@ -125,7 +130,7 @@ public class UserImage implements EventChildInterface{
* @return the id * @return the id
*/ */
@Override @Override
public EventPk getId() { public Integer getId() {
return id; return id;
} }
...@@ -134,7 +139,7 @@ public class UserImage implements EventChildInterface{ ...@@ -134,7 +139,7 @@ public class UserImage implements EventChildInterface{
* the id to set * the id to set
*/ */
@Override @Override
public void setId(EventPk id) { public void setId(Integer id) {
this.id = id; this.id = id;
} }
......
...@@ -31,26 +31,29 @@ import javax.persistence.Version; ...@@ -31,26 +31,29 @@ import javax.persistence.Version;
@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 implements EventChildInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@EmbeddedId @EmbeddedId
private EventPk id; private EventPk id;
@Column(name = "score") @Column(name = "score")
private Integer score; private Integer score;
@Column(name = "vote_time", nullable = false) @Column(name = "vote_time", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar time; private Calendar time;
@JoinColumns({
@JoinColumn(name = "entries_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "entries_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne(optional = false)
@JoinColumns( {
@JoinColumn(name = "entry_id", referencedColumnName = "id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name = "event_id", referencedColumnName = "event_id", nullable = false, updatable = false, insertable = false) })
@ManyToOne(optional = false)
private CompoEntry compoEntry; private CompoEntry compoEntry;
@JoinColumn(name = "users_id", referencedColumnName = "users_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 @Version
@Column(nullable = false) @Column(nullable = false)
private int jpaVersionField; private int jpaVersionField;
...@@ -58,12 +61,12 @@ public class Vote implements EventChildInterface{ ...@@ -58,12 +61,12 @@ public class Vote implements EventChildInterface{
public Vote() { public Vote() {
} }
public Vote(EventPk votesId) { public Vote(Event event) {
this.id = votesId; this.id = new EventPk(event);
} }
public Vote(EventPk votesId, Calendar voteTime) { public Vote(Event event, Calendar voteTime) {
this.id = votesId; this(event);
this.time = voteTime; this.time = voteTime;
} }
......
...@@ -18,3 +18,5 @@ teststr=default locale test ...@@ -18,3 +18,5 @@ teststr=default locale test
defaultstr="Something default..." defaultstr="Something default..."
logout=H\u00E4ivy logout=H\u00E4ivy
nasty.user=paha k\u00E4ytt\u00E4j\u00E4 ei yrit\u00E4 haxoroida meid\u00E4n softaa. Kts. nasty.user=paha k\u00E4ytt\u00E4j\u00E4 ei yrit\u00E4 haxoroida meid\u00E4n softaa. Kts.
product.name=Tuote
product.price=Hinta
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!