Commit 11e3b92e by Juho Juopperi

model cleanup

1 parent 166211b2
...@@ -26,7 +26,7 @@ import javax.persistence.Version; ...@@ -26,7 +26,7 @@ import javax.persistence.Version;
@Table(name = "discounts") @Table(name = "discounts")
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "Discount.findAll", query = "SELECT d FROM Discount d"), @NamedQuery(name = "Discount.findAll", query = "SELECT d FROM Discount d"),
@NamedQuery(name = "Discount.findByDiscountsId", query = "SELECT d FROM Discount d WHERE d.id = :id"), @NamedQuery(name = "Discount.findById", query = "SELECT d FROM Discount d WHERE d.id = :id"),
@NamedQuery(name = "Discount.findByPercentage", query = "SELECT d FROM Discount d WHERE d.percentage = :percentage"), @NamedQuery(name = "Discount.findByPercentage", query = "SELECT d FROM Discount d WHERE d.percentage = :percentage"),
@NamedQuery(name = "Discount.findByCode", query = "SELECT d FROM Discount d WHERE d.code = :code"), @NamedQuery(name = "Discount.findByCode", query = "SELECT d FROM Discount d WHERE d.code = :code"),
@NamedQuery(name = "Discount.findByDetails", query = "SELECT d FROM Discount d WHERE d.details = :details"), @NamedQuery(name = "Discount.findByDetails", query = "SELECT d FROM Discount d WHERE d.details = :details"),
......
...@@ -27,8 +27,8 @@ import javax.persistence.Version; ...@@ -27,8 +27,8 @@ import javax.persistence.Version;
@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.findByProductsId", query = "SELECT p FROM Product p WHERE p.productsId = :productsId"), @NamedQuery(name = "Product.findById", query = "SELECT p FROM Product p WHERE p.id = :id"),
@NamedQuery(name = "Product.findByProductName", query = "SELECT p FROM Product p WHERE p.productName = :productName"), @NamedQuery(name = "Product.findByProductName", query = "SELECT p FROM Product p WHERE p.name = :name"),
@NamedQuery(name = "Product.findByPrice", query = "SELECT p FROM Product p WHERE p.price = :price"), @NamedQuery(name = "Product.findByPrice", query = "SELECT p FROM Product p WHERE p.price = :price"),
@NamedQuery(name = "Product.findBySort", query = "SELECT p FROM Product p WHERE p.sort = :sort"), @NamedQuery(name = "Product.findBySort", query = "SELECT p FROM Product p WHERE p.sort = :sort"),
@NamedQuery(name = "Product.findByBarcode", query = "SELECT p FROM Product p WHERE p.barcode = :barcode") }) @NamedQuery(name = "Product.findByBarcode", query = "SELECT p FROM Product p WHERE p.barcode = :barcode") })
...@@ -41,7 +41,7 @@ public class Product implements ModelInterface { ...@@ -41,7 +41,7 @@ public class Product implements ModelInterface {
private Integer id; private Integer id;
@Column(name = "product_name") @Column(name = "product_name")
private String productName; private String name;
@Column(name = "price", nullable = false) @Column(name = "price", nullable = false)
private BigInteger price; private BigInteger price;
...@@ -82,12 +82,12 @@ public class Product implements ModelInterface { ...@@ -82,12 +82,12 @@ public class Product implements ModelInterface {
this.sort = sort; this.sort = sort;
} }
public String getProductName() { public String getName() {
return productName; return name;
} }
public void setProductName(String productName) { public void setName(String productName) {
this.productName = productName; this.name = productName;
} }
public BigInteger getPrice() { public BigInteger getPrice() {
......
...@@ -20,30 +20,35 @@ import javax.persistence.Version; ...@@ -20,30 +20,35 @@ import javax.persistence.Version;
/** /**
* *
* @author jkj
*/ */
@Entity @Entity
@Table(name = "readers") @Table(name = "readers")
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "Reader.findAll", query = "SELECT r FROM Reader r"), @NamedQuery(name = "Reader.findAll", query = "SELECT r FROM Reader r"),
@NamedQuery(name = "Reader.findByReadersId", query = "SELECT r FROM Reader r WHERE r.readersId = :readersId"), @NamedQuery(name = "Reader.findById", query = "SELECT r FROM Reader r WHERE r.id = :id"),
@NamedQuery(name = "Reader.findByReaderId", query = "SELECT r FROM Reader r WHERE r.readerId = :readerId"), @NamedQuery(name = "Reader.findByIdentification", query = "SELECT r FROM Reader r WHERE r.identification = :identification"),
@NamedQuery(name = "Reader.findByReaderDescription", query = "SELECT r FROM Reader r WHERE r.readerDescription = :readerDescription") }) @NamedQuery(name = "Reader.findByDescription", query = "SELECT r FROM Reader r WHERE r.description = :description") })
public class Reader implements ModelInterface { public class Reader implements ModelInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
@Column(name = "readers_id", nullable = false) @Column(name = "readers_id", nullable = false)
private Integer id; private Integer id;
@Column(name = "reader_id")
private String readerId; @Column(name = "reader_ident")
private String identification;
@Column(name = "reader_description") @Column(name = "reader_description")
private String readerDescription; private String description;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "readersId")
private List<ReaderEvent> readerEventList; @OneToMany(cascade = CascadeType.ALL, mappedBy = "reader")
private List<ReaderEvent> events;
@JoinColumn(name = "locations_id", referencedColumnName = "locations_id") @JoinColumn(name = "locations_id", referencedColumnName = "locations_id")
@ManyToOne @ManyToOne
private Location locationsId; private Location location;
@Version @Version
@Column(nullable = false) @Column(nullable = false)
private int jpaVersionField; private int jpaVersionField;
...@@ -55,36 +60,36 @@ public class Reader implements ModelInterface { ...@@ -55,36 +60,36 @@ public class Reader implements ModelInterface {
this.id = readersId; this.id = readersId;
} }
public String getReaderId() { public String getIdentification() {
return readerId; return identification;
} }
public void setReaderId(String readerId) { public void setIdentification(String readerId) {
this.readerId = readerId; this.identification = readerId;
} }
public String getReaderDescription() { public String getDescription() {
return readerDescription; return description;
} }
public void setReaderDescription(String readerDescription) { public void setDescription(String readerDescription) {
this.readerDescription = readerDescription; this.description = readerDescription;
} }
public List<ReaderEvent> getReaderEventList() { public List<ReaderEvent> getEvents() {
return readerEventList; return events;
} }
public void setReaderEventList(List<ReaderEvent> readerEventList) { public void setEvents(List<ReaderEvent> readerEventList) {
this.readerEventList = readerEventList; this.events = readerEventList;
} }
public Location getLocationsId() { public Location getLocation() {
return locationsId; return location;
} }
public void setLocationsId(Location locationsId) { public void setLocation(Location locationsId) {
this.locationsId = locationsId; this.location = locationsId;
} }
@Override @Override
...@@ -111,7 +116,7 @@ public class Reader implements ModelInterface { ...@@ -111,7 +116,7 @@ public class Reader implements ModelInterface {
@Override @Override
public String toString() { public String toString() {
return "fi.insomnia.bortal.model.Reader[readersId=" + getId() + "]"; return "fi.insomnia.bortal.model.Reader[id=" + getId() + "]";
} }
/** /**
......
...@@ -20,33 +20,37 @@ import javax.persistence.Version; ...@@ -20,33 +20,37 @@ import javax.persistence.Version;
/** /**
* *
* @author jkj
*/ */
@Entity @Entity
@Table(name = "reader_events") @Table(name = "reader_events")
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "ReaderEvent.findAll", query = "SELECT r FROM ReaderEvent r"), @NamedQuery(name = "ReaderEvent.findAll", query = "SELECT r FROM ReaderEvent r"),
@NamedQuery(name = "ReaderEvent.findByReaderEventsId", query = "SELECT r FROM ReaderEvent r WHERE r.readerEventsId = :readerEventsId"), @NamedQuery(name = "ReaderEvent.findById", query = "SELECT r FROM ReaderEvent r WHERE r.id = :id"),
@NamedQuery(name = "ReaderEvent.findByEventTime", query = "SELECT r FROM ReaderEvent r WHERE r.eventTime = :eventTime"), @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 ModelInterface { public class ReaderEvent implements ModelInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
@Column(name = "reader_events_id", nullable = false) @Column(name = "reader_events_id", nullable = false)
private Integer id; private Integer id;
@Column(name = "event_time", nullable = false) @Column(name = "event_time", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date eventTime; private Date time;
@Column(name = "value") @Column(name = "value")
private String value; private String value;
@JoinColumn(name = "printed_cards_id", referencedColumnName = "printed_cards_id", nullable = false) @JoinColumn(name = "printed_cards_id", referencedColumnName = "printed_cards_id", nullable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private PrintedCard printedCardsId; private PrintedCard printedCard;
@JoinColumn(name = "readers_id", referencedColumnName = "readers_id", nullable = false) @JoinColumn(name = "readers_id", referencedColumnName = "readers_id", nullable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Reader readersId; private Reader reader;
@Version @Version
@Column(nullable = false) @Column(nullable = false)
private int jpaVersionField; private int jpaVersionField;
...@@ -60,15 +64,15 @@ public class ReaderEvent implements ModelInterface { ...@@ -60,15 +64,15 @@ public class ReaderEvent implements ModelInterface {
public ReaderEvent(Integer readerEventsId, Date eventTime) { public ReaderEvent(Integer readerEventsId, Date eventTime) {
this.id = readerEventsId; this.id = readerEventsId;
this.eventTime = eventTime; this.time = eventTime;
} }
public Date getEventTime() { public Date getTime() {
return eventTime; return time;
} }
public void setEventTime(Date eventTime) { public void setTime(Date eventTime) {
this.eventTime = eventTime; this.time = eventTime;
} }
public String getValue() { public String getValue() {
...@@ -79,20 +83,20 @@ public class ReaderEvent implements ModelInterface { ...@@ -79,20 +83,20 @@ public class ReaderEvent implements ModelInterface {
this.value = value; this.value = value;
} }
public PrintedCard getPrintedCardsId() { public PrintedCard getPrintedCard() {
return printedCardsId; return printedCard;
} }
public void setPrintedCardsId(PrintedCard printedCardsId) { public void setPrintedCard(PrintedCard printedCardsId) {
this.printedCardsId = printedCardsId; this.printedCard = printedCardsId;
} }
public Reader getReadersId() { public Reader getReader() {
return readersId; return reader;
} }
public void setReadersId(Reader readersId) { public void setReader(Reader readersId) {
this.readersId = readersId; this.reader = readersId;
} }
@Override @Override
...@@ -119,8 +123,7 @@ public class ReaderEvent implements ModelInterface { ...@@ -119,8 +123,7 @@ public class ReaderEvent implements ModelInterface {
@Override @Override
public String toString() { public String toString() {
return "fi.insomnia.bortal.model.ReaderEvent[readerEventsId=" + getId() return "fi.insomnia.bortal.model.ReaderEvent[id=" + getId() + "]";
+ "]";
} }
/** /**
......
...@@ -11,6 +11,7 @@ import javax.persistence.Column; ...@@ -11,6 +11,7 @@ import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
...@@ -26,8 +27,8 @@ import javax.persistence.Version; ...@@ -26,8 +27,8 @@ import javax.persistence.Version;
@Table(name = "roles") @Table(name = "roles")
@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.findByRolesId", query = "SELECT r FROM Role r WHERE r.rolesId = :rolesId"), @NamedQuery(name = "Role.findById", query = "SELECT r FROM Role r WHERE r.id = :id"),
@NamedQuery(name = "Role.findByRoleName", query = "SELECT r FROM Role r WHERE r.roleName = :roleName") }) @NamedQuery(name = "Role.findByRoleName", query = "SELECT r FROM Role r WHERE r.name = :name") })
public class Role implements ModelInterface { public class Role implements ModelInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -37,19 +38,21 @@ public class Role implements ModelInterface { ...@@ -37,19 +38,21 @@ public class Role implements ModelInterface {
private Integer id; private Integer id;
@Column(name = "role_name", nullable = false) @Column(name = "role_name", nullable = false)
private String roleName; private String name;
@JoinTable(name = "role_memberships")
@ManyToMany(cascade = CascadeType.ALL) @ManyToMany(cascade = CascadeType.ALL)
private List<User> users; private List<User> users;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "rolesId") @ManyToMany
private List<RoleInheritance> roleInheritanceList; @JoinTable(name = "role_inheritance")
private List<Role> children;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "inherits") @ManyToMany(mappedBy = "children")
private List<RoleInheritance> roleInheritanceList1; private List<Role> parents;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "rolesId") @OneToMany(cascade = CascadeType.ALL, mappedBy = "role")
private List<RoleRight> roleRightList; private List<RoleRight> roleRights;
@JoinColumn(name = "card_templates_id", referencedColumnName = "card_templates_id") @JoinColumn(name = "card_templates_id", referencedColumnName = "card_templates_id")
@ManyToOne @ManyToOne
...@@ -57,7 +60,7 @@ public class Role implements ModelInterface { ...@@ -57,7 +60,7 @@ public class Role implements ModelInterface {
@JoinColumn(name = "events_id", referencedColumnName = "events_id", nullable = false) @JoinColumn(name = "events_id", referencedColumnName = "events_id", nullable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Event eventsId; private Event event;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "role") @OneToMany(cascade = CascadeType.ALL, mappedBy = "role")
private List<Discount> discounts; private List<Discount> discounts;
...@@ -75,40 +78,23 @@ public class Role implements ModelInterface { ...@@ -75,40 +78,23 @@ public class Role implements ModelInterface {
public Role(Integer rolesId, String roleName) { public Role(Integer rolesId, String roleName) {
this.id = rolesId; this.id = rolesId;
this.roleName = roleName; this.name = roleName;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public List<RoleInheritance> getRoleInheritanceList() {
return roleInheritanceList;
}
public void setRoleInheritanceList(List<RoleInheritance> roleInheritanceList) {
this.roleInheritanceList = roleInheritanceList;
} }
public List<RoleInheritance> getRoleInheritanceList1() { public String getName() {
return roleInheritanceList1; return name;
} }
public void setRoleInheritanceList1( public void setName(String roleName) {
List<RoleInheritance> roleInheritanceList1) { this.name = roleName;
this.roleInheritanceList1 = roleInheritanceList1;
} }
public List<RoleRight> getRoleRightList() { public List<RoleRight> getRoleRights() {
return roleRightList; return roleRights;
} }
public void setRoleRightList(List<RoleRight> roleRightList) { public void setRoleRights(List<RoleRight> roleRightList) {
this.roleRightList = roleRightList; this.roleRights = roleRightList;
} }
public CardTemplate getCardTemplate() { public CardTemplate getCardTemplate() {
...@@ -119,12 +105,12 @@ public class Role implements ModelInterface { ...@@ -119,12 +105,12 @@ public class Role implements ModelInterface {
this.cardTemplate = cardTemplatesId; this.cardTemplate = cardTemplatesId;
} }
public Event getEventsId() { public Event getEvent() {
return eventsId; return event;
} }
public void setEventsId(Event eventsId) { public void setEvent(Event eventsId) {
this.eventsId = eventsId; this.event = eventsId;
} }
@Override @Override
...@@ -151,7 +137,7 @@ public class Role implements ModelInterface { ...@@ -151,7 +137,7 @@ public class Role implements ModelInterface {
@Override @Override
public String toString() { public String toString() {
return "fi.insomnia.bortal.model.Role[rolesId=" + getId() + "]"; return "fi.insomnia.bortal.model.Role[id=" + getId() + "]";
} }
/** /**
...@@ -199,4 +185,20 @@ public class Role implements ModelInterface { ...@@ -199,4 +185,20 @@ public class Role implements ModelInterface {
public List<Discount> getDiscounts() { public List<Discount> getDiscounts() {
return discounts; return discounts;
} }
public void setParents(List<Role> parents) {
this.parents = parents;
}
public List<Role> getParents() {
return parents;
}
public void setChildren(List<Role> children) {
this.children = children;
}
public List<Role> getChildren() {
return children;
}
} }
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
/**
*
* @author jkj
*/
@Entity
@Table(name = "role_inheritance", uniqueConstraints = { @UniqueConstraint(columnNames = {
"roles_id", "inherits" }) })
@NamedQueries( {
@NamedQuery(name = "RoleInheritance.findAll", query = "SELECT r FROM RoleInheritance r"),
@NamedQuery(name = "RoleInheritance.findByRoleInheritanceId", query = "SELECT r FROM RoleInheritance r WHERE r.roleInheritanceId = :roleInheritanceId") })
public class RoleInheritance implements ModelInterface {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "role_inheritance_id", nullable = false)
private Integer id;
@JoinColumn(name = "roles_id", referencedColumnName = "roles_id", nullable = false)
@ManyToOne(optional = false)
private Role rolesId;
@JoinColumn(name = "inherits", referencedColumnName = "roles_id", nullable = false)
@ManyToOne(optional = false)
private Role inherits;
@Version
@Column(nullable = false)
private int jpaVersionField;
public RoleInheritance() {
}
public RoleInheritance(Integer roleInheritanceId) {
this.id = roleInheritanceId;
}
public Role getRolesId() {
return rolesId;
}
public void setRolesId(Role rolesId) {
this.rolesId = rolesId;
}
public Role getInherits() {
return inherits;
}
public void setInherits(Role inherits) {
this.inherits = inherits;
}
@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof RoleInheritance)) {
return false;
}
RoleInheritance other = (RoleInheritance) object;
if ((this.getId() == null && other.getId() != null)
|| (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.RoleInheritance[roleInheritanceId="
+ getId() + "]";
}
/**
* @return the id
*/
public Integer getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(Integer id) {
this.id = id;
}
/**
* @return the jpaVersionField
*/
public int getJpaVersionField() {
return jpaVersionField;
}
/**
* @param jpaVersionField
* the jpaVersionField to set
*/
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
}
...@@ -22,9 +22,10 @@ import javax.persistence.Version; ...@@ -22,9 +22,10 @@ import javax.persistence.Version;
@Table(name = "role_rights") @Table(name = "role_rights")
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "RoleRight.findAll", query = "SELECT r FROM RoleRight r"), @NamedQuery(name = "RoleRight.findAll", query = "SELECT r FROM RoleRight r"),
@NamedQuery(name = "RoleRight.findByRoleRights", query = "SELECT r FROM RoleRight r WHERE r.roleRights = :roleRights"), @NamedQuery(name = "RoleRight.findById", query = "SELECT r FROM RoleRight r WHERE r.id = :id"),
@NamedQuery(name = "RoleRight.findByRead", query = "SELECT r FROM RoleRight r WHERE r.read = :read"), @NamedQuery(name = "RoleRight.findByRead", query = "SELECT r FROM RoleRight r WHERE r.read = :read"),
@NamedQuery(name = "RoleRight.findByWrite", query = "SELECT r FROM RoleRight r WHERE r.write = :write") }) @NamedQuery(name = "RoleRight.findByWrite", query = "SELECT r FROM RoleRight r WHERE r.write = :write"),
@NamedQuery(name = "RoleRight.findByExecute", query = "SELECT r FROM RoleRight r WHERE r.execute = :execute") })
public class RoleRight implements ModelInterface { public class RoleRight implements ModelInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -37,13 +38,18 @@ public class RoleRight implements ModelInterface { ...@@ -37,13 +38,18 @@ public class RoleRight implements ModelInterface {
@Column(name = "write", nullable = false) @Column(name = "write", nullable = false)
private boolean write; private boolean write;
// TODO: add execute
@Column(name = "write", nullable = false)
private boolean execute;
@JoinColumn(name = "access_rights_id", referencedColumnName = "access_rights_id") @JoinColumn(name = "access_rights_id", referencedColumnName = "access_rights_id")
@ManyToOne @ManyToOne
private AccessRight accessRightsId; private AccessRight accessRight;
@JoinColumn(name = "roles_id", referencedColumnName = "roles_id", nullable = false) @JoinColumn(name = "roles_id", referencedColumnName = "roles_id", nullable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Role rolesId; private Role role;
@Version @Version
@Column(nullable = false) @Column(nullable = false)
private int jpaVersionField; private int jpaVersionField;
...@@ -77,20 +83,20 @@ public class RoleRight implements ModelInterface { ...@@ -77,20 +83,20 @@ public class RoleRight implements ModelInterface {
this.write = write; this.write = write;
} }
public AccessRight getAccessRightsId() { public AccessRight getAccessRight() {
return accessRightsId; return accessRight;
} }
public void setAccessRightsId(AccessRight accessRightsId) { public void setAccessRight(AccessRight accessRightsId) {
this.accessRightsId = accessRightsId; this.accessRight = accessRightsId;
} }
public Role getRolesId() { public Role getRole() {
return rolesId; return role;
} }
public void setRolesId(Role rolesId) { public void setRole(Role rolesId) {
this.rolesId = rolesId; this.role = rolesId;
} }
@Override @Override
...@@ -149,4 +155,12 @@ public class RoleRight implements ModelInterface { ...@@ -149,4 +155,12 @@ public class RoleRight implements ModelInterface {
public void setJpaVersionField(int jpaVersionField) { public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField; this.jpaVersionField = jpaVersionField;
} }
public void setExecute(boolean execute) {
this.execute = execute;
}
public boolean isExecute() {
return execute;
}
} }
...@@ -27,7 +27,7 @@ import javax.persistence.Version; ...@@ -27,7 +27,7 @@ import javax.persistence.Version;
@Table(name = "users") @Table(name = "users")
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"), @NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"),
@NamedQuery(name = "User.findByUsersId", query = "SELECT u FROM User u WHERE u.usersId = :usersId"), @NamedQuery(name = "User.findById", query = "SELECT u FROM User u WHERE u.id = :id"),
@NamedQuery(name = "User.findByCreated", query = "SELECT u FROM User u WHERE u.created = :created"), @NamedQuery(name = "User.findByCreated", query = "SELECT u FROM User u WHERE u.created = :created"),
@NamedQuery(name = "User.findByActive", query = "SELECT u FROM User u WHERE u.active = :active"), @NamedQuery(name = "User.findByActive", query = "SELECT u FROM User u WHERE u.active = :active"),
@NamedQuery(name = "User.findByPassword", query = "SELECT u FROM User u WHERE u.password = :password"), @NamedQuery(name = "User.findByPassword", query = "SELECT u FROM User u WHERE u.password = :password"),
...@@ -46,51 +46,73 @@ import javax.persistence.Version; ...@@ -46,51 +46,73 @@ import javax.persistence.Version;
public class User implements ModelInterface { public class User implements ModelInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
@Column(name = "users_id", nullable = false) @Column(name = "users_id", nullable = false)
private Integer id; private Integer id;
@Column(name = "created", nullable = false) @Column(name = "created", nullable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date created; private Date created;
@Column(name = "active", nullable = false) @Column(name = "active", nullable = false)
private boolean active; private boolean active;
@Column(name = "password") @Column(name = "password")
private String password; private String password;
@Column(name = "lastname", nullable = false) @Column(name = "lastname", nullable = false)
private String lastname; private String lastname;
@Column(name = "firstnames", nullable = false) @Column(name = "firstnames", nullable = false)
private String firstnames; private String firstnames;
@Column(name = "birthday") @Column(name = "birthday")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date birthday; private Date birthday;
@Column(name = "nick") @Column(name = "nick")
private String nick; private String nick;
@Column(name = "email") @Column(name = "email")
private String email; private String email;
@Column(name = "address") @Column(name = "address")
private String address; private String address;
@Column(name = "zip") @Column(name = "zip")
private String zip; private String zip;
@Column(name = "postal_code") @Column(name = "postal_code")
private String postalCode; private String postalCode;
@Column(name = "town") @Column(name = "town")
private String town; private String town;
@Column(name = "phone") @Column(name = "phone")
private String phone; private String phone;
@Column(name = "female") @Column(name = "female")
private Boolean female; private Boolean female;
@Column(name = "login") @Column(name = "login")
private String login; private String login;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "voter") @OneToMany(cascade = CascadeType.ALL, mappedBy = "voter")
private List<Vote> votes; private List<Vote> votes;
@ManyToMany(cascade = CascadeType.ALL, mappedBy = "users") @ManyToMany(cascade = CascadeType.ALL, mappedBy = "users")
private List<Role> roles; private List<Role> roles;
@OneToMany(mappedBy = "usersId")
@OneToMany(mappedBy = "id")
private List<LogEntry> logEntryList; private List<LogEntry> logEntryList;
@OneToMany(mappedBy = "user") @OneToMany(mappedBy = "user")
private List<UserImage> userImageList; private List<UserImage> userImageList;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "users") @OneToMany(cascade = CascadeType.ALL, mappedBy = "users")
private List<CompoEntryParticipant> compoEntryParticipantList; private List<CompoEntryParticipant> compoEntryParticipantList;
@OneToMany(mappedBy = "creator") @OneToMany(mappedBy = "creator")
private List<CompoEntry> compoEntryList; private List<CompoEntry> compoEntryList;
...@@ -107,19 +129,20 @@ public class User implements ModelInterface { ...@@ -107,19 +129,20 @@ public class User implements ModelInterface {
private List<Place> currentPlaces; private List<Place> currentPlaces;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user") @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
private List<PrintedCard> printedCardList; private List<PrintedCard> printedCards;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user") @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
private List<AccountEvent> accountEventList; private List<AccountEvent> accountEvents;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user") @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
private List<DiscountInstance> discountInstanceList; private List<DiscountInstance> discountInstances;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "user") @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
private List<Bill> billList; private List<Bill> bills;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "seller") @OneToMany(cascade = CascadeType.ALL, mappedBy = "seller")
private List<AccountEvent> soldItems; private List<AccountEvent> soldItems;
@Version @Version
@Column(nullable = false) @Column(nullable = false)
private int jpaVersionField; private int jpaVersionField;
...@@ -333,37 +356,36 @@ public class User implements ModelInterface { ...@@ -333,37 +356,36 @@ public class User implements ModelInterface {
this.currentPlaces = placeList; this.currentPlaces = placeList;
} }
public List<PrintedCard> getPrintedCardList() { public List<PrintedCard> getPrintedCards() {
return printedCardList; return printedCards;
} }
public void setPrintedCardList(List<PrintedCard> printedCardList) { public void setPrintedCards(List<PrintedCard> printedCardList) {
this.printedCardList = printedCardList; this.printedCards = printedCardList;
} }
public List<AccountEvent> getAccountEventList() { public List<AccountEvent> getAccountEvents() {
return accountEventList; return accountEvents;
} }
public void setAccountEventList(List<AccountEvent> accountEventList) { public void setAccountEvents(List<AccountEvent> accountEventList) {
this.accountEventList = accountEventList; this.accountEvents = accountEventList;
} }
public List<DiscountInstance> getDiscountInstanceList() { public List<DiscountInstance> getDiscountInstances() {
return discountInstanceList; return discountInstances;
} }
public void setDiscountInstanceList( public void setDiscountInstances(List<DiscountInstance> discountInstanceList) {
List<DiscountInstance> discountInstanceList) { this.discountInstances = discountInstanceList;
this.discountInstanceList = discountInstanceList;
} }
public List<Bill> getBillList() { public List<Bill> getBills() {
return billList; return bills;
} }
public void setBillList(List<Bill> billList) { public void setBills(List<Bill> billList) {
this.billList = billList; this.bills = billList;
} }
@Override @Override
...@@ -390,7 +412,7 @@ public class User implements ModelInterface { ...@@ -390,7 +412,7 @@ public class User implements ModelInterface {
@Override @Override
public String toString() { public String toString() {
return "fi.insomnia.bortal.model.User[usersId=" + getId() + "]"; return "fi.insomnia.bortal.model.User[id=" + getId() + "]";
} }
/** /**
......
...@@ -17,34 +17,40 @@ import javax.persistence.Version; ...@@ -17,34 +17,40 @@ import javax.persistence.Version;
/** /**
* *
* @author jkj
*/ */
@Entity @Entity
@Table(name = "user_images") @Table(name = "user_images")
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "UserImage.findAll", query = "SELECT u FROM UserImage u"), @NamedQuery(name = "UserImage.findAll", query = "SELECT u FROM UserImage u"),
@NamedQuery(name = "UserImage.findByUserImagesId", query = "SELECT u FROM UserImage u WHERE u.userImagesId = :userImagesId"), @NamedQuery(name = "UserImage.findById", query = "SELECT u FROM UserImage u WHERE u.id = :id"),
@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 ModelInterface { public class UserImage implements ModelInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
@Column(name = "user_images_id", nullable = false) @Column(name = "user_images_id", nullable = false)
private Integer id; private Integer id;
@Column(name = "name") @Column(name = "name")
private String name; private String name;
@Column(name = "description") @Column(name = "description")
private String description; private String description;
@Column(name = "mime_type") @Column(name = "mime_type")
private String mimeType; private String mimeType;
@Lob @Lob
@Column(name = "image_data") @Column(name = "image_data")
private byte[] imageData; private byte[] imageData;
@JoinColumn(name = "users_id", referencedColumnName = "users_id") @JoinColumn(name = "users_id", referencedColumnName = "users_id")
@ManyToOne @ManyToOne
private User user; private User user;
@Version @Version
@Column(nullable = false) @Column(nullable = false)
private int jpaVersionField; private int jpaVersionField;
...@@ -112,8 +118,7 @@ public class UserImage implements ModelInterface { ...@@ -112,8 +118,7 @@ public class UserImage implements ModelInterface {
@Override @Override
public String toString() { public String toString() {
return "fi.insomnia.bortal.model.UserImage[userImagesId=" + getId() return "fi.insomnia.bortal.model.UserImage[id=" + getId() + "]";
+ "]";
} }
/** /**
......
...@@ -27,9 +27,9 @@ import javax.persistence.Version; ...@@ -27,9 +27,9 @@ import javax.persistence.Version;
"entries_id", "users_id" }) }) "entries_id", "users_id" }) })
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "Vote.findAll", query = "SELECT v FROM Vote v"), @NamedQuery(name = "Vote.findAll", query = "SELECT v FROM Vote v"),
@NamedQuery(name = "Vote.findByVotesId", query = "SELECT v FROM Vote v WHERE v.votesId = :votesId"), @NamedQuery(name = "Vote.findById", query = "SELECT v FROM Vote v WHERE v.id = :id"),
@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.findByVoteTime", query = "SELECT v FROM Vote v WHERE v.voteTime = :voteTime") }) @NamedQuery(name = "Vote.findByTime", query = "SELECT v FROM Vote v WHERE v.time = :time") })
public class Vote implements ModelInterface { public class Vote implements ModelInterface {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -40,7 +40,7 @@ public class Vote implements ModelInterface { ...@@ -40,7 +40,7 @@ public class Vote implements ModelInterface {
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 Date voteTime; private Date time;
@JoinColumn(name = "entries_id", referencedColumnName = "entries_id", nullable = false) @JoinColumn(name = "entries_id", referencedColumnName = "entries_id", nullable = false)
@ManyToOne(optional = false) @ManyToOne(optional = false)
private CompoEntry compoEntry; private CompoEntry compoEntry;
...@@ -60,7 +60,7 @@ public class Vote implements ModelInterface { ...@@ -60,7 +60,7 @@ public class Vote implements ModelInterface {
public Vote(Integer votesId, Date voteTime) { public Vote(Integer votesId, Date voteTime) {
this.id = votesId; this.id = votesId;
this.voteTime = voteTime; this.time = voteTime;
} }
public Integer getId() { public Integer getId() {
...@@ -79,12 +79,12 @@ public class Vote implements ModelInterface { ...@@ -79,12 +79,12 @@ public class Vote implements ModelInterface {
this.score = score; this.score = score;
} }
public Date getVoteTime() { public Date getTime() {
return voteTime; return time;
} }
public void setVoteTime(Date voteTime) { public void setTime(Date voteTime) {
this.voteTime = voteTime; this.time = voteTime;
} }
@Override @Override
...@@ -111,7 +111,7 @@ public class Vote implements ModelInterface { ...@@ -111,7 +111,7 @@ public class Vote implements ModelInterface {
@Override @Override
public String toString() { public String toString() {
return "fi.insomnia.bortal.model.Vote[votesId=" + id + "]"; return "fi.insomnia.bortal.model.Vote[id=" + id + "]";
} }
/** /**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!