Commit 8324a573 authored by rani0808's avatar rani0808

Created POJO's from order json and encapsulated all the objects in order

parent f6ec77f5
package com.nisum.omd;
import java.io.File;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.nisum.omd.domain.Order;
@SpringBootApplication
public class OmdCheckoutServiceApplication implements CommandLineRunner {
public class OmdCheckoutServiceApplication {
@Autowired
RandomDataGenerateImpl rdg;
public static void main(String[] args) {
SpringApplication.run(OmdCheckoutServiceApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
// TODO Auto-generated method stub
ObjectMapper objectMapper = new ObjectMapper();
Order order = objectMapper.readValue(new File("src/main/resources/Order.json"), Order.class);
for (int i=0; i< 100; i++) {
order.setOrderNum(rdg.generateOrderNumber());
order.setCustomerId(rdg.generateCustomerId());
order.setLineItem(rdg.genetateLineItem());
System.out.println(order);
}
}
}
package com.nisum.omd;
import org.springframework.stereotype.Component;
import com.github.javafaker.Faker;
import com.nisum.omd.domain.LineItem;
@Component
//@Scope(value="prototype", proxyMode=ScopedProxyMode.TARGET_CLASS)
public class RandomDataGenerateImpl implements RandomDataGenerator {
Faker fk = new Faker();
public String generateOrderNumber() {
return String.valueOf(fk.number().numberBetween(1000000, 9999999));
}
public String generateCustomerId() {
// TODO Auto-generated method stub
return String.valueOf(fk.number().numberBetween(10000, 99999));
}
public LineItem genetateLineItem() {
// TODO Auto-generated method stub
LineItem li = new LineItem();
li.setProductName(fk.commerce().productName());
li.setTaxCode(String.valueOf(fk.number().numberBetween(100, 1000)));
return li;
}
}
package com.nisum.omd;
import com.nisum.omd.domain.LineItem;
public interface RandomDataGenerator {
String generateOrderNumber();
String generateCustomerId();
LineItem genetateLineItem();
}
package com.nisum.omd.domain;
public class BillingTo {
private String firstName;
private String lastName;
private String addressLine1;
private String city;
private String state;
private String zipCode;
private String country;
private int mobileNum;
private String eMailID;
private boolean residentialAddr;
public BillingTo(String firstName, String lastName, String addressLine1, String city, String state, String zipCode,
String country, int mobileNum, String eMailID, boolean residentialAddr) {
super();
this.firstName = firstName;
this.lastName = lastName;
this.addressLine1 = addressLine1;
this.city = city;
this.state = state;
this.zipCode = zipCode;
this.country = country;
this.mobileNum = mobileNum;
this.eMailID = eMailID;
this.residentialAddr = residentialAddr;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getAddressLine1() {
return addressLine1;
}
public void setAddressLine1(String addressLine1) {
this.addressLine1 = addressLine1;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getZipCode() {
return zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public int getMobileNum() {
return mobileNum;
}
public void setMobileNum(int mobileNum) {
this.mobileNum = mobileNum;
}
public String geteMailID() {
return eMailID;
}
public void seteMailID(String eMailID) {
this.eMailID = eMailID;
}
public boolean isResidentialAddr() {
return residentialAddr;
}
public void setResidentialAddr(boolean residentialAddr) {
this.residentialAddr = residentialAddr;
}
}
package com.nisum.omd.domain;
import java.util.List;
import java.util.Map;
public class Order {
......@@ -11,116 +12,157 @@ public class Order {
private String shipMethod;
private String customerId;
private String customerType;
private Promotions promotions;
private String gift;
private LineItem lineItem;
private Map<String,Object> shippingInfo;
private Map<String,Object> shipTo;
private Map<String,Object> billingTo;
private Map<String,Object> orderCharges;
private Map<String,Object> OrderTaxes;
private Promotions promotions;
private List<LineItem> lineItem;
private BillingTo billingTo;
private OrderCharges orderCharges;
private OrderTaxes orderTaxes;
private ShippingInfo shippingInfo;
private ShipTo shipTo;
private PaymentMethod paymentMethod;
public Order(String orderNum, String orderDate, String currency, String shipMethod, String customerId,
String customerType, String gift, Promotions promotions, List<LineItem> lineItem, BillingTo billingTo,
OrderCharges orderCharges, OrderTaxes orderTaxes, ShippingInfo shippingInfo, ShipTo shipTo,
PaymentMethod paymentMethod) {
super();
this.orderNum = orderNum;
this.orderDate = orderDate;
this.currency = currency;
this.shipMethod = shipMethod;
this.customerId = customerId;
this.customerType = customerType;
this.gift = gift;
this.promotions = promotions;
this.lineItem = lineItem;
this.billingTo = billingTo;
this.orderCharges = orderCharges;
this.orderTaxes = orderTaxes;
this.shippingInfo = shippingInfo;
this.shipTo = shipTo;
this.paymentMethod = paymentMethod;
}
public String getOrderNum() {
return orderNum;
}
public void setOrderNum(String orderNum) {
this.orderNum = orderNum; //rdg.generateOrderNumber();
this.orderNum = orderNum;
}
public String getOrderDate() {
return orderDate;
}
public void setOrderDate(String orderDate) {
this.orderDate = orderDate;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
public String getShipMethod() {
return shipMethod;
}
public void setShipMethod(String shipMethod) {
this.shipMethod = shipMethod;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;//rdg.generateCustomerId();
this.customerId = customerId;
}
public String getCustomerType() {
return customerType;
}
public void setCustomerType(String customerType) {
this.customerType = customerType;
}
public Promotions getPromotions() {
return promotions;
}
public void setPromotions(Promotions promotions) {
this.promotions = promotions;
}
public String getGift() {
return gift;
}
public void setGift(String gift) {
this.gift = gift;
}
public LineItem getLineItem() {
return lineItem;
}
public void setLineItem(LineItem lineItem) {
//this.lineItem = rdg.genetateLineItem();
this.lineItem = lineItem;
}
public Map<String, Object> getShippingInfo() {
return shippingInfo;
public Promotions getPromotions() {
return promotions;
}
public void setShippingInfo(Map<String, Object> shippingInfo) {
this.shippingInfo = shippingInfo;
public void setPromotions(Promotions promotions) {
this.promotions = promotions;
}
public Map<String, Object> getShipTo() {
return shipTo;
public List<LineItem> getLineItem() {
return lineItem;
}
public void setShipTo(Map<String, Object> shipTo) {
this.shipTo = shipTo;
public void setLineItem(List<LineItem> lineItem) {
this.lineItem = lineItem;
}
public Map<String, Object> getBillingTo() {
public BillingTo getBillingTo() {
return billingTo;
}
public void setBillingTo(Map<String, Object> billingTo) {
public void setBillingTo(BillingTo billingTo) {
this.billingTo = billingTo;
}
public Map<String, Object> getOrderCharges() {
public OrderCharges getOrderCharges() {
return orderCharges;
}
public void setOrderCharges(Map<String, Object> orderCharges) {
public void setOrderCharges(OrderCharges orderCharges) {
this.orderCharges = orderCharges;
}
public Map<String, Object> getOrderTaxes() {
return OrderTaxes;
public OrderTaxes getOrderTaxes() {
return orderTaxes;
}
public void setOrderTaxes(OrderTaxes orderTaxes) {
this.orderTaxes = orderTaxes;
}
public ShippingInfo getShippingInfo() {
return shippingInfo;
}
public void setShippingInfo(ShippingInfo shippingInfo) {
this.shippingInfo = shippingInfo;
}
public ShipTo getShipTo() {
return shipTo;
}
public void setOrderTaxes(Map<String, Object> orderTaxes) {
OrderTaxes = orderTaxes;
public void setShipTo(ShipTo shipTo) {
this.shipTo = shipTo;
}
public PaymentMethod getPaymentMethod() {
return paymentMethod;
}
public void setPaymentMethod(PaymentMethod paymentMethod) {
this.paymentMethod = paymentMethod;
}
@Override
public String toString() {
return "Order [orderNum=" + orderNum + ", orderDate=" + orderDate + ", currency=" + currency + ", shipMethod="
+ shipMethod + ", customerId=" + customerId + ", customerType=" + customerType + ", promotions="
+ promotions + ", gift=" + gift + ", lineItem=" + lineItem + ", shippingInfo=" + shippingInfo
+ ", shipTo=" + shipTo + ", billingTo=" + billingTo + ", orderCharges=" + orderCharges + ", OrderTaxes="
+ OrderTaxes + ", paymentMethod=" + paymentMethod + "]";
}
......
package com.nisum.omd.domain;
public class OrderCharges {
private float chargeAmount;
private String chargeCategory;
private String chargeName;
public OrderCharges(float chargeAmount, String chargeCategory, String chargeName) {
super();
this.chargeAmount = chargeAmount;
this.chargeCategory = chargeCategory;
this.chargeName = chargeName;
}
public float getChargeAmount() {
return chargeAmount;
}
public void setChargeAmount(float chargeAmount) {
this.chargeAmount = chargeAmount;
}
public String getChargeCategory() {
return chargeCategory;
}
public void setChargeCategory(String chargeCategory) {
this.chargeCategory = chargeCategory;
}
public String getChargeName() {
return chargeName;
}
public void setChargeName(String chargeName) {
this.chargeName = chargeName;
}
}
package com.nisum.omd.domain;
public class OrderTaxes {
private String chargeCategory;
private String taxName;
private float tax;
private String taxCode;
private int taxPercentage;
public OrderTaxes(String chargeCategory, String taxName, float tax, String taxCode, int taxPercentage) {
super();
this.chargeCategory = chargeCategory;
this.taxName = taxName;
this.tax = tax;
this.taxCode = taxCode;
this.taxPercentage = taxPercentage;
}
public String getChargeCategory() {
return chargeCategory;
}
public void setChargeCategory(String chargeCategory) {
this.chargeCategory = chargeCategory;
}
public String getTaxName() {
return taxName;
}
public void setTaxName(String taxName) {
this.taxName = taxName;
}
public float getTax() {
return tax;
}
public void setTax(float tax) {
this.tax = tax;
}
public String getTaxCode() {
return taxCode;
}
public void setTaxCode(String taxCode) {
this.taxCode = taxCode;
}
public int getTaxPercentage() {
return taxPercentage;
}
public void setTaxPercentage(int taxPercentage) {
this.taxPercentage = taxPercentage;
}
}
package com.nisum.omd.domain;
public class ShipTo {
private String firstName;
private String lastName;
private String addressLine1;
private String city;
private String state;
private String zipCode;
private String country;
private int mobileNum;
private String eMailID;
private boolean residentialAddr;
public ShipTo(String firstName, String lastName, String addressLine1, String city, String state, String zipCode,
String country, int mobileNum, String eMailID, boolean residentialAddr) {
super();
this.firstName = firstName;
this.lastName = lastName;
this.addressLine1 = addressLine1;
this.city = city;
this.state = state;
this.zipCode = zipCode;
this.country = country;
this.mobileNum = mobileNum;
this.eMailID = eMailID;
this.residentialAddr = residentialAddr;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getAddressLine1() {
return addressLine1;
}
public void setAddressLine1(String addressLine1) {
this.addressLine1 = addressLine1;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getZipCode() {
return zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public int getMobileNum() {
return mobileNum;
}
public void setMobileNum(int mobileNum) {
this.mobileNum = mobileNum;
}
public String geteMailID() {
return eMailID;
}
public void seteMailID(String eMailID) {
this.eMailID = eMailID;
}
public boolean isResidentialAddr() {
return residentialAddr;
}
public void setResidentialAddr(boolean residentialAddr) {
this.residentialAddr = residentialAddr;
}
}
package com.nisum.omd.domain;
public class ShippingInfo {
private Boolean vaildShipTo;
private int maxDaysToDeliver;
private int minDaysToDeliver;
public ShippingInfo(Boolean vaildShipTo, int maxDaysToDeliver, int minDaysToDeliver) {
super();
this.vaildShipTo = vaildShipTo;
this.maxDaysToDeliver = maxDaysToDeliver;
this.minDaysToDeliver = minDaysToDeliver;
}
public Boolean getVaildShipTo() {
return vaildShipTo;
}
public void setVaildShipTo(Boolean vaildShipTo) {
this.vaildShipTo = vaildShipTo;
}
public int getMaxDaysToDeliver() {
return maxDaysToDeliver;
}
public void setMaxDaysToDeliver(int maxDaysToDeliver) {
this.maxDaysToDeliver = maxDaysToDeliver;
}
public int getMinDaysToDeliver() {
return minDaysToDeliver;
}
public void setMinDaysToDeliver(int minDaysToDeliver) {
this.minDaysToDeliver = minDaysToDeliver;
}
}
{
"orderNum": "1000A1BX",
"orderDate": "2020-04-15T13:33:15.657-05:00",
"currency": "INR",
"shipMethod": "1",
"customerId": "189359",
"customerType": "01",
"promotions": {
"promotionDetails": {
"promotionDesc": "Electronic Items Ship Free",
"promotionApplied": "false",
"awards": {
"awardId": "1000",
"awardAmt": "0.00"
}
}
},
"gift": "false",
"lineItem": {
"lineItemNumber": "5475",
"skuNumber": "22222222",
"itemColorDesc": "White",
"size": "6",
"orderedQty": "2",
"productName": "Apple Mobile",
"itemType": "7",
"shipChrgApplInd": "true",
"estimatedShipDate": "2020-04-15T00:00:00-05:00",
"linePriceInfo": {
"listPrice": "29.50",
"retailPrice": "29.50",
"unitPrice": "20.00",
"linePriceType": "03"
},
"lineTax": {
"chargeCategory": "Price",
"chargeName": "Price",
"taxName": "SalesTax",
"tax": "3.40",
"taxPercentage": "8.50",
"taxCode": "C1",
"unitTaxAmount": "1.70"
}
},
"shippingInfo": {
"vaildShipTo": "true",
"maxDaysToDeliver": "9",
"minDaysToDeliver": "6"
},
"shipTo": {
"firstName": "Narendra",
"lastName": "Modi",
"addressLine1": "2 Folsom St",
"city": "Delhi",
"state": "DL",
"zipCode": "110001",
"country": "IN",
"mobile": "9988776655",
"eMailID": "modi@india.com",
"residentialAddr": "false"
},
"billingTo": {
"firstName": "Narendra",
"fastName": "Modi",
"addressLine1": "2 Folsom St",
"city": "Delhi",
"state": "DL",
"zipCode": "110001",
"country": "IN",
"mobile": "9988776655",
"eMailID": "modi@india.com",
"residentialAddr": "false"
},
"orderCharges": {
"ChargeAmount": "10.00",
"ChargeCategory": "Ship",
"ChargeName": "Ship"
},
"orderTaxes": {
"ChargeCategory": "Shipping",
"TaxName": "GST",
"Tax": "0.00",
"taxCode": "C1",
"TaxPercentage": "12"
},
"paymentMethod": {
"paymetMethod": "CC",
"creditCardNo": "12345678987665",
"creditCardType": "VISA",
"displayCreditCardNo": "8277",
"paymentStatus": "AUTH",
"paymentDetail": {
"TransactionId": "021361475199",
"ProcessedAmount": "1000.00",
"RequestAmount": "1000.00"
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment