/** * Create the entity by combining the stored key and data. This "tricky" binding returns the * stored data as the entity, but first it sets the transient key fields from the stored key. */ public Object entryToObject(TupleInput keyInput, Object dataInput) { String partNumber = keyInput.readString(); String supplierNumber = keyInput.readString(); Shipment shipment = (Shipment) dataInput; shipment.setKey(partNumber, supplierNumber); return shipment; }
public static void main(String args[]) { Shipment shipment1 = new Shipment(10, 20, 15, 10, 3.41); Shipment shipment2 = new Shipment(2, 3, 4, 0.76, 1.28); double vol; vol = shipment1.volume(); System.out.println("Volume of shipment1 is " + vol); System.out.println("Weight of shipment1 is " + shipment1.weight); System.out.println("Shipping cost: $" + shipment1.cost); System.out.println(); vol = shipment2.volume(); System.out.println("Volume of shipment2 is " + vol); System.out.println("Weight of shipment2 is " + shipment2.weight); System.out.println("Shipping cost: $" + shipment2.cost); }
public HibernateOrder( Long buyer, double amount, double discount, String coupon, Shipment shipment, boolean tracking) { this.buyer = buyer; this.amount = amount; this.coupon = coupon; this.discount = discount; this.shipmentAmount = shipment.getAmount(); this.shipmentType = shipment.getType(); this.shipmentAddress = new Address(shipment.getAddress()); this.tracking = tracking; this.orderState = OrderState.NEW; timestamp = new Date(); created = new Date(); }
public void testReferenceAsDescriptionsListWithValidValuesInKey_validateViewPropertiesOnModify() throws Exception { execute("Mode.detailAndFirst"); assertValue("shipment.KEY", ""); Shipment shipment = (Shipment) Shipment.findAll().iterator().next(); setValue("shipment.KEY", toKeyString(shipment)); execute("CRUD.save"); assertError("Value for Advice in Delivery is required"); setValue("advice", "Modifying"); execute("CRUD.save"); assertNoErrors(); execute("Mode.list"); execute("Mode.detailAndFirst"); assertValue("shipment.KEY", toKeyString(shipment)); assertDescriptionValue("shipment.KEY", shipment.getDescription()); // Restoring setValue("shipment.KEY", ""); setValue("advice", "Restoring"); execute("CRUD.save"); assertNoErrors(); }
public static Shipment randomShipment() { Shipment s = create(Shipment.class); s.setExternalReferenceId(generateKey(7)); s.setFromAddress(randomAddress()); s.setToAddress(randomAddress()); s.setShippingServiceName(randomShippingService().getName()); for (int i = 0; i < rand.nextInt(5) + 1; i++) { Parcel p = create(Parcel.class); p.setShipmentId(rand.nextInt(5000)); p.setContents(randomize(CONTENTS)); p.setWidth(rand.nextInt(5) + 1); p.setHeight(rand.nextInt(5) + 1); p.setLength(rand.nextInt(5) + 1); p.setWeight(rand.nextInt(5) + 1); p.setParcelStatus(randomEnum(ParcelStatus.values())); s.getParcels().add(p); } return (s); }
public Shipment addShipment(Shipment shipment) { getShipments().add(shipment); shipment.setSalesInvoice(this); return shipment; }
public Shipment removeShipment(Shipment shipment) { getShipments().remove(shipment); shipment.setSalesInvoice(null); return shipment; }
/** Create the stored key from the entity. */ public void objectToKey(Object object, TupleOutput output) { Shipment shipment = (Shipment) object; output.writeString(shipment.getPartNumber()); output.writeString(shipment.getSupplierNumber()); }