Skip to content
Snippets Groups Projects
Commit 22d44446 authored by Odin Velle Ulvestad's avatar Odin Velle Ulvestad
Browse files

Merge branch 'scan_dev' into 'develop'

refactor scan class

See merge request !58
parents 52afb827 107b5608
No related branches found
No related tags found
2 merge requests!71Added invoices test data,!58refactor scan class
......@@ -19,8 +19,9 @@ public class Scan {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "parcel_id", insertable=false, updatable=false )
private int parcelId;
@ManyToOne
@Column(name = "parcel_id")
private Parcel parcel;
@ManyToOne
@JoinColumn(name = "terminal_id")
......@@ -33,26 +34,24 @@ public class Scan {
@Column(name = "scanned_at")
private LocalDateTime scannedAt;
@ManyToOne
@JoinColumn(name = "parcel_id")
private Parcel parcel;
/**
* Constructs an instance of this class
*
* @param id unique id of this particular scan
* @param parcelId the parcel that is scanned
* @param terminalId the terminal id where the scan is executed
* @param statusId the status of the given parcel
* @param parcel the parcel that is scanned
* @param terminal the terminal where the scan is executed
* @param status the status of the given parcel
* @param scannedAt the date and time the scan was executed
*/
public Scan(int id, int parcelId, int terminalId, int statusId, LocalDateTime scannedAt, Parcel parcel) {
public Scan(int id, Parcel parcel, Terminal terminal, Status status, LocalDateTime scannedAt) {
if (checkId(id)) { // TODO: add checks for other parameters as well
this.id = id;
this.parcelId = parcelId;
this.scannedAt = scannedAt;
this.parcel = parcel;
this.terminal = terminal;
this.status = status;
this.scannedAt = scannedAt;
} else {
throw new IllegalArgumentException("one or more parameters have an invalid value");
}
......@@ -72,8 +71,8 @@ public class Scan {
return id;
}
public int getParcelId() {
return parcelId;
public Parcel getParcel() {
return this.parcel;
}
public Terminal getTerminal() {
......@@ -88,9 +87,6 @@ public class Scan {
return scannedAt;
}
public Parcel getParcel() {
return parcel;
}
/**
* Returns true if id has legal value, and false otherwise
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment