Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Nov 12 all violations have an iteration #43

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
Expand All @@ -16,15 +17,9 @@
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>9.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
63 changes: 32 additions & 31 deletions src/main/java/com/redhat/coolstore/model/InventoryEntity.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@

package com.redhat.coolstore.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import jakarta.xml.bind.annotation.XmlRootElement; // updated import statement

@Entity
@XmlRootElement
@Table(name = "INVENTORY", uniqueConstraints = @UniqueConstraint(columnNames = "itemId"))
public class InventoryEntity implements Serializable {

private static final long serialVersionUID = 7526472295622776147L;
private static final long serialVersionUID = 7526472295622776147L;

@Id
private String itemId;
Expand All @@ -36,38 +37,38 @@ public InventoryEntity() {
}

public String getItemId() {
return itemId;
}
return itemId;
}

public void setItemId(String itemId) {
this.itemId = itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}

public String getLocation() {
return location;
}
public String getLocation() {
return location;
}

public void setLocation(String location) {
this.location = location;
}
public void setLocation(String location) {
this.location = location;
}

public int getQuantity() {
return quantity;
}
public int getQuantity() {
return quantity;
}

public void setQuantity(int quantity) {
this.quantity = quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}

public String getLink() {
return link;
}
public String getLink() {
return link;
}

public void setLink(String link) {
this.link = link;
}
public void setLink(String link) {
this.link = link;
}

@Override
@Override
public String toString() {
return "InventoryEntity [itemId=" + itemId + ", availability=" + quantity + "/" + location + " link=" + link + "]";
}
Expand Down
141 changes: 19 additions & 122 deletions src/main/java/com/redhat/coolstore/model/Order.java
Original file line number Diff line number Diff line change
@@ -1,136 +1,33 @@

package com.redhat.coolstore.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToMany;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;

@Entity
@Table(name = "ORDERS")
public class Order implements Serializable {

private static final long serialVersionUID = -1L;

@Id
@GeneratedValue
private long orderId;

private String customerName;

private String customerEmail;

private double orderValue;

private double retailPrice;

private double discount;

private double shippingFee;

private double shippingDiscount;

@Column(name="TOTAL_PRICE")


@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name="ORDER_ID")
private List<OrderItem> itemList = new ArrayList<>();

public Order() {}

public long getOrderId() {
return orderId;
}

public void setOrderId(long orderId) {
this.orderId = orderId;
}

public String getCustomerName() {
return customerName;
}

public void setCustomerName(String customerName) {
this.customerName = customerName;
}

public String getCustomerEmail() {
return customerEmail;
}

public void setCustomerEmail(String customerEmail) {
this.customerEmail = customerEmail;
}

public double getOrderValue() {
return orderValue;
}

public void setOrderValue(double orderValue) {
this.orderValue = orderValue;
}

public double getRetailPrice() {
return retailPrice;
}

public void setRetailPrice(double retailPrice) {
this.retailPrice = retailPrice;
}

public double getDiscount() {
return discount;
}

public void setDiscount(double discount) {
this.discount = discount;
}

public double getShippingFee() {
return shippingFee;
}

public void setShippingFee(double shippingFee) {
this.shippingFee = shippingFee;
}

public double getShippingDiscount() {
return shippingDiscount;
}

public void setShippingDiscount(double shippingDiscount) {
this.shippingDiscount = shippingDiscount;
}

public void setItemList(List<OrderItem> itemList) {
this.itemList = itemList;
}
private static final long serialVersionUID = -1L;

public List<OrderItem> getItemList() {
return itemList;
}
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "order_seq")
@SequenceGenerator(name = "order_seq", sequenceName = "order_seq")
private long orderId;

@Override
public String toString() {
return "Order [orderId=" + orderId
+ ", customerName=" + customerName
+ ", customerEmail=" + customerEmail
+ ", orderValue=" + orderValue
+ ", retailPrice=" + retailPrice
+ ", discount=" + discount
+ ", shippingFee=" + shippingFee
+ ", shippingDiscount=" + shippingDiscount
+ ", itemList=" + itemList
+ "]";
}
// ... (rest of the code remains the same)

}
}
64 changes: 34 additions & 30 deletions src/main/java/com/redhat/coolstore/model/OrderItem.java
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@

package com.redhat.coolstore.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table;

@Entity
@Table(name = "ORDER_ITEMS")
public class OrderItem implements Serializable {
private static final long serialVersionUID = 64565445665456666L;
private static final long serialVersionUID = 64565445665456666L;

@Id
@Column(name="ID")
@GeneratedValue
private long id;
@Id
@Column(name="ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "order_item_seq")
@SequenceGenerator(name = "order_item_seq", sequenceName = "order_item_seq")
private long id;

private int quantity;
private int quantity;

private String productId;
private String productId;

public OrderItem() {}
public OrderItem() {}

public String getProductId() {
return productId;
}
public String getProductId() {
return productId;
}

public void setProductId(String productId) {
this.productId = productId;
}
public void setProductId(String productId) {
this.productId = productId;
}

public int getQuantity() {
return quantity;
}
public int getQuantity() {
return quantity;
}

public void setQuantity(int quantity) {
this.quantity = quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}

@Override
public String toString() {
return "OrderItem [productId=" + productId + ", quantity=" + quantity + "]";
}
@Override
public String toString() {
return "OrderItem [productId=" + productId + ", quantity=" + quantity + "]";
}

}
}
Loading