Commit 2e74c684 by Tuukka Kivilahti

barcode stuff for printedcard and readerevent

1 parent 84fcc6ec
......@@ -15,7 +15,7 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=1
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
......@@ -90,7 +90,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=8
org.eclipse.jdt.core.formatter.indentation.size=4
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
......@@ -283,7 +283,7 @@ org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.char=tab
org.eclipse.jdt.core.formatter.tabulation.size=4
org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
......
cleanup_settings_version=2
eclipse.preferences.version=1
formatter_profile=_InsomniaConventions
formatter_profile=_Insomnia
formatter_settings_version=12
......@@ -51,14 +51,10 @@ public class PrintedCard extends GenericEntity {
@Temporal(TemporalType.TIMESTAMP)
private Calendar printTime;
@Column(name = "barcode")
private String barcode;
@Column(name = "card_enabled", nullable = false)
private boolean enabled = true;
@Column(name = "rfid_uid")
private String rfidUid;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "printedCard")
private List<ReaderEvent> readerEvents = new ArrayList<ReaderEvent>();
......@@ -112,13 +108,6 @@ public class PrintedCard extends GenericEntity {
this.printTime = printTime;
}
public String getBarcode() {
return barcode;
}
public void setBarcode(String barcode) {
this.barcode = barcode;
}
public boolean getEnabled() {
return enabled;
......@@ -128,14 +117,6 @@ public class PrintedCard extends GenericEntity {
this.enabled = cardEnabled;
}
public String getRfidUid() {
return rfidUid;
}
public void setRfidUid(String rfidUid) {
this.rfidUid = rfidUid;
}
public List<ReaderEvent> getReaderEvents() {
return readerEvents;
}
......
......@@ -23,121 +23,179 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class ReaderEvent extends GenericEntity {
private static final long serialVersionUID = 1L;
@Column(name = "event_time", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date time;
@Column(name = "event_updated")
@Temporal(TemporalType.TIMESTAMP)
private Date updatetime;
@Column(name = "value")
private String value;
@Lob
@Column(name = "notes")
private String notes;
@Column(nullable = false)
private Integer gamePoint = 0;
@JoinColumn(name = "printed_cards_id", referencedColumnName = "id", nullable = true, updatable = false)
@ManyToOne(optional = false)
private PrintedCard printedCard;
@JoinColumn(name = "readers_id", referencedColumnName = "id", nullable = false, updatable = false)
@ManyToOne(optional = false)
private Reader reader;
public ReaderEvent(Calendar eventTime, PrintedCard card, Reader reader) {
this.time = eventTime.getTime();
this.printedCard = card;
this.reader = reader;
}
public ReaderEvent() {
super();
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public Date getTime() {
return time;
}
public void setTime(Date eventTime) {
this.time = eventTime;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public PrintedCard getPrintedCard() {
return printedCard;
}
public void setPrintedCard(PrintedCard printedCardsId) {
this.printedCard = printedCardsId;
}
public Reader getReader() {
return reader;
}
public void setReader(Reader readersId) {
this.reader = readersId;
}
public void setGamePoint(Integer gamePoint) {
this.gamePoint = gamePoint;
}
public Integer getGamePoint() {
return gamePoint;
}
public Date getUpdatetime() {
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
public String getSeenSince() {
Date comptime = updatetime;
if (comptime == null)
{
comptime = time;
}
long diffSec = (new Date().getTime() - comptime.getTime()) / 1000;
long secs = diffSec % 60;
long diffMin = diffSec / 60;
long mins = diffMin % 60;
long hours = diffMin / 60;
StringBuilder ret = new StringBuilder();
if (hours > 0) {
ret.append(hours).append(" h ");
}
if (hours > 0 || mins > 0) {
ret.append(mins).append(" min ");
}
ret.append(secs).append(" sec");
return ret.toString();
}
public enum Type {
USER,
PLACE,
CARD,
PRODUCT,
UNKNOWN
}
private static final long serialVersionUID = 1L;
@Column(name = "event_time", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date time;
@Column(name = "event_updated")
@Temporal(TemporalType.TIMESTAMP)
private Date updatetime;
@Column(name = "value")
private String value;
@Lob
@Column(name = "notes")
private String notes;
@Column(nullable = false)
private Integer gamePoint = 0;
@JoinColumn(name = "printed_cards_id", referencedColumnName = "id", nullable = true, updatable = false)
@ManyToOne(optional = false)
private PrintedCard printedCard;
@JoinColumn(name = "readers_id", referencedColumnName = "id", nullable = false, updatable = false)
@ManyToOne(optional = false)
private Reader reader;
@JoinColumn(name = "event_users_id", referencedColumnName = "id", nullable = true, updatable = false)
@ManyToOne(optional = false)
private EventUser user;
@JoinColumn(name = "places_id", referencedColumnName = "id", nullable = true, updatable = false)
@ManyToOne(optional = false)
private Place place;
@JoinColumn(name = "products_id", referencedColumnName = "id", nullable = true, updatable = false)
@ManyToOne(optional = false)
private Product product;
private Type type;
public EventUser getUser() {
return user;
}
public void setUser(EventUser user) {
this.user = user;
}
public Place getPlace() {
return place;
}
public void setPlace(Place place) {
this.place = place;
}
public Product getProduct() {
return product;
}
public void setProduct(Product product) {
this.product = product;
}
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
public ReaderEvent(Calendar eventTime, Reader reader, String value) {
this(eventTime, reader, value, null, null, null, null, Type.UNKNOWN);
}
public ReaderEvent(Calendar eventTime, Reader reader, String value, Type type) {
this(eventTime, reader, value, null, null, null, null, type);
}
public ReaderEvent(Calendar eventTime, Reader reader, String value, PrintedCard card, EventUser user, Place place, Product product, Type type) {
this.time = eventTime.getTime();
this.reader = reader;
this.value = value;
this.user = user;
this.printedCard = card;
this.user = user;
this.place = place;
this.product = product;
if (type == null)
type = Type.UNKNOWN;
this.type = type;
}
public ReaderEvent() {
super();
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public Date getTime() {
return time;
}
public void setTime(Date eventTime) {
this.time = eventTime;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public PrintedCard getPrintedCard() {
return printedCard;
}
public void setPrintedCard(PrintedCard printedCardsId) {
this.printedCard = printedCardsId;
}
public Reader getReader() {
return reader;
}
public void setReader(Reader readersId) {
this.reader = readersId;
}
public void setGamePoint(Integer gamePoint) {
this.gamePoint = gamePoint;
}
public Integer getGamePoint() {
return gamePoint;
}
public Date getUpdatetime() {
if (updatetime == null)
return time;
return updatetime;
}
public void setUpdatetime(Date updatetime) {
this.updatetime = updatetime;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!