package oracle.fodemo.storefront.store.queries;

import oracle.fodemo.storefront.store.queries.common.OrderItemsVO;

import oracle.jbo.Row;
import oracle.jbo.domain.Number;
import oracle.jbo.server.ViewObjectImpl;
// ---------------------------------------------------------------------
// ---    File generated by Oracle ADF Business Components Design Time.
// ---    Custom code may be added to this class.
// ---    Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class OrderItemsVOImpl extends ViewObjectImpl implements OrderItemsVO {
    /**This is the default constructor (do not remove).
     */
    public OrderItemsVOImpl() {
    }

    /**
     * @param orderId
     */
    public void showOrderItemsForOrderId(Long orderId){
        setApplyViewCriteriaName("findByOrderId");
        ensureVariableManager().setVariableValue("bvOrderId", orderId);
        executeQuery();
    }

    /**
     * @param orderId
     * @param productId
     */
    public void showOrderItemForOrderIdAndProductId(Long orderId, Integer productId){
        setApplyViewCriteriaName("findByOrderIdAndProductId");
        ensureVariableManager().setVariableValue("bvOrderId", orderId);
        ensureVariableManager().setVariableValue("bvProductId", productId);
        executeQuery();
    }

    /**
     * @param newQuantity
     */
    public void setQuantityForCurrentRow(Integer newQuantity){
        Row currentRow = this.getCurrentRow();
        if(currentRow != null){
            currentRow.setAttribute("Quantity", newQuantity);
            this.getDBTransaction().commit();
        }
    }

    public void showAll() {
      setApplyViewCriteriaNames(null);
      executeQuery();
    }

// todo: don't think this is used any longer
//    public void deleteCurrentItem(){
//        Row currentRow = this.getCurrentRow();
//        if(currentRow != null){
//            currentRow.remove();
//            this.getDBTransaction().commit();
//        }
//    }


    /**Gets the variable value for bvOrderId.
     * @return
     */
    public String getbvOrderId() {
        return (String)ensureVariableManager().getVariableValue("bvOrderId");
    }

    /**Sets <code>value</code> for variable bvOrderId.
     * @param value
     */
    public void setbvOrderId(String value) {
        ensureVariableManager().setVariableValue("bvOrderId", value);
    }

    /**Gets the variable value for bvProductId.
     * @return
     */
    public String getbvProductId() {
        return (String)ensureVariableManager().getVariableValue("bvProductId");
    }

    /**Sets <code>value</code> for variable bvProductId.
     * @param value
     */
    public void setbvProductId(String value) {
        ensureVariableManager().setVariableValue("bvProductId", value);
    }
}
