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,6 +23,14 @@ import org.eclipse.persistence.annotations.OptimisticLockingType; ...@@ -23,6 +23,14 @@ 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 {
public enum Type {
USER,
PLACE,
CARD,
PRODUCT,
UNKNOWN
}
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "event_time", nullable = false) @Column(name = "event_time", nullable = false)
...@@ -51,10 +59,80 @@ public class ReaderEvent extends GenericEntity { ...@@ -51,10 +59,80 @@ public class ReaderEvent extends GenericEntity {
@ManyToOne(optional = false) @ManyToOne(optional = false)
private Reader reader; private Reader reader;
public ReaderEvent(Calendar eventTime, PrintedCard card, 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.time = eventTime.getTime();
this.printedCard = card;
this.reader = reader; 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() { public ReaderEvent() {
...@@ -110,6 +188,9 @@ public class ReaderEvent extends GenericEntity { ...@@ -110,6 +188,9 @@ public class ReaderEvent extends GenericEntity {
} }
public Date getUpdatetime() { public Date getUpdatetime() {
if (updatetime == null)
return time;
return updatetime; return updatetime;
} }
...@@ -117,27 +198,4 @@ public class ReaderEvent extends GenericEntity { ...@@ -117,27 +198,4 @@ public class ReaderEvent extends GenericEntity {
this.updatetime = 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();
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!