FilterSearch.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.pdd.monitor.driver;

  21. import org.openspcoop2.pdd.monitor.Filtro;

  22. /**
  23. *
  24. * FilterSearch
  25. *
  26. * @author Andrea Poli (apoli@link.it)
  27. * @author $Author$
  28. * @version $Rev$, $Date$
  29. *
  30. */
  31. public class FilterSearch extends Filtro {

  32.     /**
  33.      *
  34.      */
  35.     private static final long serialVersionUID = 1L;
  36.    
  37.     private long limit = -1;
  38.     private long offset = -1;

  39.    
  40.     public long getOffset() {
  41.         return this.offset;
  42.     }
  43.     public void setOffset(long offset) {
  44.         this.offset = offset;
  45.     }
  46.     public long getLimit() {
  47.         return this.limit;
  48.     }
  49.     public void setLimit(long limit) {
  50.         this.limit = limit;
  51.     }
  52.    
  53.     @Override
  54.     public String toString(){
  55.         StringBuilder bf = new StringBuilder();
  56.         if(this.getBusta()!=null){
  57.             if(this.getBusta().getMittente()!=null){
  58.                 if(this.getBusta().getMittente().getTipo()!=null && !"".equals(this.getBusta().getMittente().getTipo()) &&
  59.                         this.getBusta().getMittente().getNome()!=null && !"".equals(this.getBusta().getMittente().getNome())){
  60.                     bf.append("Mittente(");
  61.                     bf.append(this.getBusta().getMittente().getTipo()+"/"+this.getBusta().getMittente().getNome());
  62.                     bf.append(")");
  63.                 }else{
  64.                     if(this.getBusta().getMittente().getTipo()!=null && !"".equals(this.getBusta().getMittente().getTipo())){
  65.                         bf.append("TipoMittente(");
  66.                         bf.append(this.getBusta().getMittente().getTipo());
  67.                         bf.append(")");
  68.                     }
  69.                     if(this.getBusta().getMittente().getNome()!=null && !"".equals(this.getBusta().getMittente().getNome())){
  70.                         if(bf.length()>0){
  71.                             bf.append(" ");
  72.                         }
  73.                         bf.append("Mittente(");
  74.                         bf.append(this.getBusta().getMittente().getNome());
  75.                         bf.append(")");
  76.                     }
  77.                 }
  78.             }
  79.             if(bf.length()>0){
  80.                 bf.append(" ");
  81.             }
  82.             if(this.getBusta().getDestinatario()!=null){
  83.                 if(this.getBusta().getDestinatario().getTipo()!=null && !"".equals(this.getBusta().getDestinatario().getTipo()) &&
  84.                         this.getBusta().getDestinatario().getNome()!=null && !"".equals(this.getBusta().getDestinatario().getNome())){
  85.                     if(bf.length()>0){
  86.                         bf.append(" ");
  87.                     }
  88.                     bf.append("Destinatario(");
  89.                     bf.append(this.getBusta().getDestinatario().getTipo()+"/"+this.getBusta().getDestinatario().getNome());
  90.                     bf.append(")");
  91.                 }else{
  92.                     if(this.getBusta().getDestinatario().getTipo()!=null && !"".equals(this.getBusta().getDestinatario().getTipo())){
  93.                         if(bf.length()>0){
  94.                             bf.append(" ");
  95.                         }
  96.                         bf.append("TipoDestinatario(");
  97.                         bf.append(this.getBusta().getDestinatario().getTipo());
  98.                         bf.append(")");
  99.                     }
  100.                     if(this.getBusta().getDestinatario().getNome()!=null && !"".equals(this.getBusta().getDestinatario().getNome())){
  101.                         if(bf.length()>0){
  102.                             bf.append(" ");
  103.                         }
  104.                         bf.append("Destinatario(");
  105.                         bf.append(this.getBusta().getDestinatario().getNome());
  106.                         bf.append(")");
  107.                     }
  108.                 }
  109.             }
  110.             if(this.getBusta().getServizio()!=null){
  111.                 boolean v = false;
  112.                 if(this.getBusta().getServizio().getTipo()!=null && !"".equals(this.getBusta().getServizio().getTipo()) &&
  113.                         this.getBusta().getServizio().getNome()!=null && !"".equals(this.getBusta().getServizio().getNome()) ){
  114.                     if(bf.length()>0){
  115.                         bf.append(" ");
  116.                     }
  117.                     bf.append("Servizio(");
  118.                     bf.append(this.getBusta().getServizio().getTipo()+"/"+this.getBusta().getServizio().getNome());
  119.                     if(this.getBusta().getServizio().getVersione()!=null && (this.getBusta().getServizio().getVersione().intValue()>0)) {
  120.                         bf.append(" v").append(this.getBusta().getServizio().getVersione().intValue());
  121.                         v = true;
  122.                     }
  123.                     bf.append(")");
  124.                 }else{
  125.                     if(this.getBusta().getServizio().getTipo()!=null && !"".equals(this.getBusta().getServizio().getTipo())){
  126.                         if(bf.length()>0){
  127.                             bf.append(" ");
  128.                         }
  129.                         bf.append("TipoServizio(");
  130.                         bf.append(this.getBusta().getServizio().getTipo());
  131.                         bf.append(")");
  132.                     }
  133.                     if(this.getBusta().getServizio().getNome()!=null && !"".equals(this.getBusta().getServizio().getNome())){
  134.                         if(bf.length()>0){
  135.                             bf.append(" ");
  136.                         }
  137.                         bf.append("Servizio(");
  138.                         bf.append(this.getBusta().getServizio().getNome());
  139.                         if(this.getBusta().getServizio().getVersione()!=null && (this.getBusta().getServizio().getVersione().intValue()>0)) {
  140.                             bf.append(" v").append(this.getBusta().getServizio().getVersione().intValue());
  141.                             v = true;
  142.                         }
  143.                         bf.append(")");
  144.                     }
  145.                 }
  146.                
  147.                 if(!v && this.getBusta().getServizio().getVersione()!=null && (this.getBusta().getServizio().getVersione().intValue()>0)) {
  148.                     if(bf.length()>0){
  149.                         bf.append(" ");
  150.                     }
  151.                     bf.append("Versione Servizio(");
  152.                     bf.append(this.getBusta().getServizio().getVersione().intValue());
  153.                     bf.append(")");
  154.                 }
  155.             }
  156.             if(this.getBusta().getAzione()!=null && !"".equals(this.getBusta().getAzione())){
  157.                 if(bf.length()>0){
  158.                     bf.append(" ");
  159.                 }
  160.                 bf.append("Azione(");
  161.                 bf.append(this.getBusta().getAzione());
  162.                 bf.append(")");
  163.             }
  164.             if(this.getBusta().getProfiloCollaborazione()!=null && !"".equals(this.getBusta().getProfiloCollaborazione())){
  165.                 if(bf.length()>0){
  166.                     bf.append(" ");
  167.                 }
  168.                 bf.append("ProfiloCollaborazione(");
  169.                 bf.append(this.getBusta().getProfiloCollaborazione());
  170.                 bf.append(")");
  171.             }      
  172.             if(this.getBusta().getCollaborazione()!=null && !"".equals(this.getBusta().getCollaborazione())){
  173.                 if(bf.length()>0){
  174.                     bf.append(" ");
  175.                 }
  176.                 bf.append("Collaborazione(");
  177.                 bf.append(this.getBusta().getCollaborazione());
  178.                 bf.append(")");
  179.             }
  180.             if(this.getBusta().getRiferimentoMessaggio()!=null && !"".equals(this.getBusta().getRiferimentoMessaggio())){
  181.                 if(bf.length()>0){
  182.                     bf.append(" ");
  183.                 }
  184.                 bf.append("RiferimentoMessaggio(");
  185.                 bf.append(this.getBusta().getRiferimentoMessaggio());
  186.                 bf.append(")");
  187.             }
  188.         }
  189.         if(this.getSoggettoList()!=null && this.getSoggettoList().size()>0){
  190.             for(int i=0; i<this.getSoggettoList().size(); i++){
  191.                 if(bf.length()>0){
  192.                     bf.append(" ");
  193.                 }
  194.                 bf.append("FiltroSoggetto["+i+"](");
  195.                 bf.append(this.getSoggettoList().get(i).getTipo()+"/"+this.getSoggettoList().get(i).getNome());
  196.                 bf.append(")");
  197.             }
  198.         }
  199.         if(this.getIdMessaggio()!=null && !"".equals(this.getIdMessaggio())){
  200.             if(bf.length()>0){
  201.                 bf.append(" ");
  202.             }
  203.             bf.append("IDMessaggio(");
  204.             bf.append(this.getIdMessaggio());
  205.             bf.append(")");
  206.         }
  207.         if(this.getMessagePattern()!=null && !"".equals(this.getMessagePattern())){
  208.             if(bf.length()>0){
  209.                 bf.append(" ");
  210.             }
  211.             bf.append("Pattern(");
  212.             bf.append(this.getMessagePattern());
  213.             bf.append(")");
  214.         }
  215.         if(this.getSoglia()>0){
  216.             if(bf.length()>0){
  217.                 bf.append(" ");
  218.             }
  219.             bf.append("Soglia(");
  220.             bf.append(this.getSoglia());
  221.             bf.append(")");
  222.         }
  223.         if(this.getStato()!=null && !"".equals(this.getStato().getValue())){
  224.             if(bf.length()>0){
  225.                 bf.append(" ");
  226.             }
  227.             bf.append("Stato(");
  228.             bf.append(this.getStato());
  229.             bf.append(")");
  230.         }
  231.         if(this.getTipo()!=null && !"".equals(this.getTipo())){
  232.             if(bf.length()>0){
  233.                 bf.append(" ");
  234.             }
  235.             bf.append("Tipo(");
  236.             bf.append(this.getTipo());
  237.             bf.append(")");
  238.         }

  239.         if(bf.length()>255){
  240.             return bf.substring(0, 250) +"...";
  241.         }
  242.         else{
  243.             return bf.toString();
  244.         }
  245.     }
  246. }