/**
  * @param terminalId
  * @param shipmentMode
  * @param chargeId
  * @return
  */
 public boolean deleteFOBCharges(String terminalId, String shipmentMode, String chargeId) {
   Connection connection = null;
   PreparedStatement pStmt = null;
   // @@ Commented by Priyanka on 28/06/07 for Connection Leakages
   // ResultSet				rs				=	null;
   String sql = "";
   boolean flag = false;
   int modeval = 0;
   if (shipmentMode.equals("Air")) {
     modeval = 1;
   } else if (shipmentMode.equals("Sea")) {
     modeval = 2;
   } else {
     modeval = 4;
   }
   try {
     connection = getConnection();
     int count = 0;
     ///////////// DELETING DETAILED RECORDS
     sql = "DELETE FROM FS_FR_STD_CHARGES WHERE TRML_ID =? AND SHPMNT_MODE = ? AND CHARGEID=?";
     pStmt = connection.prepareStatement(sql);
     pStmt.setString(1, terminalId);
     pStmt.setInt(2, modeval);
     pStmt.setString(3, chargeId);
     count = pStmt.executeUpdate();
     if (count > 0) {
       flag = true;
     }
   } catch (SQLException ex) {
     flag = false;
     Logger.error(FILE_NAME, "SQL EXception in deleteFOBCharges()" + ex);
     throw new javax.ejb.EJBException();
   } catch (Exception ex) {
     flag = false;
     Logger.error(FILE_NAME, "EXception in deleteFOBCharges()" + ex);
     throw new javax.ejb.EJBException();
   } finally {
     try {
       // @@ Commented by Priyanka on 28/06/07 for Connection Leakages
       // if(rs != null)
       //	{rs.close();}
       // @@  for Connection Leakages
       if (pStmt != null) {
         pStmt.close();
       }
       if (connection != null) {
         connection.close();
       }
     } catch (Exception ex) {
       flag = false;
       Logger.error(FILE_NAME, "Exception at finally Block in deleteFOBCharges()" + ex);
     }
   }
   return flag;
 }
 /**
  * @param shipmentMode
  * @return
  */
 public ArrayList getChargeIdsOfTypefromFob(String shipmentMode) {
   ArrayList generatedList = new ArrayList();
   Statement stmt = null;
   ResultSet rs = null;
   Connection connection = null;
   ArrayList chargeList = new ArrayList();
   if (shipmentMode.equals("Air")) {
     shipmentMode = "(1,3,5,7)";
   } else if (shipmentMode.equals("Sea")) {
     shipmentMode = "(2,3,6,7)";
   } else if (shipmentMode.equals("Truck")) {
     shipmentMode = "(4,5,6,7)";
   }
   try {
     connection = getConnection();
     String sql1 = null;
     sql1 =
         "SELECT DISTINCT CHARGEID  FROM FS_FR_CHARGESMASTER WHERE COSTINCURREDAT  ='Destination' AND SHIPMENTMODE IN "
             + shipmentMode;
     stmt = connection.createStatement();
     //	System.out.println(sql1);
     rs = stmt.executeQuery(sql1);
     int i = 0;
     while (rs.next()) {
       i++;
     }
     rs = null;
     if (i > 0) {
       rs = stmt.executeQuery(sql1);
       i = 0;
       while (rs.next()) {
         chargeList.add(rs.getString("CHARGEID"));
         i++;
       }
     }
   } catch (SQLException se) {
     Logger.error(FILE_NAME, "getChargeDetails()", se);
   } finally {
     try {
       if (rs != null) {
         rs.close();
       }
       if (stmt != null) {
         stmt.close();
       }
       if (connection != null) {
         connection.close();
       }
     } catch (Exception ex) {
       Logger.error(FILE_NAME, "Exception in finally Block" + ex);
     }
   }
   return chargeList;
 }
 // Added by SureshK for CR_1918
 public ArrayList getMAWBDtl(String masterDocId, String terminalId) throws RemoteException {
   Logger.info(FILE_NAME, " [getMasterDataForULDBuild()] [masterDocId] " + masterDocId);
   ArrayList result = null;
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.getMAWBDetails(masterDocId, terminalId);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [getMasterDataForULDBuild()] -> " + e.toString());
     throw new EJBException("Error getting getMasterDataForULDBuild ");
   }
   return result;
 }
 // Added by SureshK for CR_1918
 public String getULDAllocationDtl(String houseDocId, String terminalId) throws RemoteException {
   Logger.info(FILE_NAME, " [getMasterDataForULDBuild()] [houseDocId] " + houseDocId);
   String result = null;
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.getULDAllocationDetails(houseDocId, terminalId);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [getMasterDataForULDBuild()] -> " + e.toString());
     throw new EJBException("Error getting getMasterDataForULDBuild ");
   }
   return result;
 }
 public String isValidULDId(String uldId, String terminalId) throws RemoteException {
   Logger.info(FILE_NAME, " In isValidULDId() uldId " + uldId);
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.isValidULDId(uldId, terminalId);
     Logger.info(FILE_NAME, " In isValidULDId() result " + result);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [isValidULDId()] -> " + e.toString());
     throw new EJBException("Error while getting ULDId data");
   }
   return result;
 }
 public String updateTWHStatus(
     String docId, String subOperation, String status, ESupplyGlobalParameters loginBean) {
   Logger.info(FILE_NAME, " In updateTWHStatus() docId " + docId);
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.updateTWHStatus(docId, subOperation, status, loginBean);
     Logger.info(FILE_NAME, " In getDetpatchData() ");
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [updateTWHStatus()] -> " + e.toString());
     throw new EJBException("Error while updating status");
   }
   return result;
 }
 /*
  * ULD Build Methods Ends Here
  */
 public String getDespatchData(String referenceId, String refType) throws RemoteException {
   Logger.info(
       FILE_NAME, " In getDetpatchData() ReferenceId " + referenceId + " RefType " + refType);
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.getDespatchData(referenceId, refType);
     Logger.info(FILE_NAME, " In getDetpatchData() ");
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [getDetpatchData()] -> " + e.toString());
     throw new EJBException("Error while getting ULDId data");
   }
   return result;
 }
 /**
  * @param paramName
  * @return boolean
  */
 public static boolean isExistInUnOrderListForDefineReport(String paramName) {
   String orderParam[] = {
     "partid",
     "pono",
     "invoiceno",
     "frtinvoiceid",
     "frtinvoiceamount",
     "frtinvoicecurrency",
     "chargeid",
     "paymentamount",
     "housecurrencyid",
     "payat",
     "etd",
     "eta",
     "carrierid",
     "vesselname",
     "dono",
     "dodate",
     "poddate"
   };
   boolean isExist = true;
   String FILE_NAME1 = "ETSDefineReportOrderCheck.java";
   try {
     for (int index = 0; index < orderParam.length; index++) {
       if (orderParam[index].equals(paramName)) {
         isExist = false;
         break;
       }
     }
   } catch (Exception e) {
     Logger.error(FILE_NAME1, " : Exception in java:" + e.toString());
   }
   return isExist;
 }
 public String create(
     ETGSDDOB gsdDetailDOB,
     String operation,
     String subOperation,
     ESupplyGlobalParameters loginBean)
     throws RemoteException {
   String result = "";
   // @@Added By V.Sreelatha on 16/04/2010 for Audit Trail
   gsdDetailDOB.setLoginBean(loginBean);
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     if ("GSD".equals(subOperation)) {
       result = gsdDAO.createGSD(gsdDetailDOB, operation, loginBean);
     } else if ("Despatch".equals(subOperation)) {
       result = gsdDAO.createDespatch(gsdDetailDOB, operation);
     } else if ("WHLocation".equals(subOperation)) {
       result = gsdDAO.createDepotLocation(gsdDetailDOB, operation);
     } else if ("ULD".equals(subOperation)) {
       result = gsdDAO.createULD(gsdDetailDOB, operation);
     } else if ("Pallet".equals(subOperation)) {
       result = gsdDAO.createPallet(gsdDetailDOB, loginBean);
     } else if ("HousePick".equals(subOperation) || "MasterPick".equals(subOperation)) {
       result = gsdDAO.createPickList(gsdDetailDOB, subOperation, loginBean);
     } else if ("ULDBuild".equals(subOperation)) {
       // result = gsdDAO.createULDBuild(gsdDetailDOB, loginBean);
       result = gsdDAO.updateULDStatus(gsdDetailDOB, loginBean);
     }
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [create()] -> Add " + e.toString());
     throw new EJBException("Error in Inserting Goods Storage Details");
   }
   return result;
 }
 /**
  * @param houseDocId
  * @param chargeId
  * @return
  */
 public boolean chargeExist(String houseDocId, String chargeId) {
   Connection connection = null;
   PreparedStatement pStmt = null;
   ResultSet rs = null;
   boolean flag = false;
   ArrayList list = new ArrayList();
   try {
     connection = getConnection();
     String sql = "SELECT CHARGEID FROM FS_FR_HOUSEDOCCHARGES WHERE HOUSEDOCID =?";
     pStmt = connection.prepareStatement(sql);
     pStmt.setString(1, houseDocId);
     rs = pStmt.executeQuery();
     while (rs.next()) {
       String c = rs.getString(1);
       list.add(c);
     }
     if (list.contains(chargeId)) {
       flag = true;
     } else {
       flag = false;
     }
   } catch (SQLException ex) {
     Logger.error(FILE_NAME, "SQLException : " + ex);
     throw new javax.ejb.EJBException();
   } catch (Exception ex) {
     Logger.error(FILE_NAME, "Exception : " + ex);
     throw new javax.ejb.EJBException();
   } finally {
     try {
       if (rs != null) {
         rs.close();
       }
       if (pStmt != null) {
         pStmt.close();
       }
       if (connection != null) {
         connection.close();
       }
     } catch (Exception ex) {
       Logger.error(FILE_NAME, "Exception in finally Block" + ex);
     }
   }
   return flag;
 }
 public String getReferenceData(String referenceId, String subOperation) throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.getReferenceData(referenceId, subOperation);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [getReferenceData()] -> " + e.toString());
     throw new EJBException("Error getting ReferenceId Data");
   }
   return result;
 }
 public String createMAWBULD(String masterDocId, String[] uldId) throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.createMAWBULD(masterDocId, uldId);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [createMAWBULD()] -> " + e.toString());
     throw new EJBException("Error getting ULD Data");
   }
   return result;
 }
 /*public String getConsignmentData(String consignmentId,String terminalId)throws RemoteException{
 String result = "";
 try{
 ETGSDDAO gsdDAO = new ETGSDDAO();
 result = gsdDAO.getConsignmentData(consignmentId,terminalId);
 }catch (Exception e) {
 Logger.error(FILE_NAME, " [getGSDStatusReport()] -> "+e.toString());
 throw new EJBException("Error while getting consignmentData");
 }
 return result;
 }*/
 public String isValidLocationCode(String locationId) throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.isValidLocationCode(locationId);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [isValidLocationCode()] -> " + e.toString());
     throw new EJBException("Error while getting LocationCode");
   }
   return result;
 }
 // Goutham
 public String isValidDepotId(String depotId) throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.getDepotIdData(depotId);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [isValidDepotId()] -> " + e.toString());
     throw new EJBException("Error while getting DepotId");
   }
   return result;
 } // Goutham
 public String getReferenceType(String referenceId) throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.getRefType(referenceId);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [getReferenceType()] -> " + e.toString());
     throw new EJBException("Error while getting ReferenceType");
   }
   return result;
 }
 public String isValidReferenceId(String referenceId) throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.isValidReferenceId(referenceId);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [isValidReferenceId()] -> " + e.toString());
     throw new EJBException("Error Validating referenceId");
   }
   return result;
 }
 public String getAirlineDescription(String Airline) throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.getAirlineDescription(Airline);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [getAirlineDescription()] -> " + e.toString());
     throw new EJBException("Error Doing getAirlineDescription");
   }
   return result;
 }
 public String getPRSData(String prsId, String terminalId) throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.getPRSData(prsId, terminalId);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [getPRSData()] -> " + e.toString());
     throw new EJBException("Error Doing getPRSData");
   }
   return result;
 }
 public String getConsignmentNotInWareHouse(String referenceId) throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.getConsignmentNotInWareHouse(referenceId);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [getConsignmentNotInWareHouse()] -> " + e.toString());
     throw new EJBException("Error Doing getConsignmentNotInWareHouse");
   }
   return result;
 }
 public String getPalletData(String palletId) throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.getPalletData(palletId);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [palletId()] -> " + e.toString());
     throw new EJBException("Error getting Pallet Data");
   }
   return result;
 }
 /**
  * @param chargeId
  * @return
  */
 public ArrayList isChargesExist(String chargeId[]) {
   Connection connection = null;
   PreparedStatement pStmt = null;
   ResultSet rs = null;
   ArrayList list = new ArrayList();
   try {
     connection = getConnection();
     String sql = "SELECT CHARGEID FROM FS_FR_CHARGESMASTER WHERE CHARGEID=?";
     pStmt = connection.prepareStatement(sql);
     if (chargeId != null) {
       for (int index = 0; index < chargeId.length; index++) {
         pStmt.setString(1, chargeId[index]);
         rs = pStmt.executeQuery();
         if (!rs.next()) {
           list.add(chargeId[index]);
         }
       }
     }
   } catch (SQLException ex) {
     Logger.error(FILE_NAME, "SQLException : " + ex);
     throw new javax.ejb.EJBException();
   } catch (Exception ex) {
     Logger.error(FILE_NAME, "Exception : " + ex);
     throw new javax.ejb.EJBException();
   } finally {
     try {
       if (rs != null) {
         rs.close();
       }
       if (pStmt != null) {
         pStmt.close();
       }
       if (connection != null) {
         connection.close();
       }
     } catch (Exception ex) {
       Logger.error(FILE_NAME, "Exception in finally Block" + ex);
     }
   }
   return list;
 }
 public String isValidConsignmentId(String consignmentId, String terminalId)
     throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.isValidConsignmentId(consignmentId, terminalId);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [isValidConsignmentId()] -> " + e.toString());
     throw new EJBException("Error in isValidConsignmentId");
   }
   return result;
 }
 public String loadMAWBULD(String masterDocId, ESupplyGlobalParameters loginBean)
     throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.loadMAWBULD(masterDocId, loginBean);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [loadMAWBULD()] -> " + e.toString());
     throw new EJBException("Error getting ULD Data");
   }
   return result;
 }
 public String getWHStatusReport(String referenceId, ESupplyGlobalParameters loginBean)
     throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.getWHStatusReport(referenceId, loginBean);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [getWHStatusReport()] -> " + e.toString());
     throw new EJBException("Error getting WH Status Report");
   }
   return result;
 }
 public String getPickListData(
     String docId, String subOperation, ESupplyGlobalParameters loginBean) throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.getPickListData(docId, subOperation, loginBean);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [getPickListData()] -> " + e.toString());
     throw new EJBException("Error getting Pick List Data");
   }
   return result;
 }
 public String getGSDStatusReport(String consignmentId, ESupplyGlobalParameters loginBean)
     throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.getGSDStatusReport(consignmentId, loginBean);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [getGSDStatusReport()] -> " + e.toString());
     throw new EJBException("Error in getting Goods Storage status");
   }
   return result;
 }
 public String updateWareHouseStatus(
     String referenceId, String refType, String subOperation, ESupplyGlobalParameters loginBean)
     throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.updateWareHouseStatus(referenceId, refType, subOperation, loginBean);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [updateWareHouseStatus()] -> " + e.toString());
     throw new EJBException("Error Doing updateWareHouseStatus");
   }
   return result;
 }
 public String putAway(
     String locationId, String referenceId, String refType, ESupplyGlobalParameters loginBean)
     throws RemoteException {
   String result = "";
   try {
     ETGSDDAO gsdDAO = new ETGSDDAO();
     result = gsdDAO.putAway(locationId, referenceId, refType, loginBean);
   } catch (Exception e) {
     Logger.error(FILE_NAME, " [putAway()] -> " + e.toString());
     throw new EJBException("Error Doing putAway");
   }
   return result;
 }
 /**
  * @param con
  * @param qry
  * @return boolean
  * @throws java.sql.SQLException
  */
 private static boolean isIdExists(Connection con, String qry) throws SQLException {
   boolean result = false;
   Statement ps = null;
   ResultSet rs = null;
   try {
     ps = con.createStatement();
     rs = ps.executeQuery(qry);
     if (rs.next()) {
       result = true;
     }
   } catch (Exception ex) {
     Logger.error(FILE_NAME, " isIdExists() " + ex);
     Logger.info(FILE_NAME, "Query :" + qry);
     throw new SQLException("Error while checking in Id " + ex);
   } finally {
     //			 @@ Modified by K Srinivasarao to resolve the Connection leaks
     closeStatement(rs, ps);
     rs = null;
     ps = null;
   }
   return result;
 }
 /** @return */
 private Connection getConnection() {
   DataSource ds = null;
   // InitialContext		ic		=		null;//commented  by nagaja for performance tuning on 23-09-2008
   Connection con = null;
   try {
     // modified by nagaja for performance tuning on 23-09-2008
     /*	ic		=	new InitialContext();
     ds		=	(DataSource)ic.lookup("java:comp/env/jdbc/DB");*/
     ds = LookUpBean.getDataSource();
     con = ds.getConnection();
   } catch (Exception ex) {
     Logger.error(FILE_NAME, "Exception in getConnection() : " + ex);
   }
   return con;
 }