Skip to content
Snippets Groups Projects
Commit e3717700 authored by Yokiza's avatar Yokiza
Browse files

Made some minor changes and added guardian conditions

Made some minor changes and added guardian conditions
parent 800238f0
No related branches found
No related tags found
4 merge requests!71Added invoices test data,!30Had to edit the server port in Application properties due to default port 8080...,!27Had to edit the server port in Application properties due to default port 8080...,!18Request for merging shipping order branch to develop
......@@ -7,42 +7,44 @@ import jakarta.persistence.Id;
/**
* Represents a shipping order -object in the query engine application.
*
* @author Joakim Røren Melum
* @version 0.1
* @date 01.03.2023
*/
public class ShippingOrder {
/***
* The ID of the shipping order.
*/
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "shippingOrder_id")
private long shippingOrder_id;
private long id;
/**
* The status ID of the shippingOrder.
*/
@Column(name = "shippingOrder_status_ID")
private long status_id;
private long statusId;
/**
* The ID of the sender of the shipping order.
*/
@Column(name = "senders_id")
private long senders_id;
@Column(name = "sender_id")
private long senderId;
/**
* The ID of the reciever of the shipping order.
* The ID of the receiver of the shipping order.
*/
@Column(name = "receivers_id")
private long receivers_id;
@Column(name = "receiver_id")
private long receiverId;
/**
* The date and time for the shipping order.
*/
@Column(name = "date_time")
private String date_time;
private String dateAndTime;
/**
* If the shipping order would ever be changed in a way that
......@@ -50,24 +52,35 @@ public class ShippingOrder {
* into the old shipping order id.
*/
@Column(name = "original_shipping_order_id")
private long original_shipping_order_id;
private long originalShippingOrderId;
/**
* Initialises the ShippingOrder-object.
* @param shippingOrder_id the id of the shippingOrder.
* @param status_id the id of the shippingOrder status.
* @param senders_id the id of the sender of the shippingOrder.
* @param receivers_id the id of the receivers of the shippingOrder.
* @param date_time the date and time.
* @param original_shipping_order_id the original shipping order id.
*
* @param id the id of the shippingOrder.
* @param statusId the id of the shippingOrder status.
* @param senderId the id of the sender of the shippingOrder.
* @param receiverId the id of the receivers of the shippingOrder.
* @param dateAndTime the date and time.
* @param originalShippingOrderId the original shipping order id.
*/
public ShippingOrder(long shippingOrder_id, long status_id, long senders_id, long receivers_id, String date_time, long original_shipping_order_id) {
this.shippingOrder_id = shippingOrder_id;
this.status_id = status_id;
this.senders_id = senders_id;
this.receivers_id = receivers_id;
this.date_time = date_time;
this.original_shipping_order_id = original_shipping_order_id;
public ShippingOrder(long id, long statusId, long senderId, long receiverId, String dateAndTime, long originalShippingOrderId) {
if ((checkId(id)) &&
(checkStatusId(statusId)) &&
(checkSenderId(senderId)) &&
(checkReceiverId(receiverId)) &&
(checkDateAndTime(dateAndTime)) &&
(checkOriginalShippingOrderId(originalShippingOrderId))
) {
this.id = id;
this.statusId = statusId;
this.senderId = senderId;
this.receiverId = receiverId;
this.dateAndTime = dateAndTime;
this.originalShippingOrderId = originalShippingOrderId;
} else {
throw new IllegalArgumentException("Invalid constructor param(s)!");
}
}
/**
......@@ -79,90 +92,182 @@ public class ShippingOrder {
/**
* @return shippingOrder ID
*/
public long getShippingOrder_id() {
return shippingOrder_id;
public long getId() {
return id;
}
/**
* Sets the shippingOrder ID
* @param shippingOrder_id to be set
*
* @param id to be set
*/
public void setShippingOrder_id(long shippingOrder_id) {
this.shippingOrder_id = shippingOrder_id;
public void setId(long id) {
if (checkId(id)) {
this.id = id;
} else {
throw new IllegalArgumentException("Invalid id!");
}
}
/**
* @return status id
*/
public long getStatus_id() {
return status_id;
public long getStatusId() {
return statusId;
}
/**
* Set the shippingorder status id
* @param status_id of the shipping order
* Set the status id
*
* @param statusId of the shipping order
*/
public void setStatus_id(long status_id) {
this.status_id = status_id;
public void setStatusId(long statusId) {
if (checkStatusId(statusId)) {
this.statusId = statusId;
} else {
throw new IllegalArgumentException("Invalid status id!");
}
}
/**
* @return the shippingorder senders id
* @return the shippingOrder senders id
*/
public long getSenders_id() {
return senders_id;
public long getSenderId() {
return senderId;
}
/**
* Sets the shipping orders senders id
* @param senders_id of the shipping order
*
* @param senderId of the shipping order
*/
public void setSenders_id(long senders_id) {
this.senders_id = senders_id;
public void setSenderId(long senderId) {
if (checkSenderId(senderId)) {
this.senderId = senderId;
} else {
throw new IllegalArgumentException("Invalid sender id!");
}
checkSenderId(senderId);
}
/**
* @return the shippingorder
* @return the shippingOrder
*/
public long getReceivers_id() {
return receivers_id;
public long getReceiverId() {
return receiverId;
}
/**
* Sets the recievers id of the shipping order
* @param receivers_id of the shipping order
* Sets the receiver id of the shipping order
*
* @param receiverId of the shipping order
*/
public void setReceivers_id(long receivers_id) {
this.receivers_id = receivers_id;
public void setReceiverId(long receiverId) {
if (checkReceiverId(receiverId)) {
this.receiverId = receiverId;
} else {
throw new IllegalArgumentException("Invalid receiver id!");
}
checkReceiverId(receiverId);
}
/**
* @return the shippingorder
* @return the shippingOrder
*/
public String getDate_time() {
return date_time;
public String getDateAndTime() {
return dateAndTime;
}
/**
* Sets the date and time of the shipping order
* @param date_time of the shipping order
*
* @param dateAndTime of the shipping order
*/
public void setDate_time(String date_time) {
this.date_time = date_time;
public void setDateAndTime(String dateAndTime) {
if (checkDateAndTime(dateAndTime)) {
this.dateAndTime = dateAndTime;
} else {
throw new IllegalArgumentException("Invalid date and time!");
}
}
/**
* @return the shippingorder
* @return the shippingOrder
*/
public long getOriginal_shipping_order_id() {
return original_shipping_order_id;
public long getOriginalShippingOrderId() {
return originalShippingOrderId;
}
/**
* Sets the original shipping order id to the shipping order
* @param original_shipping_order_id of the shipping order
*
* @param originalShippingOrderId of the shipping order
*/
public void setOriginalShippingOrderId(long originalShippingOrderId) {
if (checkOriginalShippingOrderId(originalShippingOrderId)) {
this.originalShippingOrderId = originalShippingOrderId;
} else {
throw new IllegalArgumentException("Invalid original shipping order id!");
}
}
/**
* Checks if the id is valid.
*
* @param input to be checked
* @return <code>TRUE</code> if the input is valid. <code>FALSE</code> if the input is invalid.
*/
private boolean checkId(long input) {
return (input > 0) && (input < Long.MAX_VALUE);
}
/**
* Checks if the status id is valid.
*
* @param input to be checked
* @return <code>TRUE</code> if the input is valid. <code>FALSE</code> if the input is invalid.
*/
private boolean checkStatusId(long input) {
return (input > 0) && (input < Long.MAX_VALUE);
}
/**
* Checks if the sender id is valid.
*
* @param input to be checked
* @return <code>TRUE</code> if the input is valid. <code>FALSE</code> if the input is invalid.
*/
private boolean checkSenderId(long input) {
return (input > 0) && (input < Long.MAX_VALUE);
}
/**
* Checks if the receiver id is valid.
*
* @param input to be checked
* @return <code>TRUE</code> if the input is valid. <code>FALSE</code> if the input is invalid.
*/
private boolean checkReceiverId(long input) {
return (input > 0) && (input < Long.MAX_VALUE);
}
/**
* Checks if the date and time is valid.
*
* @param input to be checked
* @return <code>TRUE</code> if the input is valid. <code>FALSE</code> if the input is invalid.
*/
private boolean checkDateAndTime(String input) {
return (input != null) && (!input.isEmpty()) && (!input.isBlank());
}
/**
* Checks if the original is valid.
*
* @param input to be checked
* @return <code>TRUE</code> if the input is valid. <code>FALSE</code> if the input is invalid.
*/
public void setOriginal_shipping_order_id(long original_shipping_order_id) {
this.original_shipping_order_id = original_shipping_order_id;
private boolean checkOriginalShippingOrderId(long input) {
return (input > 0) && (input < Long.MAX_VALUE);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment