/** Required Method Implementation */
 public void ejbCreate() throws CreateException, RemoteException {
   try {
     // Data validation EJB
     rhcccustValidateHome = (RhccCustomerHome) USFEnv.ic.lookup(RHCC_VALIDATION_EJBEAN);
     rhcccustValidate = rhcccustValidateHome.create();
   } catch (NamingException e) {
     USFEnv.getLog().writeCrit("Inside Naming exception", this, e);
   } catch (CreateException e) {
     USFEnv.getLog().writeCrit("Inside Create exception", this, e);
   } catch (RemoteException e) {
     USFEnv.getLog().writeCrit("Inside Remote exception", this, e);
   }
   USFEnv.getLog().writeDebug("EJB Created, ref:" + this.toString(), this, null);
 }
 public List retrieveAttachmentsByCustomerId(long customerId) throws RemoteException {
   List attachments = new ArrayList();
   AttachmentDAO attachmentDAO = new AttachmentDAO(conn);
   attachments = attachmentDAO.retrieveAttachmentsByCustomerId(customerId);
   USFEnv.getLog().writeDebug("attachments size is......" + attachments.size(), this, null);
   return attachments;
 }
 /** This method used to connect to the Conection pool */
 public void connect() throws ConnectException, RemoteException {
   try {
     conn = null;
     conn = dbconn.open();
     USFEnv.getLog().writeDebug("created db connection(), ref: " + conn.toString(), this, null);
   } catch (Exception e) {
     throw new ConnectException("Database connection failure");
   }
 }
  /**
   * Business unit of work This method is used to delete an existing customer
   *
   * @param customer Id
   * @return true or false whether the customer is deleted or not
   */
  public boolean delCustomer(String customerId) throws RemoteException {
    USFEnv.getLog().writeWarn(" Inside delCustomer", this, null);
    boolean bTmp = false;

    // Get the connection
    RhccCustInfos rhcc_obj = new RhccCustInfos(conn);

    try {
      if (conn != null) {
        bTmp = rhcc_obj.deleteCustomer(Long.parseLong(customerId));
        USFEnv.getLog()
            .writeDebug("delCustomer DB connection, ref: " + conn.toString(), this, null);
      }
    } catch (Exception e) {
      USFEnv.getLog().writeCrit("Error in business EJB: ", this, e);
    }
    return bTmp;
  }
  /**
   * Business unit of work This method is used to update an existing customer after editing
   *
   * @param customer details
   * @return true or false whether the customer is updated or not
   */
  public boolean updateCustomer(RhccCustInfos updateCustomer) throws RemoteException {
    USFEnv.getLog().writeWarn(" Inside updateCustomer", this, null);
    boolean bTmp = false;

    // Get the connection
    RhccCustInfos rhcc_obj = new RhccCustInfos(conn);

    try {
      if (conn != null) {
        bTmp = rhcc_obj.updateCustomerInfo(updateCustomer);
        USFEnv.getLog()
            .writeDebug("newCustomer DB connection, ref: " + conn.toString(), this, null);
      }
    } catch (Exception e) {
      USFEnv.getLog().writeCrit("Error in business EJB: ", this, e);
    }
    return bTmp;
  }
  /**
   * Business unit of work This method is used to view a particular selected Customer
   *
   * @param customer Id
   * @return customer details
   */
  public RhccCustInfos viewCustomer(String customerId) throws RemoteException {
    RhccCustInfos cTmp = null;

    USFEnv.getLog().writeWarn(" Inside viewCustomer", this, null);

    // Get the connection
    RhccCustInfos rhcc_obj = new RhccCustInfos(conn);
    try {
      if (conn != null) {
        cTmp = rhcc_obj.searchCustomerInfo(customerId);
        USFEnv.getLog()
            .writeDebug("viewCustomer DB connection, ref: " + conn.toString(), this, null);
      }
    } catch (Exception e) {
      USFEnv.getLog().writeCrit("Error in business EJB: ", this, e);
    }
    return cTmp;
  }
  /**
   * Business unit of work This method show all the RHCC customers for a funding year
   *
   * @param year - funding year
   * @return vCustnmid - Customers for a Funding Year
   */
  public Vector getAllRHCCCustomers(short year) throws RemoteException, NullPointerException {
    Vector vCustnmid = null;

    USFEnv.getLog().writeWarn("Inside getAllRHCCCustomers", this, null);

    // Get the connection

    RhccCustInfos rhcc_obj = new RhccCustInfos();
    try {

      vCustnmid = rhcc_obj.getAllRHCCCustomers(year);
      USFEnv.getLog()
          .writeDebug("getAllRHCCCustomers DB connection, ref: " + conn.toString(), this, null);

    } catch (Exception e) {
      USFEnv.getLog().writeCrit("Error in business EJB: ", this, e);
    }
    return vCustnmid;
  }
  /**
   * Business unit of work This method is used to save a new Customer or an existing customer after
   * editing
   *
   * @param new customer details
   * @return true or false whether the customer is saved or not
   */
  public boolean saveCustomer(RhccCustInfos saveCustomer, Hashtable custErrors)
      throws RemoteException {
    USFEnv.getLog().writeWarn(" Inside saveCustomer", this, null);

    long customerId;
    boolean bCustErr = false;
    boolean bTmp = false;

    // Get the connection
    RhccCustInfos rhcc_obj = new RhccCustInfos(conn);

    try {
      customerId = saveCustomer.getCustomerId();

      if (conn != null) {
        USFEnv.getLog()
            .writeDebug("saveCustomer DB connection, ref: " + conn.toString(), this, null);
      }
      // Check business logic field value validation
      bCustErr = rhcccustValidate.customerBusVal(saveCustomer, custErrors);

      // Check if critial error occured
      if (!bCustErr) {
        // Saving a new customer
        if (customerId == 0) {
          // One time funding year set for new customer record
          bTmp = newCustomer(saveCustomer);

          USFEnv.getLog()
              .writeWarn(
                  "new RhccCustInfo created, RCI_ID: " + saveCustomer.getCustomerId(), this, null);
        } else {
          // Saving an exiting customer
          bTmp = updateCustomer(saveCustomer);
        }
      }

    } catch (Exception e) {
      USFEnv.getLog().writeCrit("Error in business EJB: ", this, e);
    }
    return bTmp;
  }
  /**
   * This Method checks if the passed product key has any credits. returns a boolean value based on
   * the check Result.
   *
   * @param wodId - Product Key WOD_ID of the WRK_ORDR_DETS table
   * @return boolean - TRUE ( If product has credits) FALSE (If product has no credits)
   */
  public boolean hasCredits(long wodId) throws RemoteException {

    WrkOrdrDets wrkordrdts_obj = new WrkOrdrDets(conn);

    // Check if the Product credit is greater than zero
    if (wrkordrdts_obj.getProductDiscount(wodId) > (new Double("0.00")).doubleValue()) {
      // If Yes Return True
      USFEnv.getLog().writeDebug("Item has Discounts", this, null);
      return true;
    }
    // Return False
    return false;
  }
  /**
   * This Method is the Unit of Work related to a Item Deletion. This returns a boolean value based
   * on the Deletion Result.
   *
   * @param wodId - WorkOrder Detail Id(Product Key) Primary Key of WRK_ORDR_DETS table
   * @return boolean - TRUE ( If Deletion Success) FALSE (Deletion Failed)
   */
  public boolean deleteProduct(long wodId) throws RemoteException {

    WrkOrdrDets wrkordrdts_obj = new WrkOrdrDets(conn);

    // Check if the Product credit is greater than zero
    if (wrkordrdts_obj.getProductDiscount(wodId) > (new Double("0.00")).doubleValue()) {
      // If Yes return False as product cant be deleted
      USFEnv.getLog().writeWarn("Cannot Delete Item. Item has Discounts", this, null);
      return false;
    }
    // Else if credit not greater than zero Delete the Product.
    return wrkordrdts_obj.deleteWrkOrdrDets(wodId);
  }
 /** Required Method Implementation */
 public void ejbPassivate() {
   USFEnv.getLog().writeDebug("WorkOrderDetailBean: WorkOrder Detail Bean passivated", this, null);
 }
 /** Required Method Implementation */
 public void ejbRemove() {
   USFEnv.getLog().writeDebug("WorkOrderDetailBean: WorkOrder Detail Bean Removed", this, null);
 }
 /**
  * Required Method Implementation
  *
  * @exception CreateException, RemoteException
  */
 public void ejbCreate() throws CreateException, RemoteException {
   USFEnv.getLog().writeDebug("workorderdetailBean: WorkOrderDetail Bean Created", this, null);
 }
 public void setSessionContext(SessionContext context) {
   USFEnv.getLog().writeDebug("FrnDetailBean: Session Context Created", this, null);
   this.context = context;
 }
 /** Required Method Implementation */
 public void ejbPassivate() {
   USFEnv.getLog().writeDebug("RhccInfoBean: RhccInfo Bean Passivated", this, null);
 }
 /** Required Method Implementation */
 public void ejbRemove() {
   USFEnv.getLog().writeDebug("RhccInfoBean: RhccInfo Bean Removed", this, null);
 }