// --------------------------------------------------------------------- // --- File generated by Oracle ADF Business Components Design Time. // --- Wed Oct 14 14:13:06 EEST 2015 // --- Custom code may be added to this class. // --- Warning: Do not modify method signatures of generated methods. // --------------------------------------------------------------------- public class SItemImpl extends EntityImpl { /** AttributesEnum: generated enum for identifying attributes and accessors. DO NOT MODIFY. */ public enum AttributesEnum { OrdId, ItemId, ProductId, Price, Quantity, QuantityShipped, SOrd, SProduct; private static AttributesEnum[] vals = null; private static final int firstIndex = 0; public int index() { return AttributesEnum.firstIndex() + ordinal(); } public static final int firstIndex() { return firstIndex; } public static int count() { return AttributesEnum.firstIndex() + AttributesEnum.staticValues().length; } public static final AttributesEnum[] staticValues() { if (vals == null) { vals = AttributesEnum.values(); } return vals; } } public static final int ORDID = AttributesEnum.OrdId.index(); public static final int ITEMID = AttributesEnum.ItemId.index(); public static final int PRODUCTID = AttributesEnum.ProductId.index(); public static final int PRICE = AttributesEnum.Price.index(); public static final int QUANTITY = AttributesEnum.Quantity.index(); public static final int QUANTITYSHIPPED = AttributesEnum.QuantityShipped.index(); public static final int SORD = AttributesEnum.SOrd.index(); public static final int SPRODUCT = AttributesEnum.SProduct.index(); /** This is the default constructor (do not remove). */ public SItemImpl() {} /** @return the definition object for this instance class. */ public static synchronized EntityDefImpl getDefinitionObject() { return EntityDefImpl.findDefObject("pts.adf.summit.model.entities.SItem"); } /** * Gets the attribute value for OrdId, using the alias name OrdId. * * @return the value of OrdId */ public Integer getOrdId() { return (Integer) getAttributeInternal(ORDID); } /** * Sets <code>value</code> as the attribute value for OrdId. * * @param value value to set the OrdId */ public void setOrdId(Integer value) { setAttributeInternal(ORDID, value); } /** * Gets the attribute value for ItemId, using the alias name ItemId. * * @return the value of ItemId */ public DBSequence getItemId() { return (DBSequence) getAttributeInternal(ITEMID); } /** * Sets <code>value</code> as the attribute value for ItemId. * * @param value value to set the ItemId */ public void setItemId(DBSequence value) { setAttributeInternal(ITEMID, value); } /** * Gets the attribute value for ProductId, using the alias name ProductId. * * @return the value of ProductId */ public Integer getProductId() { return (Integer) getAttributeInternal(PRODUCTID); } /** * Sets <code>value</code> as the attribute value for ProductId. * * @param value value to set the ProductId */ public void setProductId(Integer value) { setAttributeInternal(PRODUCTID, value); // Code added to set the item price to be the wholesale price of the new product.. SProductImpl prodInfo = (SProductImpl) getSProduct(); setPrice(prodInfo.getSuggestedWhlslPrice()); } /** * Gets the attribute value for Price, using the alias name Price. * * @return the value of Price */ public BigDecimal getPrice() { return (BigDecimal) getAttributeInternal(PRICE); } /** * Sets <code>value</code> as the attribute value for Price. * * @param value value to set the Price */ public void setPrice(BigDecimal value) { // When ever this attribute is changed, the order total has to be updated as this is based // on the line item, which is the price * quantity. // Get the price before you change it BigDecimal oldPrice = getPrice(); // When adding a new line you won't have an oldPrice if (oldPrice == null) { oldPrice = new BigDecimal(0); } setAttributeInternal(PRICE, value); // Recalculate the order total if the price changes. SOrdImpl order = getSOrd(); // First of all remove the the old line item total from the order total BigDecimal orderTotal = order.getTotal().subtract(new BigDecimal(getQuantity()).multiply(oldPrice)); // Now add the new line item total order.setTotal(orderTotal.add(new BigDecimal(getQuantity()).multiply(value))); } /** * Gets the attribute value for Quantity, using the alias name Quantity. * * @return the value of Quantity */ public Integer getQuantity() { return (Integer) getAttributeInternal(QUANTITY); } /** * Sets <code>value</code> as the attribute value for Quantity. * * @param value value to set the Quantity */ public void setQuantity(Integer value) { Integer oldQuantity = getQuantity(); setAttributeInternal(QUANTITY, value); // Recalculate the order total if the quantity changes. SOrdImpl order = getSOrd(); // First of all remove the the old line item total from the order total BigDecimal orderTotal = order.getTotal().subtract(getPrice().multiply(new BigDecimal(oldQuantity))); // Now add the new line item total order.setTotal(orderTotal.add(getPrice().multiply(new BigDecimal(value)))); } /** * Gets the attribute value for QuantityShipped, using the alias name QuantityShipped. * * @return the value of QuantityShipped */ public Integer getQuantityShipped() { return (Integer) getAttributeInternal(QUANTITYSHIPPED); } /** * Sets <code>value</code> as the attribute value for QuantityShipped. * * @param value value to set the QuantityShipped */ public void setQuantityShipped(Integer value) { // When ever this attribute is changed, the order total has to be updated as this is based // on the line item, which is the price * quantityShipped. // Get the quantityShipped before you change it Integer oldQuantity = getQuantityShipped(); setAttributeInternal(QUANTITYSHIPPED, value); // Recalculate the order total if the price changes. SOrdImpl order = (SOrdImpl) getSOrd(); // First of all remove the the old line item total from the order total BigDecimal orderTotal = order.getTotal().subtract(getPrice().multiply(new BigDecimal(oldQuantity))); // Now add the new line item total order.setTotal(orderTotal.add(getPrice().multiply(new BigDecimal(value)))); } /** @return the associated entity SOrdImpl. */ public SOrdImpl getSOrd() { return (SOrdImpl) getAttributeInternal(SORD); } /** Sets <code>value</code> as the associated entity SOrdImpl. */ public void setSOrd(SOrdImpl value) { setAttributeInternal(SORD, value); } /** @return the associated entity SProductImpl. */ public SProductImpl getSProduct() { return (SProductImpl) getAttributeInternal(SPRODUCT); } /** Sets <code>value</code> as the associated entity SProductImpl. */ public void setSProduct(SProductImpl value) { setAttributeInternal(SPRODUCT, value); } /** * @param ordId key constituent * @param itemId key constituent * @return a Key object based on given key constituents. */ public static Key createPrimaryKey(Integer ordId, DBSequence itemId) { return new Key(new Object[] {ordId, itemId}); } }
// --------------------------------------------------------------------- // --- File generated by Oracle ADF Business Components Design Time. // --- Wed Oct 14 14:59:15 EEST 2015 // --- Custom code may be added to this class. // --- Warning: Do not modify method signatures of generated methods. // --------------------------------------------------------------------- public class SItemViewRowImpl extends ViewRowImpl implements SItemViewRow { public static final int ENTITY_SITEM = 0; public static final int ENTITY_SIMAGE = 1; public static final int ENTITY_SPRODUCT = 2; /** AttributesEnum: generated enum for identifying attributes and accessors. DO NOT MODIFY. */ public enum AttributesEnum { OrdId, ItemId, ProductId, Price, Quantity, QuantityShipped, ProductName, Id, ProductShortDesc, ProductSuggestedPrice, ProductFilename, Id1, ItemTotal, ImageNameFromDB, SInventoryView, SProductView1; static AttributesEnum[] vals = null;; private static final int firstIndex = 0; public int index() { return AttributesEnum.firstIndex() + ordinal(); } public static final int firstIndex() { return firstIndex; } public static int count() { return AttributesEnum.firstIndex() + AttributesEnum.staticValues().length; } public static final AttributesEnum[] staticValues() { if (vals == null) { vals = AttributesEnum.values(); } return vals; } } public static final int ORDID = AttributesEnum.OrdId.index(); public static final int ITEMID = AttributesEnum.ItemId.index(); public static final int PRODUCTID = AttributesEnum.ProductId.index(); public static final int PRICE = AttributesEnum.Price.index(); public static final int QUANTITY = AttributesEnum.Quantity.index(); public static final int QUANTITYSHIPPED = AttributesEnum.QuantityShipped.index(); public static final int PRODUCTNAME = AttributesEnum.ProductName.index(); public static final int ID = AttributesEnum.Id.index(); public static final int PRODUCTSHORTDESC = AttributesEnum.ProductShortDesc.index(); public static final int PRODUCTSUGGESTEDPRICE = AttributesEnum.ProductSuggestedPrice.index(); public static final int PRODUCTFILENAME = AttributesEnum.ProductFilename.index(); public static final int ID1 = AttributesEnum.Id1.index(); public static final int ITEMTOTAL = AttributesEnum.ItemTotal.index(); public static final int IMAGENAMEFROMDB = AttributesEnum.ImageNameFromDB.index(); public static final int SINVENTORYVIEW = AttributesEnum.SInventoryView.index(); public static final int SPRODUCTVIEW1 = AttributesEnum.SProductView1.index(); /** This is the default constructor (do not remove). */ public SItemViewRowImpl() {} /** * Gets SItem entity object. * * @return the SItem */ public SItemImpl getSItem() { return (SItemImpl) getEntity(ENTITY_SITEM); } /** * Gets SImage entity object. * * @return the SImage */ public EntityImpl getSImage() { return (EntityImpl) getEntity(ENTITY_SIMAGE); } /** * Gets SProduct entity object. * * @return the SProduct */ public SProductImpl getSProduct() { return (SProductImpl) getEntity(ENTITY_SPRODUCT); } /** * Gets the attribute value for ORD_ID using the alias name OrdId. * * @return the ORD_ID */ public Integer getOrdId() { return (Integer) getAttributeInternal(ORDID); } /** * Sets <code>value</code> as attribute value for ORD_ID using the alias name OrdId. * * @param value value to set the ORD_ID */ public void setOrdId(Integer value) { setAttributeInternal(ORDID, value); } /** * Gets the attribute value for ITEM_ID using the alias name ItemId. * * @return the ITEM_ID */ public DBSequence getItemId() { return (DBSequence) getAttributeInternal(ITEMID); } /** * Sets <code>value</code> as attribute value for ITEM_ID using the alias name ItemId. * * @param value value to set the ITEM_ID */ public void setItemId(DBSequence value) { setAttributeInternal(ITEMID, value); } /** * Gets the attribute value for PRODUCT_ID using the alias name ProductId. * * @return the PRODUCT_ID */ public Integer getProductId() { return (Integer) getAttributeInternal(PRODUCTID); } /** * Sets <code>value</code> as attribute value for PRODUCT_ID using the alias name ProductId. * * @param value value to set the PRODUCT_ID */ public void setProductId(Integer value) { setAttributeInternal(PRODUCTID, value); } /** * Gets the attribute value for PRICE using the alias name Price. * * @return the PRICE */ public BigDecimal getPrice() { return (BigDecimal) getAttributeInternal(PRICE); } /** * Sets <code>value</code> as attribute value for PRICE using the alias name Price. * * @param value value to set the PRICE */ public void setPrice(BigDecimal value) { setAttributeInternal(PRICE, value); } /** * Gets the attribute value for QUANTITY using the alias name Quantity. * * @return the QUANTITY */ public Integer getQuantity() { return (Integer) getAttributeInternal(QUANTITY); } /** * Sets <code>value</code> as attribute value for QUANTITY using the alias name Quantity. * * @param value value to set the QUANTITY */ public void setQuantity(Integer value) { setAttributeInternal(QUANTITY, value); } /** * Gets the attribute value for QUANTITY_SHIPPED using the alias name QuantityShipped. * * @return the QUANTITY_SHIPPED */ public Integer getQuantityShipped() { return (Integer) getAttributeInternal(QUANTITYSHIPPED); } /** * Sets <code>value</code> as attribute value for QUANTITY_SHIPPED using the alias name * QuantityShipped. * * @param value value to set the QUANTITY_SHIPPED */ public void setQuantityShipped(Integer value) { setAttributeInternal(QUANTITYSHIPPED, value); } /** * Gets the attribute value for NAME using the alias name ProductName. * * @return the NAME */ public String getProductName() { return (String) getAttributeInternal(PRODUCTNAME); } /** * Sets <code>value</code> as attribute value for NAME using the alias name ProductName. * * @param value value to set the NAME */ public void setProductName(String value) { setAttributeInternal(PRODUCTNAME, value); } /** * Gets the attribute value for ID using the alias name Id. * * @return the ID */ public Integer getId() { return (Integer) getAttributeInternal(ID); } /** * Sets <code>value</code> as attribute value for ID using the alias name Id. * * @param value value to set the ID */ public void setId(Integer value) { setAttributeInternal(ID, value); } /** * Gets the attribute value for SHORT_DESC using the alias name ProductShortDesc. * * @return the SHORT_DESC */ public String getProductShortDesc() { return (String) getAttributeInternal(PRODUCTSHORTDESC); } /** * Sets <code>value</code> as attribute value for SHORT_DESC using the alias name * ProductShortDesc. * * @param value value to set the SHORT_DESC */ public void setProductShortDesc(String value) { setAttributeInternal(PRODUCTSHORTDESC, value); } /** * Gets the attribute value for SUGGESTED_WHLSL_PRICE using the alias name ProductSuggestedPrice. * * @return the SUGGESTED_WHLSL_PRICE */ public BigDecimal getProductSuggestedPrice() { return (BigDecimal) getAttributeInternal(PRODUCTSUGGESTEDPRICE); } /** * Sets <code>value</code> as attribute value for SUGGESTED_WHLSL_PRICE using the alias name * ProductSuggestedPrice. * * @param value value to set the SUGGESTED_WHLSL_PRICE */ public void setProductSuggestedPrice(BigDecimal value) { setAttributeInternal(PRODUCTSUGGESTEDPRICE, value); } /** * Gets the attribute value for FILENAME using the alias name ProductFilename. * * @return the FILENAME */ public String getProductFilename() { return (String) getAttributeInternal(PRODUCTFILENAME); } /** * Sets <code>value</code> as attribute value for FILENAME using the alias name ProductFilename. * * @param value value to set the FILENAME */ public void setProductFilename(String value) { setAttributeInternal(PRODUCTFILENAME, value); } /** * Gets the attribute value for ID using the alias name Id1. * * @return the ID */ public Integer getId1() { return (Integer) getAttributeInternal(ID1); } /** * Sets <code>value</code> as attribute value for ID using the alias name Id1. * * @param value value to set the ID */ public void setId1(Integer value) { setAttributeInternal(ID1, value); } /** * Gets the attribute value for the calculated attribute ItemTotal. * * @return the ItemTotal */ public Number getItemTotal() { return (Number) getAttributeInternal(ITEMTOTAL); } /** * Gets the attribute value for the calculated attribute ImageNameFromDB. * * @return the ImageNameFromDB */ public String getImageNameFromDB() { return (String) getAttributeInternal(IMAGENAMEFROMDB); } /** Gets the associated <code>RowIterator</code> using master-detail link SInventoryView. */ public RowIterator getSInventoryView() { return (RowIterator) getAttributeInternal(SINVENTORYVIEW); } /** Gets the view accessor <code>RowSet</code> SProductView1. */ public RowSet getSProductView1() { return (RowSet) getAttributeInternal(SPRODUCTVIEW1); } /** * Added - instead of simply deleting an order item, I will set the quantity to 0 and then delete * it */ public void deleteOrderItem() { setQuantity(new Integer(0)); remove(); } /** * Added - takes in the product id and returns a filename from the database using the * GET_PRODUCT_IMAGE db stored function which looks up the image filename according to the * image_id associated with the product id. The Original Forms application uses files with a TIF * extension we changed these images to JPG */ public String readImageNameFromDB(Number id) { CallableStatement cs = null; cs = this.getDBTransaction().createCallableStatement("begin ?:=GET_PRODUCT_IMAGE(?); end;", 0); try { cs.registerOutParameter(1, Types.VARCHAR); cs.setObject(2, id); cs.execute(); Object returnVal = cs.getObject(1); return returnVal.toString(); } catch (SQLException e) { // print exception if SQL fails. In production systems you may want to log the // issue and fail more gracefully e.g by returning NULL r an empty String e.printStackTrace(); } return "No File"; } }