@Override
  public final String makeFilter(final Class<?> pEntityClass,
    final Map<String, Object> pAddParam) throws Exception {
    if (!AccountingEntry.class.isAssignableFrom(pEntityClass)) {
      throw new ExceptionWithCode(ExceptionWithCode.CONFIGURATION_MISTAKE,
        "This class not descendant of AccountingEntry: "
          + pEntityClass);
    }
    lazyEvalReplicationMethod(pAddParam);
    StringBuffer filterAvoidAccDbCr = new StringBuffer("");
    if (this.replicationMethod.getExcludeDebitAccounts().size() > 0) {
      filterAvoidAccDbCr.append(" and ((ACCDEBIT is null or ACCDEBIT not in (");
      boolean isFirst = true;
      for (ReplExcludeAccountsDebit repExclAccDb
        : this.replicationMethod.getExcludeDebitAccounts()) {
        if (isFirst) {
          isFirst = false;
        } else {
          filterAvoidAccDbCr.append(",");
        }
        filterAvoidAccDbCr.append("'" + repExclAccDb.getAccount()
          .getItsId() + "'");
      }
    }
    if (this.replicationMethod.getExcludeCreditAccounts().size() > 0) {
      if (this.replicationMethod.getExcludeDebitAccounts().size() > 0) {
        filterAvoidAccDbCr
          .append(")) and (ACCCREDIT is null or ACCCREDIT not in (");
      } else {
        filterAvoidAccDbCr
          .append(" and (ACCCREDIT is null or ACCCREDIT not in (");
      }
      boolean isFirst = true;
      for (ReplExcludeAccountsCredit repExclAccCr
        : this.replicationMethod.getExcludeCreditAccounts()) {
        if (isFirst) {
          isFirst = false;
        } else {
          filterAvoidAccDbCr.append(",");
        }
        filterAvoidAccDbCr.append("'" + repExclAccCr.getAccount()
          .getItsId() + "'");
      }
    }
    if (this.replicationMethod.getExcludeDebitAccounts().size() > 0
      && this.replicationMethod.getExcludeCreditAccounts().size() > 0) {
      filterAvoidAccDbCr.append(")))");
    } else if (this.replicationMethod.getExcludeDebitAccounts().size() > 0
      || this.replicationMethod.getExcludeCreditAccounts().size() > 0) {
      filterAvoidAccDbCr.append("))");
    }
    if (this.replicationMethod.getExcludeDebitAccounts().size() > 0
      || this.replicationMethod.getExcludeCreditAccounts().size() > 0) {
      return "(" + this.filterId.makeFilter(pEntityClass, pAddParam)
        + filterAvoidAccDbCr.toString() + ")";
    }
    return this.filterId.makeFilter(pEntityClass, pAddParam);
  }
@ Override public final String makeFilter ( final Class < ? > pEntityClass , final Map < String , Object > pAddParam ) throws Exception { if ( ! AccountingEntry . class . isAssignableFrom ( pEntityClass ) ) { throw new ExceptionWithCode ( ExceptionWithCode . CONFIGURATION_MISTAKE , "This class not descendant of AccountingEntry: " + pEntityClass ) ; } lazyEvalReplicationMethod ( pAddParam ) ; StringBuffer filterAvoidAccDbCr = new StringBuffer ( "" ) ; if ( this . replicationMethod . getExcludeDebitAccounts ( ) . size ( ) > 0 ) { filterAvoidAccDbCr . append ( " and ((ACCDEBIT is null or ACCDEBIT not in (" ) ; boolean isFirst = true ; for ( ReplExcludeAccountsDebit repExclAccDb : this . replicationMethod . getExcludeDebitAccounts ( ) ) { if ( isFirst ) { isFirst = false ; } else { filterAvoidAccDbCr . append ( "," ) ; } filterAvoidAccDbCr . append ( "'" + repExclAccDb . getAccount ( ) . getItsId ( ) + "'" ) ; } } if ( this . replicationMethod . getExcludeCreditAccounts ( ) . size ( ) > 0 ) { if ( this . replicationMethod . getExcludeDebitAccounts ( ) . size ( ) > 0 ) { filterAvoidAccDbCr . append ( ")) and (ACCCREDIT is null or ACCCREDIT not in (" ) ; } else { filterAvoidAccDbCr . append ( " and (ACCCREDIT is null or ACCCREDIT not in (" ) ; } boolean isFirst = true ; for ( ReplExcludeAccountsCredit repExclAccCr : this . replicationMethod . getExcludeCreditAccounts ( ) ) { if ( isFirst ) { isFirst = false ; } else { filterAvoidAccDbCr . append ( "," ) ; } filterAvoidAccDbCr . append ( "'" + repExclAccCr . getAccount ( ) . getItsId ( ) + "'" ) ; } } if ( this . replicationMethod . getExcludeDebitAccounts ( ) . size ( ) > 0 && this . replicationMethod . getExcludeCreditAccounts ( ) . size ( ) > 0 ) { filterAvoidAccDbCr . append ( ")))" ) ; } else if ( this . replicationMethod . getExcludeDebitAccounts ( ) . size ( ) > 0 || this . replicationMethod . getExcludeCreditAccounts ( ) . size ( ) > 0 ) { filterAvoidAccDbCr . append ( "))" ) ; } if ( this . replicationMethod . getExcludeDebitAccounts ( ) . size ( ) > 0 || this . replicationMethod . getExcludeCreditAccounts ( ) . size ( ) > 0 ) { return "(" + this . filterId . makeFilter ( pEntityClass , pAddParam ) + filterAvoidAccDbCr . toString ( ) + ")" ; } return this . filterId . makeFilter ( pEntityClass , pAddParam ) ; }
<p>
Interactive filter of accounting entries.
</p>
@param pEntityClass Entity Class
@param pAddParam additional params (must present requestedDatabaseId
and replicationMethodId of String type (WEB parameters))
@return filter e.g. "((ITSID>0 and IDDATABASEBIRTH=2135)
and ((ACCDEBIT is null or ACCDEBIT not in ('BadDebts'))
and (ACCCREDIT is null or ACCCREDIT not in ('BadDebts','Property'))))"
@throws Exception - an exception