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