Package org.openbravo.erpCommon.utility

Examples of org.openbravo.erpCommon.utility.OBError


  }

  private OBError processButton(VariablesSecureApp vars, String strKey, String strProject,
      String windowId) {
    Connection conn = null;
    OBError myMessage = null;
    if (strProject == null || strProject.equals("")) {
      extracted(myMessage).setType("Error");
      extracted(myMessage).setTitle(Utility.messageBD(this, "Error", vars.getLanguage()));
      extracted(myMessage).setMessage(
          Utility.messageBD(this, "NoProjectSelected", vars.getLanguage()));
      return extracted(myMessage);
    }
    try {
      conn = this.getTransactionConnection();
      String projectCategory = ProjectCopyFromData.selectProjectCategory(this, strKey);
      ProjectSetTypeData[] dataProject = ProjectSetTypeData.selectProject(this, strKey);
      if (projectCategory.equals("S")) {
        ProjectCopyFromData[] data = ProjectCopyFromData.select(this, strProject);
        String strProjectPhase = "";
        String strProjectTask = "";
        for (int i = 0; data != null && i < data.length; i++) {
          strProjectPhase = SequenceIdData.getUUID();
          if (!ProjectCopyFromData.hasPhase(this, strKey, data[i].cPhaseId)) {
            try {
              if (ProjectCopyFromData.insertProjectPhase(conn, this, strKey,
                  dataProject[0].adClientId, dataProject[0].adOrgId, vars.getUser(),
                  data[i].description, data[i].mProductId, data[i].cPhaseId, strProjectPhase,
                  data[i].help, data[i].name, data[i].qty, data[i].seqno) == 1) {
                ProjectCopyFromData[] data1 = ProjectCopyFromData.selectTask(this,
                    data[i].cProjectphaseId);
                for (int j = 0; data1 != null && j < data1.length; j++) {
                  strProjectTask = SequenceIdData.getUUID();
                  ProjectCopyFromData.insertProjectTask(conn, this, strProjectTask,
                      data1[j].cTaskId, dataProject[0].adClientId, dataProject[0].adOrgId, vars
                          .getUser(), data1[j].seqno, data1[j].name, data1[j].description,
                      data1[j].help, data1[j].mProductId, strProjectPhase, data1[j].qty);
                }
              }
            } catch (ServletException ex) {
              myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
              releaseRollbackConnection(conn);
              return extracted(myMessage);
            }
          }
        }
      } else {
        ProjectCopyFromData[] dataServ = ProjectCopyFromData.selectServ(this, strProject);
        String strProjectLine = "";
        for (int i = 0; dataServ != null && i < dataServ.length; i++) {
          strProjectLine = SequenceIdData.getUUID();
          try {
            ProjectCopyFromData.insertProjectLine(conn, this, strProjectLine, strKey,
                dataProject[0].adClientId, dataProject[0].adOrgId, vars.getUser(),
                dataServ[i].line, dataServ[i].description, dataServ[i].plannedqty,
                dataServ[i].mProductId, dataServ[i].mProductCategoryId,
                dataServ[i].productDescription, dataServ[i].productName, dataServ[i].productValue);
          } catch (ServletException ex) {
            myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
            releaseRollbackConnection(conn);
            return extracted(myMessage);
          }
        }
      }
      String strProjectType = ProjectCopyFromData.selectProjectType(this, strProject);
      String strProjectCategory = "";
      if (strProjectType == null || strProjectType.equals("")) {
        strProjectCategory = ProjectCopyFromData.selectProjCategory(this, strProject);
      } else {
        strProjectCategory = ProjectSetTypeData.selectProjectCategory(this, strProjectType);
      }
      try {
        ProjectSetTypeData.update(conn, this, vars.getUser(), strProjectType, strProjectCategory,
            strKey);
      } catch (ServletException ex) {
        myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
        releaseRollbackConnection(conn);
        return extracted(myMessage);
      }

      releaseCommitConnection(conn);
      myMessage = new OBError();
      extracted(myMessage).setType("Success");
      extracted(myMessage).setTitle(Utility.messageBD(this, "Success", vars.getLanguage()));
      extracted(myMessage).setMessage(Utility.messageBD(this, "ProcessOK", vars.getLanguage()));
    } catch (Exception e) {
      try {
View Full Code Here


  private OBError writeFields(ConnectionProvider cp, VariablesSecureApp vars,
      AttributeSetInstanceData[] data, String strAttributeSet, String strInstance,
      String strWindow, String strIsSOTrx, String strProduct) throws ServletException {
    String strNewInstance = "";

    OBError myMessage = null;
    myMessage = new OBError();
    myMessage.setTitle("");
    myMessage.setType("Success");
    myMessage.setMessage(Utility.messageBD(this, "Success", vars.getLanguage()));
    if (data == null || data.length == 0) {
      myMessage.setType("Error");
      myMessage.setMessage(Utility.messageBD(this, "FindZeroRecords", vars.getLanguage()));
      // Utility.messageBD(this, "FindZeroRecords", vars.getLanguage());
      return myMessage;
    }

    boolean isinstance = !AttributeSetInstanceData.isInstanceAttribute(this, strAttributeSet)
View Full Code Here

    xmlDocument.setParameter("windowId", strWindowId);
    xmlDocument.setParameter("tabId", strTabId);
    xmlDocument.setParameter("locatorId", strLocator);

    {
      OBError myMessage = vars.getMessage("AttributeSetInstance");
      vars.removeMessage("AttributeSetInstance");
      if (myMessage != null) {
        xmlDocument.setParameter("messageType", myMessage.getType());
        xmlDocument.setParameter("messageTitle", myMessage.getTitle());
        xmlDocument.setParameter("messageMessage", myMessage.getMessage());
      }
    }
    String message = "";
    if (vars.getSessionValue("AttributeSetInstance.close").equals("Y"))
      message = "printMessage('')";
View Full Code Here

          .equals("Y"));
      b.startProcess(vars);
      // String strMessage = b.getLog();
      // if (!strMessage.equals("")) vars.setSessionValue(strWindowId +
      // "|" + strTabName + ".message", strMessage);
      OBError myError = b.getError();
      vars.setMessage(strTabId, myError);
      printPageClosePopUp(response, vars, strWindowPath);
    } else
      pageErrorPopUp(response);
  }
View Full Code Here

      xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
    } catch (Exception ex) {
      throw new ServletException(ex);
    }
    {
      OBError myMessage = vars.getMessage("ReportMaterialTransactionEditionJR");
      vars.removeMessage("ReportMaterialTransactionEditionJR");
      if (myMessage != null) {
        xmlDocument.setParameter("messageType", myMessage.getType());
        xmlDocument.setParameter("messageTitle", myMessage.getTitle());
        xmlDocument.setParameter("messageMessage", myMessage.getMessage());
      }
    }

    xmlDocument.setParameter("calendar", vars.getLanguage().substring(0, 2));
    xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");
View Full Code Here

      String strDateto = vars.getStringParameter("inpDateTo");
      String strDateOrdered = vars.getStringParameter("inpDateordered");
      String strOrganization = vars.getStringParameter("organization");
      String strCompleteAuto = vars.getStringParameter("inpShowNullComplete");

      OBError myMessage = processButton(vars, strBPartner, strDatefrom, strDateto, strDateOrdered,
          strOrganization, strCompleteAuto);
      vars.setMessage("ExpenseSOrder", myMessage);

      printPage(response, vars, strDatefrom, strDateto, strDateOrdered, strBPartner,
          strOrganization, strCompleteAuto);
View Full Code Here

  private OBError processButton(VariablesSecureApp vars, String strBPartner, String strDatefrom,
      String strDateto, String strDateOrdered, String strOrganization, String strCompleteAuto) {
    StringBuffer textoMensaje = new StringBuffer();
    Connection conn = null;

    OBError myMessage = null;
    myMessage = new OBError();
    myMessage.setTitle("");
    String strCust = "";
    try {
      conn = getTransactionConnection();
      ExpenseSOrderData[] data = ExpenseSOrderData.select(this, strBPartner, strDatefrom,
          DateTimeData.nDaysAfter(this, strDateto, "1"), Utility.getContext(this, vars,
              "#User_Client", "ExpenseSOrder"), strOrganization.equals("") ? Utility.getContext(
              this, vars, "#User_Org", "ExpenseSOrder") : Utility.stringList(strOrganization));
      String strOldOrganization = "-1";
      String strOldBPartner = "-1";
      String strOldProject = "-1";
      String strDocStatus = "DR";
      String strDocAction = "CO";
      String strProcessing = "N";
      String strCOrderId = "";
      String strCCurrencyId = "";
      String strBPCCurrencyId = "";
      String strDateexpense = "";
      String priceactual = "";
      String pricelist = "";
      String pricelimit = "";
      String docType = "0";
      String docTargetType = "";
      int line = 0;
      int total = 0;
      // ArrayList order = new ArrayList();
      for (int i = 0; data != null && i < data.length; i++) {
        docTargetType = ExpenseSOrderData.cDoctypeTarget(conn, this, data[i].adClientId,
            data[i].adOrgId);

        if ((!data[i].cBpartnerId.equals(strOldBPartner)
            || !data[i].cProjectId.equals(strOldProject) || !data[i].adOrgId
            .equals(strOldOrganization))
            && !strCOrderId.equals("")) {
          releaseCommitConnection(conn);
          // Automatically processes Sales Order
          if (strCompleteAuto.equals("Y")) {
            try {
              OBError myError = processOrder(vars, strCOrderId);
              if (myError != null)
                textoMensaje.append(" -> ").append(myError.getMessage());
            } catch (ServletException ex) {
              myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
              return myMessage;
            }
          }
          conn = getTransactionConnection();
        }
        // Creates a new sales order header, if required
        if (!data[i].cBpartnerId.equals(strOldBPartner)
            || !data[i].cProjectId.equals(strOldProject)
            || !data[i].adOrgId.equals(strOldOrganization)) {

          line = 0;
          if (total != 0)
            textoMensaje.append("<br>");
          total++;

          strOldBPartner = data[i].cBpartnerId;
          strOldProject = data[i].cProjectId;
          strOldOrganization = data[i].adOrgId;
          strCust = data[i].bpname;

          if (data[i].mPricelistId.equals("")) {
            throw new Exception("PricelistNotdefined");
          } else {
            // Selects the currency of the business partner price
            // list, that can be different from the currency of the
            // expense
            strBPCCurrencyId = ExpenseSOrderData.selectCurrency(this, data[i].mPricelistId);
          }

          BpartnerMiscData[] data1 = BpartnerMiscData.select(this, data[i].cBpartnerId);

          if (data1[0].paymentrule.equals("")) {
            throw new Exception("FormofPaymentNotdefined");
          }

          strCOrderId = SequenceIdData.getUUID();
          // order.add(strCOrderId);
          String strDocumentNo = Utility.getDocumentNo(this, vars, "", "C_Order", docTargetType,
              docTargetType, false, true);
          // Catch database error message
          try {
            ExpenseSOrderData.insertCOrder(conn, this, strCOrderId, data[i].adClientId,
                data[i].adOrgId, vars.getUser(), strDocumentNo, strDocStatus, strDocAction,
                strProcessing, docType, docTargetType, strDateOrdered, strDateOrdered,
                strDateOrdered, data[i].cBpartnerId, ExpenseSOrderData.cBPartnerLocationId(this,
                    data[i].cBpartnerId), ExpenseSOrderData.billto(this, data[i].cBpartnerId)
                    .equals("") ? ExpenseSOrderData.cBPartnerLocationId(this, data[i].cBpartnerId)
                    : ExpenseSOrderData.billto(this, data[i].cBpartnerId), strBPCCurrencyId,
                data1[0].paymentrule, data1[0].cPaymenttermId.equals("") ? ExpenseSOrderData
                    .selectPaymentTerm(this, data[i].adClientId) : data1[0].cPaymenttermId,
                data1[0].invoicerule.equals("") ? "I" : data1[0].invoicerule, data1[0].deliveryrule
                    .equals("") ? "A" : data1[0].deliveryrule, "I", data1[0].deliveryviarule
                    .equals("") ? "D" : data1[0].deliveryviarule,
                data[i].mWarehouseId.equals("") ? vars.getWarehouse() : data[i].mWarehouseId,
                data[i].mPricelistId, data[i].cProjectId, data[i].cActivityId, data[i].cCampaignId);
          } catch (ServletException ex) {
            myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
            releaseRollbackConnection(conn);
            return myMessage;
          }
          textoMensaje.append(Utility.messageBD(this, "SalesOrderDocumentno", vars.getLanguage()))
              .append(" ").append(strDocumentNo).append(" ").append(
                  Utility.messageBD(this, "beenCreated", vars.getLanguage()));
        }

        // Determines the date of the expense (strDateExpense)
        strDateexpense = data[i].dateexpense.equals("") ? data[i].datereport : data[i].dateexpense;
        strDateexpense = strDateexpense.equals("") ? DateTimeData.today(this) : strDateexpense;

        // Gets the tax for the sales order line
        String strCTaxID = Tax.get(this, data[i].mProductId, strDateOrdered, data[i].adOrgId,
            data[i].mWarehouseId.equals("") ? vars.getWarehouse() : data[i].mWarehouseId,
            ExpenseSOrderData.cBPartnerLocationId(this, data[i].cBpartnerId), ExpenseSOrderData
                .cBPartnerLocationId(this, data[i].cBpartnerId), data[i].cProjectId, true);
        if (strCTaxID.equals(""))
          throw new Exception("TaxNotFound");

        // Currency of the expense line
        strCCurrencyId = data[i].cCurrencyId;

        String strPrecision = "0";
        String strPricePrecision = "0";
        String strDiscount = "";

        BigDecimal priceActual, priceList, priceLimit, discount;

        // If there is no invoice price, looks for the prices in the
        // pricelist of the business partner
        if (data[i].invoiceprice == null || data[i].invoiceprice.equals("")) {
          ExpenseSOrderData[] data3 = ExpenseSOrderData.selectPrice(this, data[i].mProductId,
              data[i].mPricelistId, strBPCCurrencyId);
          for (int j = 0; data3 != null && j < data3.length; j++) {
            if (data3[j].validfrom == null || data3[j].validfrom.equals("")
                || !DateTimeData.compare(this, strDateexpense, data3[j].validfrom).equals("-1")) {
              priceactual = data3[j].pricestd;
              pricelist = data3[j].pricelist;
              pricelimit = data3[j].pricelimit;
            }
          }
        } else {
          // If there is an invoice price, it takes it and makes
          // currency conversions, if necessary
          priceactual = data[i].invoiceprice;
          pricelist = "0";
          pricelimit = "0";

          // If the currency of the expense line is not the same as
          // the currency of the business partner pricelist, make the
          // corresponding conversions
          if (!strCCurrencyId.equals(strBPCCurrencyId)) {
            // Converts priceactual, pricelist and pricelimit to the
            // currency of the business partner pricelist
            priceactual = ExpenseSOrderData.selectConvertedAmt(this, priceactual, strCCurrencyId,
                strBPCCurrencyId, strDateexpense, vars.getClient(), vars.getOrg());
            pricelist = ExpenseSOrderData.selectConvertedAmt(this, pricelist, strCCurrencyId,
                strBPCCurrencyId, strDateexpense, vars.getClient(), vars.getOrg());
            pricelimit = ExpenseSOrderData.selectConvertedAmt(this, pricelimit, strCCurrencyId,
                strBPCCurrencyId, strDateexpense, vars.getClient(), vars.getOrg());
          }
        }

        // Recalculates precisions for the business partner pricelist
        // currency
        ExpenseSOrderData[] data4 = ExpenseSOrderData.selectPrecisions(this, strBPCCurrencyId);
        if (data4 != null && data4.length > 0) {
          strPrecision = data4[0].stdprecision.equals("") ? "0" : data4[0].stdprecision;
          strPricePrecision = data4[0].priceprecision.equals("") ? "0" : data4[0].priceprecision;
        }
        int StdPrecision = Integer.valueOf(strPrecision).intValue();
        int PricePrecision = Integer.valueOf(strPricePrecision).intValue();
        priceActual = (priceactual.equals("") ? ZERO : (new BigDecimal(priceactual)));
        priceActual = priceActual.setScale(PricePrecision, BigDecimal.ROUND_HALF_UP);
        priceList = (pricelist.equals("") ? ZERO : (new BigDecimal(pricelist)));
        priceList = priceList.setScale(PricePrecision, BigDecimal.ROUND_HALF_UP);
        priceLimit = (pricelimit.equals("") ? ZERO : (new BigDecimal(pricelimit)));
        priceLimit = priceLimit.setScale(PricePrecision, BigDecimal.ROUND_HALF_UP);

        // Calculating discount
        if (priceList.compareTo(BigDecimal.ZERO) == 0)
          discount = ZERO;
        else {
          if (log4j.isDebugEnabled())
            log4j.debug("pricelist:" + Double.toString(priceList.doubleValue()));
          if (log4j.isDebugEnabled())
            log4j.debug("priceActual:" + Double.toString(priceActual.doubleValue()));
          discount = ((priceList.subtract(priceActual)).divide(priceList, 12,
              BigDecimal.ROUND_HALF_EVEN)).multiply(new BigDecimal("100"));
        }
        if (log4j.isDebugEnabled())
          log4j.debug("Discount: " + discount.toString());
        if (discount.scale() > StdPrecision) {
          discount = discount.setScale(StdPrecision, BigDecimal.ROUND_HALF_UP);
        }
        if (log4j.isDebugEnabled())
          log4j.debug("Discount rounded: " + discount.toString());

        priceactual = priceActual.toString();
        pricelist = priceList.toString();
        pricelimit = priceLimit.toString();
        strDiscount = discount.toString();

        if (priceactual.equals(""))
          priceactual = "0";
        if (pricelist.equals(""))
          pricelist = "0";
        if (pricelimit.equals(""))
          pricelimit = "0";
        if (strDiscount.equals(""))
          strDiscount = "0";

        String strCOrderlineID = SequenceIdData.getUUID();

        if (line == 0) {
          line = 10;
        } else {
          line = line + 10;
        }
        // Catch database error message
        try {
          ExpenseSOrderData.insertCOrderline(conn, this, strCOrderlineID, data[i].adClientId,
              strOrganization.equals("") ? data[i].adOrgId : strOrganization, vars.getUser(),
              strCOrderId, Integer.toString(line), data[i].cBpartnerId, ExpenseSOrderData
                  .cBPartnerLocationId(this, data[i].cBpartnerId), strDateOrdered, strDateOrdered,
              data[i].description, data[i].mProductId, data[i].mWarehouseId.equals("") ? vars
                  .getWarehouse() : data[i].mWarehouseId, data[i].cUomId.equals("") ? Utility
                  .getContext(this, vars, "#C_UOM_ID", "ExpenseSOrder") : data[i].cUomId,
              data[i].qty, strBPCCurrencyId, pricelist, priceactual, pricelimit, strCTaxID,
              data[i].sResourceassignmentId, strDiscount);
        } catch (ServletException ex) {
          myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          releaseRollbackConnection(conn);
          return myMessage;
        }
        // Catch database error message
        try {
          // Updates expense line with the sales order line ID
          ExpenseSOrderData.updateTimeExpenseLine(conn, this, strCOrderlineID,
              data[i].sTimeexpenselineId);
        } catch (ServletException ex) {
          myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
          releaseRollbackConnection(conn);
          return myMessage;
        }
      }

      releaseCommitConnection(conn);
      if (!strCOrderId.equals("")) {
        // Automatically processes Sales Order
        if (strCompleteAuto.equals("Y")) {
          try {
            OBError myError = processOrder(vars, strCOrderId);
            if (myError != null)
              textoMensaje.append(" -> ").append(myError.getMessage());
          } catch (ServletException ex) {
            myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
            return myMessage;
          }
        }
View Full Code Here

  private OBError processOrder(VariablesSecureApp vars, String strCOrderId) throws ServletException,
      NoConnectionAvailableException, SQLException {
    Connection conn = null;
    conn = getTransactionConnection();

    OBError myMessage = null;

    String pinstance = SequenceIdData.getUUID();
    try {
      PInstanceProcessData.insertPInstance(this, pinstance, "104", strCOrderId, "N",
          vars.getUser(), vars.getClient(), vars.getOrg());
View Full Code Here

      xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
    } catch (Exception ex) {
      throw new ServletException(ex);
    }
    {
      OBError myMessage = vars.getMessage("ExpenseSOrder");
      vars.removeMessage("ExpenseSOrder");
      if (myMessage != null) {
        xmlDocument.setParameter("messageType", myMessage.getType());
        xmlDocument.setParameter("messageTitle", myMessage.getTitle());
        xmlDocument.setParameter("messageMessage", myMessage.getMessage());
      }
    }
    // //----

    response.setContentType("text/html; charset=UTF-8");
View Full Code Here

  protected OBError doIt(VariablesSecureApp vars) throws ServletException {
    int no = 0;
    ConnectionProvider conn = null;
    Connection con = null;
    OBError myError = new OBError();

    try {
      conn = getConnection();
      con = conn.getTransactionConnection();
      if (m_deleteOldImported) {
        no = ImportAccountData.deleteOld(con, conn, getAD_Client_ID());
        if (log4j.isDebugEnabled())
          log4j.debug("Delete Old Imported = " + no);
      }
      // Set Client, Org, IaActive, Created/Updated
      no = ImportAccountData.updateRecords(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount Reset = " + no);

      // Set element
      if (!m_C_Element_ID.equals("0")) {
        no = ImportAccountData.updateElement(con, conn, m_C_Element_ID, getAD_Client_ID());
        if (log4j.isDebugEnabled())
          log4j.debug("ImportAccount Element = " + no);
      }
      no = ImportAccountData.updateIdByName(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount ids by name = " + no);
      no = ImportAccountData.updateElementError(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount element errors = " + no);

      // Set column
      no = ImportAccountData.updateColumn(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount updated columns = " + no);
      no = ImportAccountData.updateColumnError(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount column errors = " + no);

      // Set default values for PostActual, PostBudget, PostStatistical,
      // PostEncumbrance, IsSummary, IsDocControlled
      String[] yColumns = new String[] { "PostActual", "PostBudget", "PostStatistical",
          "PostEncumbrance" };
      for (int i = 0; i < yColumns.length; i++) {
        no = ImportAccountData.updateYColumns(con, conn, yColumns[i], getAD_Client_ID());
        if (log4j.isDebugEnabled())
          log4j.debug("ImportAccount " + yColumns[i] + " errors = " + no);
      }
      no = ImportAccountData.updateSummary(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount updated summary = " + no);
      no = ImportAccountData.updateDocControlled(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount updated docControlled = " + no);

      // Check Account Type A (E) L M O R
      no = ImportAccountData.updateAccountType(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount updated AccountType = " + no);
      no = ImportAccountData.updateAccountTypeError(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount AccountType errors = " + no);

      // Check Account Sign (N) C B
      no = ImportAccountData.updateAccountSign(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount updated AccountSign = " + no);
      no = ImportAccountData.updateAccountSignError(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount AccountSign errors = " + no);

      // Update ElementValue from existing
      no = ImportAccountData.updateCElementValueID(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount updated CElementValueID = " + no);

      // Disable triggers
      ImportAccountData.disableTriggers(con, conn);
      if (log4j.isDebugEnabled())
        log4j.debug("Triggers in C_ValidCombination disabled");

      conn.releaseCommitConnection(con);
      // Default accounts
      String[][] defaults = null;
      defaults = new String[73][2];

      defaults[0][0] = "PPVOFFSET_ACCT";
      defaults[1][0] = "USESUSPENSEBALANCING";// Never used
      defaults[2][0] = "SUSPENSEBALANCING_ACCT";
      defaults[3][0] = "USESUSPENSEERROR";// Never used
      defaults[4][0] = "SUSPENSEERROR_ACCT";
      defaults[5][0] = "USECURRENCYBALANCING";// Never used
      defaults[6][0] = "CURRENCYBALANCING_ACCT";
      defaults[7][0] = "RETAINEDEARNING_ACCT";
      defaults[8][0] = "INTERCOMPANYDUETO_ACCT";
      defaults[9][0] = "INTERCOMPANYDUEFROM_ACCT";
      defaults[10][0] = "CFS_ORDER_ACCT";
      defaults[11][0] = "W_INVENTORY_ACCT";
      defaults[12][0] = "W_INVACTUALADJUST_ACCT";
      defaults[13][0] = "W_DIFFERENCES_ACCT";
      defaults[14][0] = "W_REVALUATION_ACCT";
      defaults[15][0] = "P_REVENUE_ACCT";
      defaults[16][0] = "P_EXPENSE_ACCT";
      defaults[17][0] = "P_ASSET_ACCT";
      defaults[18][0] = "P_INVOICEPRICEVARIANCE_ACCT";
      defaults[19][0] = "P_TRADEDISCOUNTREC_ACCT";
      defaults[20][0] = "P_TRADEDISCOUNTGRANT_ACCT";
      defaults[21][0] = "P_COGS_ACCT";
      defaults[22][0] = "C_RECEIVABLE_ACCT";
      defaults[23][0] = "V_LIABILITY_ACCT";
      defaults[24][0] = "V_LIABILITY_SERVICES_ACCT";
      defaults[25][0] = "V_PREPAYMENT_ACCT";
      defaults[26][0] = "PAYDISCOUNT_EXP_ACCT";
      defaults[27][0] = "WRITEOFF_ACCT";
      defaults[28][0] = "PAYDISCOUNT_REV_ACCT";
      defaults[29][0] = "UNREALIZEDGAIN_ACCT";
      defaults[30][0] = "UNREALIZEDLOSS_ACCT";
      defaults[31][0] = "REALIZEDGAIN_ACCT";
      defaults[32][0] = "REALIZEDLOSS_ACCT";
      defaults[33][0] = "WITHHOLDING_ACCT";
      defaults[34][0] = "E_PREPAYMENT_ACCT";
      defaults[35][0] = "E_EXPENSE_ACCT";
      defaults[36][0] = "PJ_ASSET_ACCT";
      defaults[37][0] = "PJ_WIP_ACCT";
      defaults[38][0] = "T_EXPENSE_ACCT";
      defaults[39][0] = "T_LIABILITY_ACCT";
      defaults[40][0] = "T_RECEIVABLES_ACCT";
      defaults[41][0] = "T_DUE_ACCT";
      defaults[42][0] = "T_CREDIT_ACCT";
      defaults[43][0] = "B_INTRANSIT_ACCT";
      defaults[44][0] = "B_ASSET_ACCT";
      defaults[45][0] = "B_EXPENSE_ACCT";
      defaults[46][0] = "B_INTERESTEXP_ACCT";
      defaults[47][0] = "B_UNIDENTIFIED_ACCT";
      defaults[48][0] = "B_UNALLOCATEDCASH_ACCT";
      defaults[49][0] = "B_PAYMENTSELECT_ACCT";
      defaults[50][0] = "B_SETTLEMENTGAIN_ACCT";
      defaults[51][0] = "B_SETTLEMENTLOSS_ACCT";
      defaults[52][0] = "B_REVALUATIONGAIN_ACCT";
      defaults[53][0] = "B_REVALUATIONLOSS_ACCT";
      defaults[54][0] = "CH_EXPENSE_ACCT";
      defaults[55][0] = "CH_REVENUE_ACCT";
      defaults[56][0] = "UNEARNEDREVENUE_ACCT";
      defaults[57][0] = "NOTINVOICEDRECEIVABLES_ACCT";
      defaults[58][0] = "NOTINVOICEDREVENUE_ACCT";
      defaults[59][0] = "NOTINVOICEDRECEIPTS_ACCT";
      defaults[60][0] = "CB_ASSET_ACCT";
      defaults[61][0] = "CB_CASHTRANSFER_ACCT";
      defaults[62][0] = "CB_DIFFERENCES_ACCT";
      defaults[63][0] = "CB_RECEIPT_ACCT";
      defaults[64][0] = "A_ACCUMDEPRECIATION_ACCT";
      defaults[65][0] = "A_DEPRECIATION_ACCT";
      defaults[66][0] = "A_DISPOSAL_GAIN";
      defaults[67][0] = "INCOMESUMMARY_ACCT";
      defaults[68][0] = "P_PURCHASEPRICEVARIANCE_ACCT";
      defaults[69][0] = "C_PREPAYMENT_ACCT";
      defaults[70][0] = "B_INTERESTREV_ACCT";
      defaults[71][0] = "CB_EXPENSE_ACCT";
      defaults[72][0] = "A_DISPOSAL_LOSS";

      // till here, the edition of the I_ElementValue table
      // now, the insertion from I_ElementValue table in C_ElementValue...

      int noInsert = 0;
      int noUpdate = 0;
      int noAccountError = 0;

      con = conn.getTransactionConnection();
      ImportAccountData[] records = ImportAccountData.selectRecords(conn, getAD_Client_ID());
      for (int i = 0; i < records.length; i++) {
        String I_ElementValue_ID = records[i].iElementvalueId;
        String C_ElementValue_ID = records[i].cElementvalueId;

        if (log4j.isDebugEnabled())
          log4j.debug("I_ElementValue_ID=" + I_ElementValue_ID + ", C_ElementValue_ID="
              + C_ElementValue_ID);
        if (C_ElementValue_ID.equals("0") || C_ElementValue_ID == null
            || C_ElementValue_ID.equals("")) { // insert new
          try {
            C_ElementValue_ID = SequenceIdData.getUUID();
            records[i].cElementvalueId = C_ElementValue_ID;
            no = ImportAccountData.insertElementValue(con, conn, C_ElementValue_ID,
                I_ElementValue_ID);
            if (log4j.isDebugEnabled())
              log4j.debug("Insert ElementValue = " + no);
            noInsert += no;
          } catch (ServletException ex) {
            if (log4j.isDebugEnabled())
              log4j.debug("Insert ElementValue - " + ex.toString());
            ImportAccountData.insertElementValueError(con, conn, ex.toString(), I_ElementValue_ID);
            continue;
          }
        } else { // update
          try {
            no = ImportAccountData.updateElementValue(con, conn, I_ElementValue_ID,
                C_ElementValue_ID);
            if (log4j.isDebugEnabled())
              log4j.debug("Insert ElementValue = " + no);
            noUpdate += no;
          } catch (ServletException ex) {
            if (log4j.isDebugEnabled())
              log4j.debug("Update ElementValue - " + ex.toString());
            ImportAccountData.updateElementValueError(con, conn, ex.toString(), I_ElementValue_ID);
            continue;
          }
        }
        ImportAccountData.updateProcessing(con, conn, C_ElementValue_ID, I_ElementValue_ID);
      }
      // records = ImportAccountData.selectRecords(con, conn,
      // getAD_Client_ID());

      for (int i = 0; i < records.length; i++) {
        String I_ElementValue_ID = records[i].iElementvalueId;
        String elementValue = records[i].value;
        boolean found = false;
        for (int j = 0; j < 73 && !found && records[i].defaultAccount != null
            && !(records[i].defaultAccount).equals(""); j++) {
          if (defaults[j][0].equals(records[i].defaultAccount)) {
            defaults[j][1] = records[i].cElementvalueId;
            found = true;
          }
        }

        if (log4j.isDebugEnabled())
          log4j.debug("I_ElementValue_ID=" + I_ElementValue_ID + ", elementValue=" + elementValue);
        try {
          String[][] strOperand = operandProcess(ImportAccountData.selectOperands(con, conn,
              I_ElementValue_ID));
          String strSeqNo = "10";
          for (int j = 0; strOperand != null && j < strOperand.length; j++) {
            String C_ElementValue_Operand_ID = SequenceIdData.getUUID();
            String strAccount = ImportAccountData.selectAccount(con, conn, strOperand[j][0], vars
                .getClient(), m_C_Element_ID);
            String strElementValue = ImportAccountData.selectAccount(con, conn, elementValue, vars
                .getClient(), m_C_Element_ID);
            if (strAccount != null && !strAccount.equals("")) {
              ImportAccountData.insertOperands(con, conn, C_ElementValue_Operand_ID,
                  (strOperand[j][1].equals("+") ? "1" : "-1"), strElementValue, strAccount,
                  strSeqNo, vars.getClient(), vars.getUser());
              strSeqNo = nextSeqNo(strSeqNo);
            } else {
              if (log4j.isDebugEnabled())
                log4j.debug("Operand not inserted - Value = " + strOperand[j][0]);
            }
          }
        } catch (ServletException ex) {
          log4j.warn("ServletException I_ElementValue_ID=" + I_ElementValue_ID);
          ImportAccountData.insertElementValueError(con, conn, ex.toString(), I_ElementValue_ID);
          continue;
        }
      }
      ImportAccountData[] acctSchemas = ImportAccountData.selectAcctSchema(conn, m_C_Element_ID,
          getAD_Client_ID());
      for (int g = 0; g < acctSchemas.length; g++) {
        String defaultsRecordNo = ImportAccountData.selectDefaultsRecord(con, conn,
            acctSchemas[g].cAcctschemaId);
        if (defaultsRecordNo.equals("0")) {
          String C_AcctSchema_Default_ID = SequenceIdData.getUUID();
          ImportAccountData.insertDefaultsRecord(con, conn, acctSchemas[g].cAcctschemaId,
              acctSchemas[g].adClientId, acctSchemas[g].adOrgId, vars.getUser(),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[11][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[12][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[13][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[14][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[15][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[16][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[17][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[68][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[18][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[19][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[20][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[21][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[22][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[69][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[23][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[24][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[25][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[26][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[27][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[28][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[29][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[30][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[31][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[32][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[33][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[34][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[35][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[36][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[37][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[38][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[39][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[40][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[41][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[42][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[43][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[44][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[45][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[70][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[46][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[47][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[48][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[49][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[50][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[51][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[52][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[53][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[54][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[55][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[56][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[57][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[58][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[59][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[60][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[61][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[62][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[71][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[63][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[64][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[65][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[66][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[72][1], vars.getUser()),
              C_AcctSchema_Default_ID);
        }
        String gLRecordNo = ImportAccountData.selectGLRecord(con, conn,
            acctSchemas[g].cAcctschemaId);
        if (gLRecordNo.equals("0"))
          ImportAccountData.insertGLRecord(con, conn, acctSchemas[g].cAcctschemaId,
              acctSchemas[g].adClientId, acctSchemas[g].adOrgId, vars.getUser(),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[2][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[4][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[6][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[7][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[67][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[8][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[9][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[0][1], vars.getUser()),
              getValidCombination(con, conn, acctSchemas[g].adClientId, acctSchemas[g].adOrgId,
                  acctSchemas[g].cAcctschemaId, defaults[10][1], vars.getUser()));
      }
      // Set Error to indicator to not imported
      noAccountError = ImportAccountData.updateNotImported(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("Errors: " + noAccountError);
      if (log4j.isDebugEnabled())
        log4j.debug("Inserts: " + noInsert);
      if (log4j.isDebugEnabled())
        log4j.debug("Updates: " + noUpdate);
      addLog(Utility.messageBD(conn, "Elements not imported", vars.getLanguage()) + ": "
          + noAccountError + "; ");
      addLog("Elements inserted: " + noInsert + "; ");
      addLog("Elements updated: " + noUpdate + "; ");

      if (noAccountError == 0) {
        myError.setType("Success");
        myError.setTitle(Utility.messageBD(conn, "Success", vars.getLanguage()));
      } else if (noInsert > 0 || noUpdate > 0) {
        myError.setType("Warning");
        myError.setTitle(Utility.messageBD(conn, "Some elements could not be imported", vars
            .getLanguage()));
      } else {
        myError.setType("Error");
        myError.setTitle(Utility.messageBD(conn, " No elements could be imported", vars
            .getLanguage()));
      }

      conn.releaseCommitConnection(con);

      con = conn.getTransactionConnection();
      // Set parent
      no = ImportAccountData.setParent(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount updated parent = " + no);
      no = ImportAccountData.setParentError(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount updated parent errors = " + no);

      int noParentUpdate = 0;
      ImportAccountData[] parents = ImportAccountData.selectParents(con, conn, getAD_Client_ID());
      for (int i = 0; i < parents.length; i++) {
        no = ImportAccountData.updateTree(con, conn, parents[i].parentelementvalueId,
            parents[i].seqno, parents[i].adTreeId, parents[i].cElementvalueId);
        noParentUpdate += no;
      }
      addLog("Parent updates: " + noParentUpdate + " ");
      if (log4j.isDebugEnabled())
        log4j.debug("Parent updates: " + noParentUpdate);

      // Reset Processing Flag
      if (m_updateDefaultAccounts) {
        no = ImportAccountData.updateProcessed(con, conn, getAD_Client_ID(), "clause");
        updateDefaults(con, conn, vars);
      } else {
        no = ImportAccountData.updateProcessed(con, conn, getAD_Client_ID(), "");
      }
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount updated parent = " + no);

      // Re-enable triggers
      ImportAccountData.enableTriggers(con, conn);
      if (log4j.isDebugEnabled())
        log4j.debug("Triggers in C_ValidCombination enabled");
      // Update Description
      no = ImportAccountData.updateDescription(con, conn, getAD_Client_ID());
      if (log4j.isDebugEnabled())
        log4j.debug("ImportAccount updated description = " + no);

      conn.releaseCommitConnection(con);
    } catch (NoConnectionAvailableException ex) {
      throw new ServletException("@CODE=NoConnectionAvailable");
    } catch (SQLException ex2) {
      try {
        conn.releaseRollbackConnection(con);
      } catch (Exception ignored) {
      }
      throw new ServletException("@CODE=" + Integer.toString(ex2.getErrorCode()) + "@"
          + ex2.getMessage());
    } catch (Exception ex3) {
      try {
        conn.releaseRollbackConnection(con);
      } catch (Exception ignored) {
      }
      throw new ServletException("@CODE=@" + ex3.getMessage());
    }

    myError.setMessage(Utility.messageBD(conn, getLog(), vars.getLanguage()));
    return myError;
  }
View Full Code Here

TOP

Related Classes of org.openbravo.erpCommon.utility.OBError

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.