<p>Convert from string.</p>
@param pAddParam additional params, e.g. IRequestData
to fill owner itsVersion.
@param pStrVal string representation
@return Boolean value
@throws Exception - an exception
505974
@Override
  public final Boolean fromString(final Map<String, Object> pAddParam,
    final String pStrVal) throws Exception {
    if (pStrVal == null // HTTP checkbox return nothing if unchecked
      || "".equals(pStrVal) || "false".equals(pStrVal)
        || "off".equals(pStrVal)) {
      return Boolean.FALSE;
    }
    return Boolean.TRUE;
  }
78172
public final <T extends IHasIdLongVersionName> void makeIt(
    final Map<String, Object> pAddParam, final IRequestData pRequestData,
      final Class<T> pItemClass) throws Exception {
    Set<String> filterAppearance = new HashSet<String>();
    pAddParam.put("filterAppearance", filterAppearance);
    StringBuffer sbWhere = this.srvEntitiesPage
      .revealPageFilterData(pAddParam, pRequestData, pItemClass);
    if (sbWhere.length() == 0) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "filter_must_be_not_empty");
    }
    String itemsCatalogAction = pRequestData
      .getParameter("itemsCatalogAction");
    if (!("add".equals(itemsCatalogAction)
      || "remove".equals(itemsCatalogAction))) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "wrong_action");
    }
    Long catalogId = Long.valueOf(pRequestData
      .getParameter(CatalogGs.class.getSimpleName() + ".itsId"));
    if (catalogId == null) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "catalog_must_be_not_empty");
    }
    CatalogGs catalogOfGoods = this.srvOrm
      .retrieveEntityById(pAddParam, CatalogGs.class, catalogId);
    if (catalogOfGoods == null) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "catalog_must_be_not_empty");
    }
    if (catalogOfGoods.getHasSubcatalogs()) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "catalog_must_not_has_subcatalog");
    }
    String whereStr = sbWhere.toString();
    Integer rowCount = this.srvOrm.evalRowCountWhere(pAddParam, pItemClass,
        whereStr);
    TradingSettings ts = (TradingSettings) pAddParam.get("tradSet");
    if (rowCount > ts.getMaxQuantityOfBulkItems()) {
      throw new ExceptionWithCode(ExceptionWithCode.SOMETHING_WRONG,
        "filtered_list_size_exceed_max_bulk");
    }
    Integer totalItems = Integer
      .valueOf(pRequestData.getParameter("totalItems"));
    if (!rowCount.equals(totalItems)) {
      throw new ExceptionWithCode(ExceptionWithCode.SOMETHING_WRONG,
        "filtered_list_has_changed");
    }
    List<T> itemsList = this.srvOrm.retrieveListWithConditions(pAddParam,
      pItemClass, "where " + whereStr);
    for (T items : itemsList) {
      AItemCatalog ic;
      if (pItemClass == InvItem.class) {
        ic = new GoodsCatalog();
      } else if (pItemClass == ServiceToSale.class) {
        ic = new ServiceCatalog();
      } else {
        throw new Exception("NEI: " + pItemClass);
      }
      ic.setItsCatalog(catalogOfGoods);
      ic.setItem(items);
      if ("add".equals(itemsCatalogAction)) {
        // add items to catalog
        this.srvOrm.insertEntity(pAddParam, ic);
      } else {
        // remove items from catalog
        this.srvOrm.deleteEntity(pAddParam, ic);
      }
    }
    pRequestData.setAttribute("itemsCatalogAction", itemsCatalogAction);
    pRequestData.setAttribute("filterAppearance", filterAppearance);
    pRequestData.setAttribute("totalItems", totalItems);
    pRequestData.setAttribute("itemsList", itemsList);
    pRequestData.setAttribute("catalogOfItems", catalogOfGoods);
  }
461183
@Override
  public final <T> void fill(final Map<String, Object> pAddParam,
    final T pEntity, final IRequestData pReq) throws Exception {
    boolean isDbgSh = this.logger.getDbgSh(this.getClass())
      && this.logger.getDbgFl() < 7010 && this.logger.getDbgCl() > 7015;
    if (isDbgSh) {
      this.logger.debug(null, FillEntityFromReq.class,
        "Default charset = " + Charset.defaultCharset());
    }
    @SuppressWarnings("unchecked")
    IFillerObjectFields<T> filler = (IFillerObjectFields<T>)
      this.fillersFieldsFactory.lazyGet(pAddParam, pEntity.getClass());
    for (String fieldName : filler.getFieldsNames()) {
      try {
        String valStr = pReq.getParameter(pEntity.getClass().getSimpleName()
          + "." + fieldName); // standard
        if (valStr != null) { // e.g. Boolean checkbox or none-editable
          String convName = this.fieldConverterNamesHolder.getFor(pEntity
           .getClass(), fieldName);
          if (isDbgSh) {
            this.logger.debug(null, FillEntityFromReq.class,
              "Try fill field/inClass/converterName/value: " + fieldName + "/"
                + pEntity.getClass().getCanonicalName() + "/" + convName
                  + "/" + valStr);
          }
          IConverterToFromString conv = this.convertersFieldsFatory
            .lazyGet(pAddParam, convName);
          Object fieldVal = conv.fromString(pAddParam,  valStr);
          if (fieldVal != null && isDbgSh) {
              this.logger.debug(null, FillEntityFromReq.class,
                "Converted fieldClass/toString: " + fieldVal.getClass()
                  .getCanonicalName() + "/" + fieldVal);
          }
          filler.fill(pAddParam, pEntity, fieldVal, fieldName);
        }
      } catch (Exception ex) {
        String msg = "Can't fill field/class: " + fieldName + "/"
          + pEntity.getClass().getCanonicalName();
        throw new ExceptionWithCode(ExceptionWithCode.SOMETHING_WRONG, msg, ex);
      }
    }
  }
400811
protected final PrcPurchRetGfe lazyGetPrcPurchRetGfe(
    final Map<String, Object> pAddParam) throws Exception {
    PrcPurchRetGfe proc = (PrcPurchRetGfe)
      this.processorsMap.get(PrcPurchRetGfe.class.getSimpleName());
    if (proc == null) {
      proc = new PrcPurchRetGfe();
      @SuppressWarnings("unchecked")
      PrcEntityPbEditDelete<RS, PurchaseReturn> procDlg =
    (PrcEntityPbEditDelete<RS, PurchaseReturn>) this.fctBnEntitiesProcessors
  .lazyGet(pAddParam, PrcEntityPbEditDelete.class.getSimpleName());
      proc.setPrcEntityPbEditDelete(procDlg);
      //assigning fully initialized object:
      this.processorsMap
        .put(PrcPurchRetGfe.class.getSimpleName(), proc);
    }
    return proc;
  }
1083501
protected final UtlInvLine<RS, PurchaseReturn, PurchaseReturnLine,
    PurchaseReturnTaxLine, PurchaseReturnGoodsTaxLine> lazyGetUtlPurRetGdLn(
      final Map<String, Object> pAddParam) throws Exception {
    UtlInvLine<RS, PurchaseReturn, PurchaseReturnLine,
      PurchaseReturnTaxLine, PurchaseReturnGoodsTaxLine> utlInvLn = this
        .utlPurRetGdLn;
    if (utlInvLn == null) {
      utlInvLn = new UtlInvLine<RS, PurchaseReturn, PurchaseReturnLine,
        PurchaseReturnTaxLine, PurchaseReturnGoodsTaxLine>();
      utlInvLn.setUtlInvBase(lazyGetUtlInvBase(pAddParam));
      utlInvLn.setInvTxMeth(lazyGetPurRetTxMeth(pAddParam));
      utlInvLn.setIsMutable(false);
      utlInvLn.setNeedMkTxCat(false);
      utlInvLn.setLtlCl(PurchaseReturnGoodsTaxLine.class);
      utlInvLn.setDstTxItLnCl(DestTaxGoodsLn.class);
      FactoryPersistableBase<PurchaseReturnGoodsTaxLine> fctLtl =
        new FactoryPersistableBase<PurchaseReturnGoodsTaxLine>();
      fctLtl.setObjectClass(PurchaseReturnGoodsTaxLine.class);
      fctLtl.setDatabaseId(getSrvDatabase().getIdDatabase());
      utlInvLn.setFctLineTxLn(fctLtl);
      //assigning fully initialized object:
      this.utlPurRetGdLn = utlInvLn;
    }
    return utlInvLn;
  }
279603
protected final PrcCsvSampleDataRow
    lazyGetPrcCsvSampleDataRow(
      final Map<String, Object> pAddParam) throws Exception {
    String beanName = PrcCsvSampleDataRow.class.getSimpleName();
    @SuppressWarnings("unchecked")
    PrcCsvSampleDataRow proc = (PrcCsvSampleDataRow)
      this.processorsMap.get(beanName);
    if (proc == null) {
      proc = new PrcCsvSampleDataRow();
      lazyInitRetrievers(pAddParam);
      proc.setRetrievers(this.retrievers);
      //assigning fully initialized object:
      this.processorsMap.put(beanName, proc);
      this.logger.info(null, FctBnTradeProcessors.class,
        beanName + " has been created.");
    }
    return proc;
  }
57528
protected final UtlInvLine<RS, PurchaseInvoice, PurchaseInvoiceServiceLine,
    PurchaseInvoiceTaxLine, PurchaseInvoiceServiceTaxLine> lazyGetUtlPurSrLn(
      final Map<String, Object> pAddParam) throws Exception {
    UtlInvLine<RS, PurchaseInvoice, PurchaseInvoiceServiceLine,
      PurchaseInvoiceTaxLine, PurchaseInvoiceServiceTaxLine> utlInvLn = this
        .utlPurInvSrLn;
    if (utlInvLn == null) {
      utlInvLn = new UtlInvLine<RS, PurchaseInvoice, PurchaseInvoiceServiceLine,
        PurchaseInvoiceTaxLine, PurchaseInvoiceServiceTaxLine>();
      utlInvLn.setUtlInvBase(lazyGetUtlInvBase(pAddParam));
      utlInvLn.setInvTxMeth(lazyGetPurInvTxMeth(pAddParam));
      utlInvLn.setIsMutable(true);
      utlInvLn.setNeedMkTxCat(true);
      utlInvLn.setLtlCl(PurchaseInvoiceServiceTaxLine.class);
      utlInvLn.setDstTxItLnCl(DestTaxServPurchLn.class);
      FactoryPersistableBase<PurchaseInvoiceServiceTaxLine> fctLtl =
        new FactoryPersistableBase<PurchaseInvoiceServiceTaxLine>();
      fctLtl.setObjectClass(PurchaseInvoiceServiceTaxLine.class);
      fctLtl.setDatabaseId(getSrvDatabase().getIdDatabase());
      utlInvLn.setFctLineTxLn(fctLtl);
      //assigning fully initialized object:
      this.utlPurInvSrLn = utlInvLn;
    }
    return utlInvLn;
  }
985130
public final synchronized String evalQueryBalance(
    final Map<String, Object> pAddParam, final Date pDate) throws Exception {
    if (this.queryBalance == null) {
      String flName = "/" + "accounting" + "/" + "balance"
        + "/" + "queryBalanceSheet.sql";
      this.queryBalance = loadString(flName);
    }
    String query = queryBalance.replace(":DATE1",
      String.valueOf(getSrvBalance()
        .evalDatePeriodStartFor(pAddParam, pDate).getTime()));
    query = query.replace(":DATE2", String.valueOf(pDate.getTime()));
    return query;
  }
1288648
public final String prn(final Map<String, Object> pAddParam,
    final BigDecimal pVal) {
    return this.srvNumberToString.print(pVal.toString(),
      (String) pAddParam.get("decSepv"),
        (String) pAddParam.get("decGrSepv"),
          (Integer) pAddParam.get("reportDp"),
            (Integer) pAddParam.get("digInGr"));
  }
1014201
protected final PrcBankStatementSave<RS> lazyGetPrcBankStatementSave(
    final Map<String, Object> pAddParam) throws Exception {
    @SuppressWarnings("unchecked")
    PrcBankStatementSave<RS> proc = (PrcBankStatementSave<RS>)
      this.processorsMap.get(PrcBankStatementSave.class.getSimpleName());
    if (proc == null) {
      proc = new PrcBankStatementSave<RS>();
      proc.setSrvOrm(getSrvOrm());
      proc.setCsvReader(getCsvReader());
      //assigning fully initialized object:
      this.processorsMap.put(PrcBankStatementSave.class.getSimpleName(), proc);
    }
    return proc;
  }
254403
protected final PrcAdditionCostLineDelete<RS>
    lazyGetPrcAdditionCostLineDelete(
      final Map<String, Object> pAddParam) throws Exception {
    @SuppressWarnings("unchecked")
    PrcAdditionCostLineDelete<RS> proc = (PrcAdditionCostLineDelete<RS>)
      this.processorsMap.get(PrcAdditionCostLineDelete.class.getSimpleName());
    if (proc == null) {
      proc = new PrcAdditionCostLineDelete<RS>();
      proc.setSrvAccSettings(getSrvAccSettings());
      proc.setSrvOrm(getSrvOrm());
      proc.setSrvDatabase(getSrvDatabase());
      //assigning fully initialized object:
      this.processorsMap
        .put(PrcAdditionCostLineDelete.class.getSimpleName(), proc);
    }
    return proc;
  }
1169581
protected final PrcSalesRetGfe lazyGetPrcSalesRetGfe(
    final Map<String, Object> pAddParam) throws Exception {
    PrcSalesRetGfe proc = (PrcSalesRetGfe)
      this.processorsMap.get(PrcSalesRetGfe.class.getSimpleName());
    if (proc == null) {
      proc = new PrcSalesRetGfe();
      @SuppressWarnings("unchecked")
      PrcEntityPbEditDelete<RS, SalesReturn> procDlg =
    (PrcEntityPbEditDelete<RS, SalesReturn>) this.fctBnEntitiesProcessors
  .lazyGet(pAddParam, PrcEntityPbEditDelete.class.getSimpleName());
      proc.setPrcEntityPbEditDelete(procDlg);
      //assigning fully initialized object:
      this.processorsMap
        .put(PrcSalesRetGfe.class.getSimpleName(), proc);
    }
    return proc;
  }
543381
protected final PrcPaymentFromSave<RS> createPutPrcPaymentFromSave(
      final Map<String, Object> pAddParam) throws Exception {
    PrcPaymentFromSave<RS> proc = new PrcPaymentFromSave<RS>();
    proc.setSrvAccSettings(getSrvAccSettings());
    proc.setSrvAccEntry(getSrvAccEntry());
    proc.setSrvOrm(getSrvOrm());
    proc.setSrvI18n(getSrvI18n());
    proc.setPrcSalesInvoiceSave(lazyGetPrcSalesInvoiceSave(pAddParam));
    //assigning fully initialized object:
    this.processorsMap.put(PrcPaymentFromSave.class.getSimpleName(), proc);
    return proc;
  }
492134
public final synchronized Date evalDateNextPeriodStart(
    final Map<String, Object> pAddParam,
      final Date pDateFor) throws Exception {
    EPeriod period = evalBalanceStorePeriod(pAddParam);
    if (!(period.equals(EPeriod.MONTHLY)
      || period.equals(EPeriod.WEEKLY)
        || period.equals(EPeriod.DAILY))) {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "stored_balance_period_must_be_dwm");
    }
    Calendar cal = Calendar.getInstance(new Locale("en", "US"));
    cal.setTime(pDateFor);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    if (period.equals(EPeriod.DAILY)) {
      cal.add(Calendar.DATE, 1);
    } else if (period.equals(EPeriod.MONTHLY)) {
      cal.add(Calendar.MONTH, 1);
      cal.set(Calendar.DAY_OF_MONTH, 1);
    } else if (period.equals(EPeriod.WEEKLY)) {
      cal.add(Calendar.DAY_OF_YEAR, 7);
      cal.set(Calendar.DAY_OF_WEEK, 1);
    }
    return cal.getTime();
  }
779159
public final void updateOwner(final Map<String, Object> pAddParam,
    final AdditionCostLine pEntity) throws Exception {
    String query =
    "select sum(ITSTOTAL) as ITSTOTAL from"
      + " ADDITIONCOSTLINE where ITSOWNER="
        + pEntity.getItsOwner().getItsId();
    Double total = getSrvDatabase().evalDoubleResult(query, "ITSTOTAL");
    pEntity.getItsOwner().setTotalAdditionCost(BigDecimal.valueOf(total)
.setScale(getSrvAccSettings().lazyGetAccSettings(pAddParam).getCostPrecision(),
  getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode()));
    pEntity.getItsOwner().setItsTotal(pEntity.getItsOwner()
      .getTotalMaterialsCost().add(pEntity.getItsOwner()
        .getTotalAdditionCost()).setScale(getSrvAccSettings()
      .lazyGetAccSettings(pAddParam).getCostPrecision(),
    getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode()));
    pEntity.getItsOwner().setItsCost(pEntity.getItsOwner().getItsTotal()
      .divide(pEntity.getItsOwner().getItsQuantity(),
        getSrvAccSettings().lazyGetAccSettings(pAddParam).getCostPrecision(),
          getSrvAccSettings().lazyGetAccSettings(pAddParam).getRoundingMode()));
    getSrvOrm().updateEntity(pAddParam, pEntity.getItsOwner());
  }
496750
@Override
  public final void makeOtherEntries(final Map<String, Object> pAddParam,
    final PrepaymentFrom pEntity, final IRequestData pRequestData,
      final boolean pIsNew) throws Exception {
    // nothing
  }
1033693
@Override
  public final void process(final Map<String, Object> pAddParam,
    final IRequestData pRequestData) throws Exception {
    this.prcAccEntitiesPage.process(pAddParam, pRequestData);
    pRequestData.setAttribute("typeCodeSubaccMap",
      this.srvTypeCode.getTypeCodeMap());
  }